Closed rpothin closed 5 months ago
Thanks for raising a bug @rpothin. There was a type in the unique identifier field; I have it fixed, should get into release soon.
Hey @mawasile 👋
Thank you very much for your quick action.
Your fix proposition seems definitely better than mine 😅
I hope the details I shared at least helped you find what to fix and where ☺️
I am looking forward to test this fix.
👍 Bonus point for you for also providing a fix for other resources in a similar situation.
Have a great day. Regards, Raphael
Describe the bug
I am exploring the scenario of switching from manually managing DLP policies to managing them using Terraform. I tried to use the
terraform import
command and theimport
block approach to achieve this, but without success.To Reproduce
terraform import
command approachSteps to reproduce the behavior:
terraform import command
- in the case of the configuration above, it would be something liketerraform powerplatform_data_loss_prevention_policy.my_policy <ID of the DLP policy you got from PPAC>
import
block approachSteps to reproduce the behavior:
import
block (the ID of the DLP Policy to import could be static in your configuration or coming from a var file) - like presented hereSample Terraform Code - used in the
import
block approachExpected behavior
I would like to be able to successfully execute the
terraform import
command or to use theimport
block approach to import an existing DLP policy into a state file to be able to switch the management of its configuration to Terraform.System Information
2.3.1-preview
Additional context
After some research and analysis, I think the issue is coming from the implementation of the
ImportState
method for the DLP policy resource.Like mentioned in the Terraform documentation, the resource state should be set in
resource.ImportStateResponse
and it does not seem to be the case currently.I am not sure if
path.Root("Id")
in the call to the ImportStatePassthroughID works as expected.Based on a long discussion with GitHub Copilot to try to understand this issue, I think a fix like the one below could potentially work:
What do you think?
Contribution
Do you plan to raise a PR to address this issue? YES, but only after we come to an agreement regarding the potential solution to fix this issue - if the issue is confirmed on your side obviously 😊
Thank you for taking the time to take a look at this issue and have a great day.