hashicorp / terraform-provider-azuread

Terraform provider for Azure Active Directory
https://registry.terraform.io/providers/hashicorp/azuread/latest/docs
Mozilla Public License 2.0
430 stars 294 forks source link

Terraform Import is not working as expected #1246

Open SuryenduB opened 11 months ago

SuryenduB commented 11 months ago

Community Note

Terraform (and AzureAD Provider) Version

terraform -v Terraform v1.5.5 on windows_386

Your version of Terraform is out of date! The latest version is 1.6.3. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

Terraform Configuration Files

import {
    to = azuread_conditional_access_policy.mfa_for_databricks_and_cloudflare
    id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

import {
    to = azuread_conditional_access_policy.sensitive_users_require_FIDO2_for_Sign_In
    id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

import {
   to =  azuread_authentication_strength_policy.fido
   id =  "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

Debug Output

https://gist.github.com/SuryenduB/3f36659227e599c54fb1ef1c3eeadcc8

Panic Output

Expected Behavior

Conditional Access Policy and Authentication Strength Policy should have been imported

Actual Behavior

Steps to Reproduce

1.terraform plan -generate-config-out azuread_conditional_access_policy.tf

  1. terraform apply

Important Factoids

References

manicminer commented 11 months ago

Thanks for reporting @SuryenduB. There are some challenges around importing/managing CAPs created outside of Terraform although we aim to resolve these were possible. Would you be able to post the affected CAP in full? You can retrieve it using the MS Graph API with the URI https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/{id}

For the authentication strength policy, it looks like you have specified an invalid policy ID. Like with CAPs, you can list these using MS Graph using the URI https://graph.microsoft.com/v1.0/policies/authenticationStrengthPolicies.