Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

okta_profile_mapping not destroyable #2185

Open
keks42 opened this issue Jan 22, 2025 · 1 comment
Open

okta_profile_mapping not destroyable #2185

keks42 opened this issue Jan 22, 2025 · 1 comment
Labels
bug triaged Triaged into internal Jira

Comments

@keks42
Copy link

keks42 commented Jan 22, 2025

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.5.7

Affected Resource(s)

  • okta_profile_mapping

Terraform Configuration Files

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

# -------- Okta provided stuff ----------
data "okta_policy" "idp_discovery_policy" {
  name = "Idp Discovery Policy"
  type = "IDP_DISCOVERY"
}

data "okta_user_profile_mapping_source" "user" {
  depends_on = [okta_idp_saml.entra_id]
}


# -------- Actual IDP Configuration ----------
resource "okta_idp_saml" "entra_id" {
  issuer            = "https://sts.windows.net/whatever"
  kid               = okta_idp_saml_key.entra_id_certificate.id
  name              = "Entra ID"
  sso_destination   = "https://login.microsoftonline.com/whatever"
  sso_url           = "https://login.microsoftonline.com/whatever"
  username_template = "idpuser.subjectNameId"
}

resource "okta_idp_saml_key" "entra_id_certificate" {
  x5c = [
    "MIIDnjCCAoagAwIBAgIGAVG3MN+PMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5p\nYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEUMBIGA1UECwwLU1NPUHJvdmlkZXIxEDAOBgN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YaZZKHpWSfdJp9"
  ]
}

## How are users from EntraID identified as the same user in Okta?
resource "okta_policy_rule_idp_discovery" "entra_id_user_identification" {
  name                 = "Azure AD"
  idp_type             = "SAML2"
  idp_id               = okta_idp_saml.entra_id.id
  user_identifier_type = "IDENTIFIER"
  policy_id            = data.okta_policy.idp_discovery_policy.id
  user_identifier_patterns {
    match_type = "SUFFIX"
    value      = "some.example.com"
  }
  depends_on = [okta_idp_saml.entra_id]
}


# -------- User Profile Mapping ----------
## Custom attributes
resource "okta_app_user_schema_property" "loginname" {
  app_id        = okta_idp_saml.entra_id.id
  index         = "loginname"
  title         = "Entra ID Loginname"
  type          = "string"
  external_name = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name"
}

## Actual mapping
resource "okta_profile_mapping" "example" {
  source_id          = okta_idp_saml.entra_id.id
  target_id          = data.okta_user_profile_mapping_source.user.id
  delete_when_absent = true

  mappings {
    id         = "login"
    expression = "appuser.${okta_app_user_schema_property.loginname.index}"
  }
}

Debug Output

Panic Output

Expected Behavior

Terraform should be able to destroy the resources that it just created.

Can this be done in the Admin UI?

Partly. When deleting the whole IDP in the Admin UI, the profile mapping is also deleted.

Can this be done in the actual API call?

I don't know.

Actual Behavior

Executed commands:

terraform init
terraform plan -var-file=vars.tfvars -out okta.tfplan
terraform apply okta.tfplan
terraform destroy -var-file=vars.tfvars 

The vars.tfvars file contains only the required variables (org_name / base_url / api_token).

Terraform successfully creates all the resources, but is not able to destroy the freshly created resources. The following error appears:

│ Error: failed to delete application user schema property: the API returned an error: Api validation failed: updateAppUserSchemas. Causes: errorSummary: Property loginname cannot be deleted. It is used to populate user.login.
│ 

Steps to Reproduce

See above.

Important Factoids

References

  • #0000
@monde monde added bug triaged Triaged into internal Jira labels Jan 28, 2025
@monde
Copy link
Collaborator

monde commented Jan 28, 2025

I would call this a bug because as noted, the TF provider doesn't exhibit quite the same behavior as the Admin UI (even though the TF provider is not the Admin UI and interacts with Okta through the management API).

#2185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triaged Triaged into internal Jira
Projects
None yet
Development

No branches or pull requests

2 participants