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

Updating to allow for multiple log watch in the same S3 bucket. #85

Closed
wants to merge 3 commits into from

Conversation

badcure
Copy link

@badcure badcure commented Sep 5, 2023

Description

The goal is to allow for multiple log watching on S3 buckets. There were a lot of conflicting resources, between lambdas and S3 file notifications, that only allowed for one log watch in a Terraform instance.

This changes allows for multiple log watches in a single S3 bucket, and allows for multiple modules to be used in the same project.

The config that I have working now looks like this

module "coralogix-cloudtrail-main" {
  source           = "github.com/<name>/terraform-coralogix-aws//modules/s3"
  coralogix_region = "US2"
  private_key      = data.aws_ssm_parameter.coralogix_api_key.value
  log_info         = {
    "cloudtrail-main" = {
      application_name = "everyonesocial-${var.environment}-cloudtrail"
      subsystem_name   = "cloudtrail-main"
      integration_type = "cloudtrail"
    }
  }
  s3_bucket_name = data.aws_ssm_parameter.cloudtrail.value
}

module "coralogix-cloudfront" {
  source           = "github.com/<name>/terraform-coralogix-aws//modules/s3"
  coralogix_region = "US2"
  private_key      = data.aws_ssm_parameter.coralogix_api_key.value
  s3_bucket_name   = data.aws_ssm_parameter.cflogs.value
  log_info = {
    "cloudfront-main" = {
      application_name = "everyonesocial-${var.environment}-cloudfront"
      subsystem_name   = "cloudfront-main"
      integration_type = "s3"
      s3_key_prefix    = "${data.aws_ssm_parameter.everyonesocial_domain.value}/"
    }
    "cloudfront-api" = {
      application_name = "everyonesocial-${var.environment}-cloudfront"
        subsystem_name   = "cloudfront-api"
        integration_type = "s3"
        s3_key_prefix    = "${data.aws_ssm_parameter.everyonesocial_api_domain.value}/"
    }
  }
}

How Has This Been Tested?

I am running this now, and running terraform again says 0 changes where before there were changes each time:
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Checklist:

  • I have updated the relevant example in the examples directory for the module.
  • I have updated the relevant test file for the module.
  • This change does not affect module (e.g. it's readme file change)

@badcure badcure requested a review from a team as a code owner September 5, 2023 18:55
@guyrenny
Copy link
Contributor

guyrenny commented Sep 7, 2023

Hey @badcure, thank you for the PR and for informing us of the problem. Because its a big change it will take some time and would like to implement it for our next sprint.
For now, i got 2 points:

  1. In case you update a module you also need to update the CHANGELOG file that is relevant to the module so that the change will be documented.
  2. Run terraform fmt for the files there is some misplaced indentions that i saw.

@badcure
Copy link
Author

badcure commented Sep 7, 2023

@guyrenny Done. for the S3 module, I made it a major version update since it seems like a breaking change.

That said, the goal is to allow multiple watches on the same bucket, and subsequent terraform runs be noop if there are no changes.

Let me know if you would like me to change anything else.

Copy link

🎉 This issue has been resolved in version 1.0.84 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants