Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module.aft_lambda_layer.aws_iam_role.codebuild causes drift #36

Closed
mathewmoon opened this issue Jan 20, 2022 · 4 comments
Closed

module.aft_lambda_layer.aws_iam_role.codebuild causes drift #36

mathewmoon opened this issue Jan 20, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@mathewmoon
Copy link

It looks like the assume_role_policy having the service principals not in alphabetical order causes drift. I believe that changing the order would fix this.

Terraform detected the following changes made outside of Terraform since the last "terraform apply":

  # module.aft.module.aft_lambda_layer.aws_iam_role.codebuild has been changed
  ~ resource "aws_iam_role" "codebuild" {
      ~ assume_role_policy    = jsonencode(
          ~ {
              ~ Statement = [
                  ~ {
                      ~ Principal = {
                          ~ Service = [
                              - "events.amazonaws.com",
                                "codebuild.amazonaws.com",
                              + "events.amazonaws.com",
                            ]
                        }
                        # (2 unchanged elements hidden)
                    },
                ]
                # (1 unchanged element hidden)
            }
        )
        id                    = "python-layer-builder-aft-common-4vpk5j6o"
        name                  = "python-layer-builder-aft-common-4vpk5j6o"
        tags                  = {}
        # (8 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }
@balltrev
Copy link

Looking at the template for the trust policy on that codebuild resource, I do not see that it has ever been in the order you're seeing. Was there a chance the policy was modified out of band?

@mathewmoon
Copy link
Author

No. It has only been touched by the TF module. Looking at the template they are in order. It appears for some reason that it gets saved to state differently.

@mathewmoon
Copy link
Author

Looks like an issue with AWS not guaranteeing order in its API and not consistently sorting the data in the provider.

hashicorp/terraform-provider-aws#11801

hashicorp/terraform-provider-aws#22274

Nothing we can do in the module to fix this.

@balltrev
Copy link

Ah, I see. Thanks for diving into this.

@snebhu3 snebhu3 added the no issue No issue with the package or a dependency label Feb 9, 2022
@balltrev balltrev added bug Something isn't working and removed no issue No issue with the package or a dependency labels Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants