File tree Expand file tree Collapse file tree 2 files changed +54
-4
lines changed
terraform/account-wide-infrastructure
modules/permissions-store-bucket Expand file tree Collapse file tree 2 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ locals {
3030 destination_account_id = data. aws_secretsmanager_secret_version . destination_account_id . secret_string
3131}
3232
33- # First, we create an S3 bucket for compliance reports. You may already have a module for creating
34- # S3 buckets with more refined access rules, which you may prefer to use.
35-
33+ # First, we create an S3 bucket for compliance reports.
3634resource "aws_s3_bucket" "backup_reports" {
3735 bucket_prefix = " ${ local . project_name } -backup-reports"
3836}
@@ -55,7 +53,33 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "backup_reports" {
5553 }
5654 }
5755}
58- # Now we have to configure access to the report bucket.
56+
57+ resource "aws_s3_bucket_policy" "backup_reports_bucket_policy" {
58+ bucket = aws_s3_bucket. backup_reports . id
59+
60+ policy = jsonencode ({
61+ Version = " 2012-10-17"
62+ Id = " backup_reports_bucket_policy"
63+ Statement = [
64+ {
65+ Sid = " HTTPSOnly"
66+ Effect = " Deny"
67+ Principal = " *"
68+ Action = " s3:*"
69+ Resource = [
70+ aws_s3_bucket.backup_reports.arn,
71+ " ${ aws_s3_bucket . backup_reports . arn } /*" ,
72+ ]
73+ Condition = {
74+ Bool = {
75+ " aws:SecureTransport" = " false"
76+ }
77+ }
78+ },
79+ ]
80+ })
81+ }
82+
5983
6084resource "aws_s3_bucket_ownership_controls" "backup_reports" {
6185 bucket = aws_s3_bucket. backup_reports . id
Original file line number Diff line number Diff line change @@ -27,6 +27,32 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "authorization-sto
2727 }
2828}
2929
30+ resource "aws_s3_bucket_policy" "authorization_store_bucket_policy" {
31+ bucket = aws_s3_bucket. authorization-store . id
32+
33+ policy = jsonencode ({
34+ Version = " 2012-10-17"
35+ Id = " authorization_store_bucket_policy"
36+ Statement = [
37+ {
38+ Sid = " HTTPSOnly"
39+ Effect = " Deny"
40+ Principal = " *"
41+ Action = " s3:*"
42+ Resource = [
43+ aws_s3_bucket.authorization- store.arn,
44+ " ${ aws_s3_bucket . authorization-store . arn } /*" ,
45+ ]
46+ Condition = {
47+ Bool = {
48+ " aws:SecureTransport" = " false"
49+ }
50+ }
51+ },
52+ ]
53+ })
54+ }
55+
3056resource "aws_s3_bucket_versioning" "authorization-store" {
3157 bucket = aws_s3_bucket. authorization-store . id
3258 versioning_configuration {
You can’t perform that action at this time.
0 commit comments