File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Create s3 Bucket with conditional destroy for pr environments
22resource "aws_s3_bucket" "data_quality_reports_bucket" {
3- bucket = " ${ local . short_prefix } -data-quality-reports"
3+ bucket = " imms- ${ local . resource_scope } -data-quality-reports"
44 force_destroy = local. is_temp
55
66}
@@ -41,19 +41,48 @@ resource "aws_s3_bucket_versioning" "dq_source_versioning" {
4141}
4242
4343
44- # If used should attached to lambda or any aws service that needs to perform any operation
44+ # If used should attach to lambda or any aws service that needs to perform any operation
4545resource "aws_iam_policy" "s3_dq_access" {
4646 policy = jsonencode ({
4747 Version = " 2012-10-17"
4848 Statement = [
4949 {
5050 Effect = " Allow"
51- Action = [" s3:GetObject " , " s3: PutObject" , " s3:ListBucket " ]
51+ Action = [" s3:PutObject" ]
5252 Resource = [
5353 aws_s3_bucket.data_quality_reports_bucket.arn,
5454 " ${ aws_s3_bucket . data_quality_reports_bucket . arn } /*"
5555 ]
5656 }
5757 ]
5858 })
59+ }
60+
61+
62+ resource "aws_s3_bucket_policy" "data_quality_bucket_policy" {
63+ bucket = aws_s3_bucket. data_quality_reports_bucket . id
64+
65+ policy = jsonencode ({
66+ Version = " 2012-10-17"
67+ Id = " data_quality_bucket_policy"
68+ Statement = [
69+ {
70+ Sid = " HTTPSOnly"
71+ Effect = " Deny"
72+ Principal = {
73+ AWS = " *"
74+ }
75+ Action = " s3:*"
76+ Resource = [
77+ aws_s3_bucket.data_quality_reports_bucket.arn,
78+ " ${ aws_s3_bucket . data_quality_reports_bucket . arn } /*"
79+ ]
80+ Condition = {
81+ Bool = {
82+ " aws:SecureTransport" = " false"
83+ }
84+ }
85+ },
86+ ]
87+ })
5988}
You can’t perform that action at this time.
0 commit comments