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.17k forks source link

file_system_locations keeps appearing in terraform plan after applied (aws_codebuild_project) #21988

Closed liana-filizola closed 10 months ago

liana-filizola commented 2 years ago

Community Note

Terraform CLI and Terraform AWS Provider Version

Terraform v1.0.6
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.67.0

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "aws_codebuild_project" "my_project_name" {
  name          = "my-project-name"
  description   = "xxxx"
  service_role  = aws_iam_role.xxxx.arn
  build_timeout = xx

  artifacts {
    type = "CODEPIPELINE"
  }

  environment {
    compute_type                = "xxx"
    image                       = "aws/codebuild/standard:3.0"
    type                        = "LINUX_CONTAINER"
    image_pull_credentials_type = "CODEBUILD"
    privileged_mode             = true

  source {
    type      = "CODEPIPELINE"
    buildspec = "./xxx.yml"
  }

  file_system_locations {
    identifier  = var.test.id
    location    = var.test.location
    mount_point = var.test.mount_point
  }

  vpc_config {
    security_group_ids = var.test.sg
    subnets            = var.test.sub
    vpc_id             = var.test.id
  }

  tags = local.tags

}

Debug Output

Panic Output

Expected Behavior

file_system_location does not change over plans.

Actual Behavior

file_system_location keeps being recreated/replaced in every plan after being applied.

# module.xxx.aws_codebuild_project.my_project_name will be updated in-place
--
779 | ~ resource "aws_codebuild_project" "my_project_name" {
780 | id                     = "arn:aws:codebuild:xxx"
781 | name                   = "my-project-name"
782 | tags                   = {
             xxx
787 | }
788 | # (9 unchanged attributes hidden)
789 |  
790 | + file_system_locations {
791 | + identifier  = "my_efs"
792 | + location    = "xxx.amazonaws.com:/"
793 | + mount_point = "path/abc/def"
794 | + type        = "EFS"
795 | }
796 | - file_system_locations {
797 | - identifier    = "my_efs" -> null
798 | - location      = "xxx.amazonaws.com:/" -> null
799 | - mount_options = "nfsvers=x.x,rsize=1234567,wsize=1234567,hard,timeo=xxx,retrans=x" -> null
800 | - mount_point   = "path/abc/def" -> null
801 | - type          = "EFS" -> null
802 | }
803 |  
804 | # (6 unchanged blocks hidden)
805 | }

Steps to Reproduce

  1. terraform plan

Important Factoids

References

justinretzolk commented 2 years ago

Hey @liana-filizola 👋 Thank you for taking the time to file this. I notice that you're not defining mount_options, yet it has a value in the plan output. Is it possible that that value is being modified outside of Terraform, causing Terraform to see a drift in configuration?

liana-filizola commented 2 years ago

Hi Justin, thanks for taking a look into this.

The mount_options are not being modified outside terraform. We have 2 older pipelines with no explicit mount_options that do not show up in the plan. But when I included 2 new ones, they appear in the plan every time as being modified, although they have the exactly same config.

I will test including the mount_options in the 2 new ones to check if they stop appearing in the plan, just need to wait the recovery of the us-east-1 outage.

Edit: Plan is clean when I define the mount_options in terraform.

DrFaust92 commented 2 years ago

@liana-filizola @justinretzolk according to docs https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ProjectFileSystemLocation.html it seems nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 is default value.

Edit1: i see acceptance tests also hardcode this explicitly, ill try to run tests without that argument and see if there is diff in plan

Edit2: project_test.go:321: Step 1/3 error: Check failed: Check 11/13 error: aws_codebuild_project.test: Attribute 'file_system_locations.0.mount_options' expected "nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=450,retrans=3", got ""

so its not the default value...

github-actions[bot] commented 11 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 9 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.