Skip to content

Conversation

@sumeetoc
Copy link

@sumeetoc sumeetoc commented Jun 24, 2021

This PR provides following updates:

  1. Added labels for GCS destination bucket
  2. Added lifecycle rules instead of just expiration days for GCS destination so that policies can be applied, also it has the updated examples on consumption

@comment-bot-dev
Copy link

comment-bot-dev commented Jun 24, 2021

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

sumeetoc added 2 commits June 25, 2021 00:44
…nation, updated relevant examples. 2. Added opinion based service account creation for subscriber, not always a service account would be required
@sumeetoc sumeetoc changed the title added labels for gcs destination Opinionated GCS and Pub/sub destination Jun 24, 2021
@sumeetoc
Copy link
Author

@bharathkkb could you please comment on this PR, I would be glad to make necessary updates to atleast get storage labels and lifecycle rules implemented for aggregated log gcs bucket

Copy link
Member

@bharathkkb bharathkkb 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 @sumeetoc

It would be great to put some more details into the PR description which currently states only bucket label changes.

Comment on lines -47 to +48
for_each = var.expiration_days == null ? [] : [var.expiration_days]
for_each = var.lifecycle_rules
Copy link
Member

Choose a reason for hiding this comment

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

This is breaking change and we will need an upgrade guide. Something similar to the diff you have in the readme should work. Example https://github.com/terraform-google-modules/terraform-google-log-export/blob/master/docs/upgrading_to_v5.0.md

Comment on lines 70 to 85
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
account_id = local.subscriber_id
display_name = "${local.topic_name} Topic Subscriber"
project = var.project_id
}

resource "google_pubsub_subscription_iam_member" "pubsub_subscriber_role" {
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
role = "roles/pubsub.subscriber"
project = var.project_id
subscription = local.pubsub_subscription
member = "serviceAccount:${google_service_account.pubsub_subscriber[0].email}"
}

resource "google_pubsub_topic_iam_member" "pubsub_viewer_role" {
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on why you need to break this functionality into two flags?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, so not all the SIEM tool requires service account to authenticate to the Pub/Sub, in few tools it uses users oauth tokens to authenticate. Though the existing SA creation is helpful, it might be additional/unnecessary resource for few deployments, hence the additional flag

Copy link
Member

Choose a reason for hiding this comment

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

@sumeetoc in those cases I think the best approach would be to create the subscription outside of the module

Copy link
Author

Choose a reason for hiding this comment

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

@bharathkkb are you suggesting to revert back the changes on pub/sub and if such requirement comes in then create subscription separately?

Copy link
Member

Choose a reason for hiding this comment

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

@sumeetoc yes correct since I think its easy enough to create just the subscription use this module topic output for your usecase.

Copy link
Author

Choose a reason for hiding this comment

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

@bharathkkb I've pushed the reverted changes for pub/sub, thanks for looking into this, please let me know if anything else is required

@sumeetoc
Copy link
Author

Thanks for the PR @sumeetoc

It would be great to put some more details into the PR description which currently states only bucket label changes.

Thanks, done

@sumeetoc
Copy link
Author

@bharathkkb the upgrade document is pushed in latest commit, please review and let me know if anything else is required. Would be glad to use this directly in approaching deployment :)

Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

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

Guide LGTM, thanks for adding.

Comment on lines 70 to 85
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
account_id = local.subscriber_id
display_name = "${local.topic_name} Topic Subscriber"
project = var.project_id
}

resource "google_pubsub_subscription_iam_member" "pubsub_subscriber_role" {
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
role = "roles/pubsub.subscriber"
project = var.project_id
subscription = local.pubsub_subscription
member = "serviceAccount:${google_service_account.pubsub_subscriber[0].email}"
}

resource "google_pubsub_topic_iam_member" "pubsub_viewer_role" {
count = var.create_subscriber ? 1 : 0
count = var.create_subscriber_sa ? 1 : 0
Copy link
Member

Choose a reason for hiding this comment

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

@sumeetoc in those cases I think the best approach would be to create the subscription outside of the module

@bharathkkb bharathkkb changed the title Opinionated GCS and Pub/sub destination feat!: Support lifecycle rules and labels for GCS submodule Jul 2, 2021
@bharathkkb bharathkkb merged commit 1636eed into terraform-google-modules:master Jul 2, 2021
@release-please release-please bot mentioned this pull request Jul 2, 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.

3 participants