
JaraganI.52615 (Customer) asked a question.
I couldn't find any documentation for updating mappings for an app using Terraform. I am not using any social providers.
My terraform code looks like this. What should target_id and source_id be
resource "okta_profile_mapping" "example" {
target_id = ""
source_id = "okta"
delete_when_absent = false
mappings {
id = "firstName"
expression = "user.firstName"
}
mappings {
id = "lastName"
expression = "user.lastName"
}
mappings {
id = "email"
expression = "user.email"
}
mappings {
id = "login"
expression = "user.email"
}
mappings {
id = "custom"
expression = "user.custom"
}
}

Hi @JaraganI.52615 (Customer)
I don't see any documentation available for a Terraform deployment, however I think it's using the Okta API for mappings: https://developer.okta.com/docs/reference/api/mappings/
So the sourceID and targetid would be an ID that you should be able to retrieve via the mappings API
"source": {
"id": "otysbePhQ3yqt4cVv0g3",
"name": "user",
"type": "user",
..................................................................
},
"target": {
"id": "0oa1qmn4LZQQEH0wZ0g4",
"name": "okta_org2org",
"type": "appuser",
...................
}
Let me know if this helps.
Valentin Borcan at Okta
We are using this for _some_ oauth clients and we came up with something like this ..
data "okta_user_profile_mapping_source" "user" {}
resource "okta_profile_mapping" "profile-mapping" {
source_id = data.okta_user_profile_mapping_source.user.id
target_id = okta_app_oauth.client.id
however .. I have a follow up question here because it seems that the profile mapping is created but not applied (I checked and believe there is an internal API /mapping/reapply)
Is there a way to trigger this via terraform? .. I mean in my opinion it should be done by the terraform provider after creating the mapping so I consider this a bug.
They merged in a fix that works for me.
https://github.com/okta/terraform-provider-okta/pull/750