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

fix: permadiff issue when docker_repository field is not specified #17072

Conversation

modular-magician
Copy link
Collaborator

When docker repository is not specified, by default docker repository projects/PROJECT_ID/locations/REGION/repositories/gcf-artifacts is used. Refer https://cloud.google.com/functions/docs/reference/rest/v2beta/projects.locations.functions#dockerregistry

In such a case, terraform plan always generates a difference for docker_repository field.

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.foo.google_cloudfunctions2_function.function will be updated in-place
  ~ resource "google_cloudfunctions2_function" "function" {
        id               = "projects/my-project-e044dd03/locations/europe-west1/functions/foo"
        name             = "foo"
        # (10 unchanged attributes hidden)

      ~ build_config {
          - docker_repository     = "projects/my-project-e044dd03/locations/europe-west1/repositories/gcf-artifacts" -> null
            # (4 unchanged attributes hidden)

            # (1 unchanged block hidden)
        }

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

This fix prevents unnecessary infrastructure change by setting the default repository id received from API.

Relates to GoogleCloudPlatform/cloud-foundation-fabric#1987

Release Note Template for Downstream PRs (will be copied)

Fixed an issue when `docker_repository` is not specified in build_config section of the `google_cloudfunctions2_function`, the provider should not generate a diff during plan for the default value used by the API.

Derived from GoogleCloudPlatform/magic-modules#9850

…ashicorp#9850)

relates to GoogleCloudPlatform/cloud-foundation-fabric#1987
When docker repository is not specified by default docker repository`projects/PROJECT_ID/locations/REGION/repositories/gcf-artifacts` is used.In such a case, terraform plan always generates a difference for `docker_repository`field as the module passes null value but the tfstate file has the above specifieddefault value. This fix allows one to prevent unnecessary infrastructure change.
[upstream:3540e663502c1286967dd61650bb8ee7c2b35cf9]

Signed-off-by: Modular Magician <[email protected]>
@modular-magician modular-magician merged commit cc2ea53 into hashicorp:main Jan 22, 2024
3 checks passed
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 22, 2024
@modular-magician modular-magician deleted the downstream-pr-3540e663502c1286967dd61650bb8ee7c2b35cf9 branch November 17, 2024 00:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant