Azure / terraform-provider-azapi

Terraform provider for Azure Resource Manager Rest API
https://registry.terraform.io/providers/Azure/azapi/latest
Mozilla Public License 2.0
181 stars 48 forks source link

ResourceGroup Mandatroy Tags Azure Policy #500

Closed Romiko closed 1 month ago

Romiko commented 4 months ago

If we try to create a resource group in a subscription with an Azure Policy requiring mandatory tags for the resource group, it will fail. Seems Azapi is doing a two stage create / update. Possible fix is to apply tags upon creation?

Workaround - Use AzureRM instead of Azap.

[error]Bash wrote one or more lines to the standard error stream.

[error]2024-05-09T23:11:30.191Z [ERROR] provider.terraform-provider-azapi_v1.13.1: Response contains error diagnostic: tf_provider_addr=registry.terraform.io/Azure/azapi tf_resource_type=azapi_resource @caller=github.com/hashicorp/terraform-plugin-go@v0.22.1/tfprotov6/internal/diag/diagnostics.go:58 diagnostic_detail="creating/updating Resource: (ResourceId "/subscriptions/xyz/resourceGroups/rg-xyz-test-001" / Api Version "2021-04-01"): PUT https://management.azure.com/subscriptions/xyz/resourceGroups/rg-xyz-test-001


RESPONSE 403: 403 Forbidden ERROR CODE: RequestDisallowedByPolicy

Romiko commented 4 months ago

The cause is from another module.

ms-henglu commented 4 months ago

Hi @Romiko ,

Thank you for taking time to report this issue!

The cause is from another module.

Does this mean that you have found the cause? The azapi_resource is able to create the resource in one PUT request, the tags should be in the request body if specified in the config.

ms-henglu commented 1 month ago

I'll close this issue as there's no response and it seems to be fixed. Feel free to reopen this issue if there's any question.