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

bug: resource "aws_s3_bucket_lifecycle_configuration" "log_bucket_lifecycle_config" shouldn't be created if bucket_logs_disabled is set to true #58

Open
megashby opened this issue Jan 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@megashby
Copy link

megashby commented Jan 9, 2024

Describe the bug
the creation of the s3 bucket lifecycle configuration for the access logs bucket does not take into consideration if the access logs bucket exists.

Steps to reproduce

Instantiate the module with the following configurations:

module "lacework_aws_eks_audit_log" {
  source  = "lacework/eks-audit-log/aws"
  version = "1.1.2"

  bucket_logs_disabled      = true
  bucket_versioning_enabled = false
  cloudwatch_regions        = ["us-east-1"]

}

run a terraform plan in the appropriate directory, and receive this error

╷
│ Error: Invalid index
│ 
│   on .terraform/modules/lacework_aws_eks_audit_log/main.tf line 324, in resource "aws_s3_bucket_lifecycle_configuration" "log_bucket_lifecycle_config":
│  324:   bucket = aws_s3_bucket.log_bucket[0].id
│     ├────────────────
│     │ aws_s3_bucket.log_bucket is empty tuple
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

Expected behavior
The project should plan correctly. Ideally this line: https://github.com/lacework/terraform-aws-eks-audit-log/blob/main/main.tf#L323 checks if bucket_logs_disabled is set to true before attempting to create the bucket lifecycle policy.

Screenshots
If applicable, add screenshots to help explain your problem.

Please complete the following information):

  • Terraform Version: Terraform v1.6.6
  • Module Version: 1.1.2

Run terraform version to find your Terraform version.
You can find the module version by running terraform providers or in your terraform configuration. If developing locally you can check the VERSION file in the project root directory.

Additional context
Add any other context about the problem here.

@megashby megashby added the bug Something isn't working label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant