You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The above should loop through a list of conditional access policies. Dynamic blocks (locations and platforms) should only be created if they exist in the policy and are not configured if:
the key (i.e. locations) does not exist
OR
the key's value is set to null
The for_each loop strategy works properly for the following dynamic blocks:
The provider flags policies that do not have locations or platforms configured as invalid, and that at least 1 locations blocks are required and 1 platforms blocks are required.
│ Error: Insufficient locations blocks
│
│ on caps.tf line 140, in resource "azuread_conditional_access_policy" "framework":
│ 140: conditions {
│
│ At least 1 "locations" blocks are required.
╵
╷
│ Error: Insufficient platforms blocks
│
│ on caps.tf line 140, in resource "azuread_conditional_access_policy" "framework":
│ 140: conditions {
│
│ At least 1 "platforms" blocks are required.
This is problematic for my use case because existing policies that I am importing have platforms and locations conditions set to null. The import process succeeds, but subsequent terraform plan results in the errors above.
Steps to Reproduce
terraform plan
Workaround
I can statically set locations and platforms with default values without using a dynamic block, but this will not accurately reflect existing conditional access policies that have locations and platforms set to null.
We would like to keep pre-existing Conditional Access Policies as-is without modification. Using the below workaround will result in modifying imported policies which have locations and platforms set to null during the next terraform plan/apply.
Hi @jworl, thanks for reporting this. It looks like you are using a very old version of the provider, as I believe this was fixed in v2.21.0 in April last year. Can you try updating to the latest version of the provider, which is currently v2.40.0, and trying again?
Note also that we have an upcoming fix in v2.41.0 later this week for #801, which also makes the grant_controls and session_controls blocks optional (though at least one must be specified), in case you run into this too.
Community Note
Terraform (and AzureAD Provider) Version
Affected Resource(s)
azuread_conditional_access_policy
Terraform Configuration Files
Expected Behavior
The above should loop through a list of conditional access policies. Dynamic blocks (locations and platforms) should only be created if they exist in the policy and are not configured if:
OR
The for_each loop strategy works properly for the following dynamic blocks:
Because locations and platforms are optional configurations, I expected this to work.
Actual Behavior
The provider flags policies that do not have locations or platforms configured as invalid, and that at least 1 locations blocks are required and 1 platforms blocks are required.
This is problematic for my use case because existing policies that I am importing have platforms and locations conditions set to null. The import process succeeds, but subsequent
terraform plan
results in the errors above.Steps to Reproduce
terraform plan
Workaround
I can statically set locations and platforms with default values without using a dynamic block, but this will not accurately reflect existing conditional access policies that have locations and platforms set to null.
We would like to keep pre-existing Conditional Access Policies as-is without modification. Using the below workaround will result in modifying imported policies which have locations and platforms set to null during the next terraform plan/apply.
References
I read through the bug report below. It seems similar, though for a different block (grant_controls).
The text was updated successfully, but these errors were encountered: