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

Fixing checkov errors - adding arn for sns #263

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ No modules.
| [aws_iam_policy_document.bucket_policy_v2](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.replication](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_sns_topic.bucket-arn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/sns_topic) | data source |

## Inputs

Expand Down
12 changes: 11 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
data "aws_caller_identity" "current" {}

data "aws_sns_topic" "bucket-arn" {
name = "bucket-arn"
}


# Main S3 bucket, that is replicated from (rather than to)
# KMS Encryption handled by aws_s3_bucket_server_side_encryption_configuration resource
# Logging handled by aws_s3_bucket_logging resource
Expand All @@ -10,10 +15,12 @@ resource "aws_s3_bucket" "default" {
#checkov:skip=CKV_AWS_18: "Logging handled in logging configuration resource"
#checkov:skip=CKV_AWS_21: "Versioning handled in Versioning configuration resource"
#checkov:skip=CKV_AWS_145: "Encryption handled in encryption configuration resource"


bucket = var.bucket_name
bucket_prefix = var.bucket_prefix
force_destroy = var.force_destroy
bucket_arn = aws_sns_topic.bucket_arn.arn

tags = var.tags
}
Expand All @@ -37,6 +44,7 @@ resource "aws_s3_bucket_acl" "default" {

# Configure bucket lifecycle rules
resource "aws_s3_bucket_lifecycle_configuration" "default" {
#checkov:skip=CKV_AWS_300: "Ensure S3 lifecycle configuration sets period for aborting failed uploads"
bucket = aws_s3_bucket.default.id

dynamic "rule" {
Expand Down Expand Up @@ -93,9 +101,10 @@ resource "aws_s3_bucket_lifecycle_configuration" "default" {
storage_class = noncurrent_version_transition.value.storage_class
}
}
}
}
}
}


# Configure bucket access logging
resource "aws_s3_bucket_logging" "default" {
Expand Down Expand Up @@ -239,6 +248,7 @@ resource "aws_s3_bucket" "replication" {
bucket = (var.bucket_name != null) ? "${var.bucket_name}-replication" : null
bucket_prefix = (var.bucket_prefix != null) ? "${var.bucket_prefix}-replication" : null
force_destroy = var.force_destroy
bucket_arn = aws_sns_topic.bucket_arn.arn
tags = var.tags
}

Expand Down