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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to resource google_logging_metric creates new resource and orphans older version when changing name attribute #18144

Open
RomeroGaliza opened this issue May 15, 2024 · 1 comment

Comments

@RomeroGaliza
Copy link

RomeroGaliza commented May 15, 2024

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.8.3
on 386

  • provider registry.terraform.io/hashicorp/google v5.29.1
  • provider registry.terraform.io/hashicorp/google-beta v5.29.1

Affected Resource(s)

google_logging_metric

Terraform Configuration

resource "google_logging_metric" "cloudsql_backup" {
  name   = "cloudsql/backup_status"
  filter = "resource.type=cloudsql_database AND protoPayload.methodName=cloudsql.instances.automatedBackup"

  metric_descriptor {
    metric_kind = "DELTA"
    value_type  = "INT64"

    labels {
      key         = "instance"
      value_type  = "STRING"
      description = "The instance name for the Cloud SQL database."
    }

    labels {
      key         = "status"
      value_type  = "STRING"
      description = "The automated backup status as seen in logs."
    }
  }

  label_extractors = {
    "instance" = "EXTRACT(protoPayload.resourceName)"
    "status"   = "EXTRACT(protoPayload.metadata.windowStatus)"
  }
}

Debug Output

No response

Expected Behavior

Terraform plan and apply indicates an update in-place, even though this resource API doesn't seem to support changing the name attribute.

Actual Behavior

The previous version (with older name) remains in place (however, it can no longer be seen in the state file), and a new resource with the new name is created (and can be seen in the state file).

Steps to reproduce

  1. Create a google_logging_metric resource;
  2. Rename the resource and run a terraform plan and apply;
  3. Check the resources in the project: gcloud logging metrics list

Important Factoids

No response

References

No response

b/342170664

@github-actions github-actions bot added forward/review In review; remove label to forward service/logging labels May 15, 2024
@ggtisc ggtisc self-assigned this May 22, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented May 22, 2024

Confirmed issue!

After creating the google_logging_metric if the name is replaced the terminal returns a message of update-in-place. The issue is that this is a wrong message because it doesn't apply this behavior, and just create a new metric keeping both metrics and just changing the terraform state file

@ggtisc ggtisc removed their assignment May 22, 2024
@ggtisc ggtisc removed the forward/review In review; remove label to forward label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants