hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.82k stars 9.16k forks source link

[Bug]: file_system_locations cannot be removed from aws_codebuild_project #38888

Open neo-kenneth-colina opened 2 months ago

neo-kenneth-colina commented 2 months ago

Terraform Core Version

1.9.2

AWS Provider Version

5.62.0

Affected Resource(s)

aws_codebuild_project (file_system_locations)

Expected Behavior

It is expected that file system locations will no longer be configured in this CodeBuild project (on terraform and AWS console).

Actual Behavior

I have a CodeBuild project with one dynamic file_system_locations configuration. When updating the CodeBuild project by removing the entire file_system_locations block from aws_codebuild_project, during terraform plan/apply terraform says:

Terraform plan
# module.codebuild.aws_codebuild_project.codebuild_project will be updated in-place
  ~ resource "aws_codebuild_project" "codebuild_project" {
        id                     = "my-project-id"
        name                   = "my-project-name"
        tags                   = {
            "terraform"        = "true"
        }
        # (10 unchanged attributes hidden)

      - file_system_locations {
          - identifier    = "EFS_MY_IDENTIFIER" -> null
          - location      = "my-location.ca-central-1.amazonaws.com:/" -> null
          - mount_options = "nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2" -> null
          - mount_point   = "/usr/share/efs-my-identifier" -> null
          - type          = "EFS" -> null
        }
        # (6 unchanged blocks hidden)
    }

Terraform apply   

module.codebuild.aws_codebuild_project.codebuild_project: Modifying... [id=arn:aws:codebuild:ca-central-1:xxxxxxxxxxxx:project/my-project-name]
module.codebuild.aws_codebuild_project.codebuild_project: Modifications complete after 1s [id=arn:aws:codebuild:ca-central-1:xxxxxxxxxxxx:project/my-project-name]

The file systems locations configuration still exists in this CodeBuild project. It is not updated. If I run terraform apply again, the same output of updating aws_codebuild_project will be given again.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_codebuild_project" "codebuild_project" {
  ...

  dynamic "file_system_locations" {
    for_each = var.efs
    content {
      identifier    = file_system_locations.value.identifier
      location      = file_system_locations.value.location
      mount_point   = file_system_locations.value.mount_point
      mount_options = file_system_locations.value.mount_options
    }
  }
}

Steps to Reproduce

  1. Create a CodeBuild project with the file system locations configuration (file_system_locations block).
  2. Delete the file_system_locations block in the .tf file and do terraform apply.
  3. Check the CodeBuild project configuration, and you will see the File systems configuration is still there.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

https://github.com/hashicorp/terraform-provider-aws/issues/29261 (it looks like the same issue) https://github.com/hashicorp/terraform-provider-aws/issues/21988 (not the same issue but the same resource block)

Would you like to implement a fix?

None

github-actions[bot] commented 2 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue