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

google_cloudfunctions_function does not see event_trigger topic name changes as a difference #13513

Assignees
Labels
bug forward/review In review; remove label to forward service/cloudfunctions

Comments

@jkosternl
Copy link

jkosternl commented Jan 18, 2023

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 the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

1.3.6

Used: hashicorp/google v4.49.0

Affected Resource(s)

  • google_cloudfunctions_function

Terraform Configuration Files

When changing an existing Cloud Function trigger topic name, a name change are not picked up as a change and thus ignored.

For example:
Current state in TF:

event_trigger {
 event_type = "google.pubsub.topic.publish"
 resource   = "whatever-events-inbound"
}

New to be state:

event_trigger {
 event_type = "google.pubsub.topic.publish"
 resource   = "events-inbound"
}

If you tf plan this change, TF concludes that there is no change.

Debug Output

Didn't make, since it is not needed.

Panic Output

NA

Expected Behavior

Every name change of a topic trigger should be taken as a change.

Actual Behavior

Name changes on a trigger from "price-events-inbound" to "new-price-events-inbound" are not considered as a change.
Only if you also change the last parts of the name, it does work. Like: "price-events-inbound" -> "price-events-inboundXX"

Steps to Reproduce

  1. Deploy a Cloud Function with a PubSub trigger to an existing PubSub topic called "price-events-inbound".
  2. Update your TF configuration to only update the topic name in PubSub and the Cloud Function trigger topic name to "events-inbound"
  3. Run tf plan and see that TF concludes: there is no change.

Important Factoids

NA

References

NA

@jkosternl jkosternl added the bug label Jan 18, 2023
@edwardmedia edwardmedia self-assigned this Jan 24, 2023
@edwardmedia
Copy link
Contributor

@jkosternl I can't repro the issue. Below code seems working as expected. Can you detail the config and steps so I can repro?

func compareSelfLinkOrResourceNameWithMultipleParts(_, old, new string, _ *schema.ResourceData) bool {

@jkosternl
Copy link
Author

Thanks for checking out on our bug report @edwardmedia. We will create some better repro path with an easy example to show it.

@jkosternl
Copy link
Author

But wait, is the next line L85 not already showing the problem @edwardmedia ?
return strings.HasSuffix(old, new)
If the old name ends with the new name, no change is detected... That's not good. Changing 123asdf to asdf will result in true!

To my opinion, this should be just a strings.Compare(old, new) right? Or do the creators like to support namespace change to be seen as no change? At least, the side-effect is huge.

@jkosternl
Copy link
Author

Thanks @edwardmedia for addressing and fixing this issue! Looks like the new code contains a lot more logic to compare the old and new values.

@github-actions
Copy link

github-actions bot commented Apr 1, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2023
@github-actions github-actions bot added service/cloudfunctions forward/review In review; remove label to forward labels Jan 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.