hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.61k stars 4.65k forks source link

`azurerm_container_group` - Fix update error with `diagnostics.log_analytics` defined #28025

Open magodo opened 5 days ago

magodo commented 5 days ago

Community Note

Description

This PR fixes an issue where updating the identity.type argument for the azurerm_container_group resource throws an error when diagnostics.log_analytics is defined due to the workspace key is not in the PUT request body (see: https://github.com/hashicorp/terraform-provider-azurerm/issues/27999).

Meanwhile, to pass the test cases, I did the following updates to the tests:

    testcase.go:173: Step 1/3 error: Error running apply: exit status 1
        Error: creating Container Group (Subscription: "*******"
        Resource Group Name: "acctestRG-241113234136602111"
        Container Group Name: "acctestcontainergroup-241113234136602111"): performing ContainerGroupsCreateOrUpdate: unexpected status 400 (400 Bad Request) with error: InaccessibleImage: The image 'mcr.microsoft.com/quantum/linux-selfcontained:latest' in container group 'acctestcontainergroup-241113234136602111' is not accessible. Please check the image and registry credential.
          with azurerm_container_group.test,
          on terraform_plugin_test.tf line 33, in resource "azurerm_container_group" "test":
          33: resource "azurerm_container_group" "test" {

PR Checklist

Changes to existing Resource / Data Source

Testing

$ TF_ACC=1 go test -v -timeout=20h -run='TestAccContainerGroup_(linuxBasic|AssignedIdentityUpdate)' ./internal/services/containers
=== RUN   TestAccContainerGroup_AssignedIdentityUpdate
=== PAUSE TestAccContainerGroup_AssignedIdentityUpdate
=== RUN   TestAccContainerGroup_AssignedIdentityUpdateWithLogWorkspace
=== PAUSE TestAccContainerGroup_AssignedIdentityUpdateWithLogWorkspace
=== RUN   TestAccContainerGroup_linuxBasic
=== PAUSE TestAccContainerGroup_linuxBasic
=== RUN   TestAccContainerGroup_linuxBasicMultipleContainers
=== PAUSE TestAccContainerGroup_linuxBasicMultipleContainers
=== RUN   TestAccContainerGroup_linuxBasicTagsUpdate
=== PAUSE TestAccContainerGroup_linuxBasicTagsUpdate
=== CONT  TestAccContainerGroup_AssignedIdentityUpdate
=== CONT  TestAccContainerGroup_linuxBasicTagsUpdate
=== CONT  TestAccContainerGroup_linuxBasicMultipleContainers
=== CONT  TestAccContainerGroup_linuxBasic
=== CONT  TestAccContainerGroup_AssignedIdentityUpdateWithLogWorkspace
--- PASS: TestAccContainerGroup_linuxBasic (99.34s)
--- PASS: TestAccContainerGroup_linuxBasicTagsUpdate (103.30s)
--- PASS: TestAccContainerGroup_linuxBasicMultipleContainers (150.62s)
--- PASS: TestAccContainerGroup_AssignedIdentityUpdate (154.40s)
--- PASS: TestAccContainerGroup_AssignedIdentityUpdateWithLogWorkspace (185.62s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/containers    185.652s

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

Related Issue(s)

Fixes #27999

[!NOTE] If this PR changes meaningfully during the course of review please update the title and description as required.