-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix(AWLS2-441): ensure S3 bucket exists before VPC flow log creation #150
Conversation
main.tf
Outdated
@@ -911,7 +911,7 @@ resource "aws_flow_log" "agentless_scan_vpc_flow_log" { | |||
|
|||
# Send logs to manged S3 bucket. | |||
log_destination_type = "s3" | |||
log_destination = "arn:aws:s3:::${local.prefix}-bucket-${local.suffix}/sidekick/flow-logs/" | |||
log_destination = aws_s3_bucket.agentless_scan_bucket[0].arn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably still want to publish this to the sidekick/flow-logs
path within the bucket for organization purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch dude — addressed in a7af82d
Adds depends_on to ensure S3 bucket is fully provisioned before flow log creation, addressing an intermittent "Access Denied" error. The direct resource reference alone wasn't sufficient to guarantee proper ordering.
- Add s3_bucket_arn to global module outputs - Add s3_bucket_arn field to global_module_reference variable type - Use global_module_reference.s3_bucket_arn for flow log destination
Signed-off-by: Lei Jin <[email protected]>
…k/terraform-aws-agentless-scanning into fix/AWLS2-441/flow-logs-creation Signed-off-by: Lei Jin <[email protected]>
Signed-off-by: Lei Jin <[email protected]>
581c807
to
614397f
Compare
main.tf
Outdated
@@ -911,7 +911,8 @@ resource "aws_flow_log" "agentless_scan_vpc_flow_log" { | |||
|
|||
# Send logs to manged S3 bucket. | |||
log_destination_type = "s3" | |||
log_destination = "arn:aws:s3:::${local.prefix}-bucket-${local.suffix}/sidekick/flow-logs/" | |||
log_destination = "${aws_s3_bucket.agentless_scan_bucket[0].arn}/sidekick/flow-logs/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work since VPC flow log is a regional resources and aws_s3_bucket.agentless_scan_bucket[0].arn
only exists when global = true
Summary
Updates
log_destination
parameter in thevpc_flow_logs
resource to directly reference our S3 bucket resource, ensuring Terraform creates resources in the correct order.This fixes an intermittent "Access Denied" error that occurs when terraform tries to create the flow logs resource before the S3 bucket is fully provisioned.
Please refer to the linked Jira ticket for more details.
How did you test this change?
[WIP] Retried deployment a few times and stopped seeing intermittent failure due to permission error when creating the flow logs resource.
Issue
AWLS2-441