Hi All,
I am working on a terraform code that creates password policy and then policy rule in Okta, both the code to create a password policy and the rule is in the same tf file, but while creating the rule I need to pass the policyid of newly created password policy, can someone help how can i pass new policy id as argument in rule.
Below is my code sample:
variable “org_name” {}
variable “api_token” {}
variable “base_url” {}
Enable and configure the Okta provider
terraform {
required_providers {
okta = {
source = “okta/okta”
version = “~> 3.15”
}
}
}
provider “okta” {
org_name = var.org_name
base_url = var.base_url
api_token = var.api_token
}
locals {
instances = csvdecode(file(“./passwordpolicy.csv”))
}
resource “okta_policy_password” “passwordpolicy” {
for_each = { for inst in local.instances : inst.name => inst }
name = each.value.name
description = each.value.description
status = each.value.status
auth_provider = each.value.auth_provider
password_min_length = each.value.password_min_length
password_min_uppercase = each.value.password_min_uppercase
password_min_symbol = each.value.password_min_symbol
groups_included = split(“|”, each.value.groups_included)
priority = each.value.priority
}
Above code creates policy id, I need to pass that value in below code
resource “okta_policy_rule_password” “policy_rules” {
for_each = { for inst in local.instances : inst.name => inst }
policy_id =
name = each.value.name
status = each.value.status
password_change = each.value.passwordChange
password_reset = each.value.passwordReset
}
Regards
Rahul Jha