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

Terraform state is not fully applied #2000

Closed
ameukam opened this issue May 4, 2021 · 5 comments · Fixed by #1974
Closed

Terraform state is not fully applied #2000

ameukam opened this issue May 4, 2021 · 5 comments · Fixed by #1974
Assignees
Labels
area/infra Infrastructure management, infrastructure design, code in infra/ area/terraform Terraform modules, testing them, writing more of them, code in infra/gcp/clusters/
Milestone

Comments

@ameukam
Copy link
Member

ameukam commented May 4, 2021

I got when I deployed #1604 for aaa:

  # google_project_iam_binding.readonlymonitoringbinding will be updated in-place
  ~ resource "google_project_iam_binding" "readonlymonitoringbinding" {
        etag    = "BwXAZra+ioU="
        id      = "kubernetes-public/roles/monitoring.viewer"
      ~ members = [
            "group:[email protected]",
          - "serviceAccount:k8s-infra-monitoring-viewer@kubernetes-public.iam.gserviceaccount.com",
        ]
        project = "kubernetes-public"
        role    = "roles/monitoring.viewer"
    }

  # google_project_iam_member.cluster_node_sa_monitoring_viewer will be created
  + resource "google_project_iam_member" "cluster_node_sa_monitoring_viewer" {
      + etag    = (known after apply)
      + id      = (known after apply)
      + member  = "serviceAccount:[email protected]"
      + project = "kubernetes-public"
      + role    = "roles/monitoring.viewer"
    }

Resources introduced in #365

@ameukam ameukam added wg/k8s-infra area/infra Infrastructure management, infrastructure design, code in infra/ area/terraform Terraform modules, testing them, writing more of them, code in infra/gcp/clusters/ labels May 4, 2021
@ameukam ameukam added this to the v1.22 milestone May 4, 2021
@ameukam
Copy link
Member Author

ameukam commented May 4, 2021

It's possible those resources were re-created or have been created. Not sure if the investigation is worth it.

@spiffxp
Copy link
Member

spiffxp commented May 4, 2021

/assign
Feels pretty likely this is related to something I pruned, possibly elsewhere in bash

@spiffxp
Copy link
Member

spiffxp commented May 5, 2021

I bumped into this while deploying changes that were part of #1952. I deployed the changes, so maybe it's resolved?

I suspect if there's still a conflict with bash, it may be with changes in #1974

I'll re-run terraform once that has merged to see if there's still a difference of opinion between terraform and bash about this

@spiffxp
Copy link
Member

spiffxp commented May 5, 2021

Added a commit to #1974 to fix this

terraform apply and ./infra/gcp/ensure-main-project.sh were getting in a fight over authoritative IAM bindings for the kubernetes-public project

IMO terraform shouldn't be setting authoritative bindings for a project unless it's also managing the project. Whereas in this case, the module in question is just for managing a GKE cluster within the project. The infra/gcp/ensure-main-project.sh script is the source of truth about the configuration of the kubernetes-public project.

I opted to move the bindings over to ensure-main-project.sh instead of updating the terraform module to non-authoritatively add IAM members, since they were related to a group that is managed outside of terraform vs. service accounts that were created by terraform.

As part of the commit I preemptively ran terraform state rm for the two resources that were removed, so that terraform won't try to destroy them

@ameukam
Copy link
Member Author

ameukam commented May 5, 2021

IMO terraform shouldn't be setting authoritative bindings for a project unless it's also managing the project. Whereas in this case, the module in question is just for managing a GKE cluster within the project. The infra/gcp/ensure-main-project.sh script is the source of truth about the configuration of the kubernetes-public project.

Totally make sense for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/infra Infrastructure management, infrastructure design, code in infra/ area/terraform Terraform modules, testing them, writing more of them, code in infra/gcp/clusters/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants