okta / terraform-provider-okta

A Terraform provider to manage Okta resources, enabling infrastructure-as-code provisioning and management of users, groups, applications, and other Okta objects.
https://registry.terraform.io/providers/okta/okta
Mozilla Public License 2.0
253 stars 206 forks source link

Add import support to `okta_profile_mapping` #1955

Open exitcode0 opened 5 months ago

exitcode0 commented 5 months ago

Community Note


Description

Currently the documentation states that there is "no reason" to import okta_profile_mapping

I disagree with this perspective and think that this resource should support import

Adding import support to this resource will make it easier to bring existing configuration under TF management It means that the terraform plan can be used to align your HCl with the current state of the resource regardless of how you craft your HCL


New or Affected Resource(s)


References


Other information

This is a duplicate of #888 I figured I should raise a new issue rather than necro-post on the old issue, if you feel differently we can close this one and re-open the original

duytiennguyen-okta commented 5 months ago

OKTA internal reference https://oktainc.atlassian.net/browse/OKTA-717456

duytiennguyen-okta commented 5 months ago

That statement was made 4 years ago and probably not true anymore

duytiennguyen-okta commented 1 month ago

@exitcode0 I have to revert this because of the weird behaviour surrounding d.GetOK()

exitcode0 commented 1 month ago

@duytiennguyen-okta did the importer not work without the problematic changes to d.GetOK()?

duytiennguyen-okta commented 1 month ago

It is related to delete_when_absent, which impact mappings. I will need to convert from sdk-plugin to plugin-framework to addess the issue

exitcode0 commented 1 month ago

Is that the only way to work around this? I'm happy to contribute a PR to get this back into the provider if there is a simpler MVP fix that we can do here, perhaps we can lift inspiration from another resource in the provider?

duytiennguyen-okta commented 1 month ago

I don't know there is another way, since GetOK() get confused false with null for delete_when_absent, which lead to all kind of issue. The plugin-frameworks will be able to differentiate between these 2 values

exitcode0 commented 1 month ago

I'm not super familiar with provider development yet, something i'd like to improve so I can contribute more here

Do we have access to d.GetOkExists() easily in this file?

duytiennguyen-okta commented 1 month ago

Yeah. Here is the thread with the same problem that we currently having https://discuss.hashicorp.com/t/terraform-sdk-usage-which-out-of-get-getok-getokexists-with-boolean/41815/2