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

Allow to create subscriptions independently with topic #72

Merged
merged 4 commits into from
Aug 19, 2021

Conversation

onimsha
Copy link
Contributor

@onimsha onimsha commented Jul 23, 2021

Fixes #71

@comment-bot-dev
Copy link

comment-bot-dev commented Jul 23, 2021

Thanks for the PR! 🚀
✅ Lint checks have passed.

main.tf Outdated Show resolved Hide resolved
@google-cla
Copy link

google-cla bot commented Aug 4, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@onimsha
Copy link
Contributor Author

onimsha commented Aug 4, 2021

@googlebot I signed it!

Copy link
Contributor

@morgante morgante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I'm not sure we want to change this so that each subscription can have a different topic though, as I think that's very different from the original intent of the module.

If you do want to have this, all of the subscriptions should be attached to the same topic.

@onimsha
Copy link
Contributor Author

onimsha commented Aug 5, 2021

Thanks for the PR. I'm not sure we want to change this so that each subscription can have a different topic though, as I think that's very different from the original intent of the module.

If you do want to have this, all of the subscriptions should be attached to the same topic.

Got it. Then how about this ?

  • Introduce a new variable, existing_topic, to use in the case create_topic = false .
  • Let all the subscriptions use the same topic, declared in existing_topic
  • Add another example to use the existing_topic by creating the topic in a project, while subscriptions in another project.

If you think we can go with this approach, i will make the changes.

@morgante
Copy link
Contributor

@onimsha I'm not sure I follow your use case.

If you want to attach subscriptions without creating the topic, why wouldn't you just set create_topic = false?

@onimsha
Copy link
Contributor Author

onimsha commented Aug 10, 2021

@onimsha I'm not sure I follow your use case.

If you want to attach subscriptions without creating the topic, why wouldn't you just set create_topic = false?

Because many resources in this module depend on this for_each = var.create_topic . One it's set to be false none of them will be created

@morgante
Copy link
Contributor

Because many resources in this module depend on this for_each = var.create_topic . One it's set to be false none of them will be created

I think we should update those resources to check a separate create_subscriptions variable instead. So, the new flow would be:

  1. If create_topic and create_subscriptions are both true (default) it creates both.
  2. If only create_subscriptions is true, only create subscriptions.
  3. If only create_topic is true, only create topic.

Signed-off-by: Alex Co <tuanclq@gmail.com>
Signed-off-by: Alex Co <tuanclq@gmail.com>
@onimsha
Copy link
Contributor Author

onimsha commented Aug 16, 2021

Because many resources in this module depend on this for_each = var.create_topic . One it's set to be false none of them will be created

I think we should update those resources to check a separate create_subscriptions variable instead. So, the new flow would be:

  1. If create_topic and create_subscriptions are both true (default) it creates both.
  2. If only create_subscriptions is true, only create subscriptions.
  3. If only create_topic is true, only create topic.

Changes pushed. Can you take a look ?

variables.tf Outdated Show resolved Hide resolved
main.tf Outdated Show resolved Hide resolved
examples/subscriptions_only/variables.tf Outdated Show resolved Hide resolved
examples/subscriptions_only/variables.tf Outdated Show resolved Hide resolved
Signed-off-by: Alex Co <tuanclq@gmail.com>
Signed-off-by: Alex Co <tuanclq@gmail.com>
@morgante morgante merged commit 0c25bf2 into terraform-google-modules:master Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow creating subscriptions for existing topics
3 participants