@@ -104,6 +104,60 @@ data "aws_iam_policy_document" "rules_s3_bucket_policy" {
104104 }
105105}
106106
107+ # Policy doc for S3 Consumer Mappings bucket
108+ data "aws_iam_policy_document" "s3_consumer_mapping_bucket_policy" {
109+ statement {
110+ sid = " AllowSSLRequestsOnly"
111+ actions = [
112+ " s3:GetObject" ,
113+ " s3:ListBucket" ,
114+ ]
115+ resources = [
116+ module . s3_consumer_mappings_bucket . storage_bucket_arn ,
117+ " ${ module . s3_consumer_mappings_bucket . storage_bucket_arn } /*" ,
118+ ]
119+ condition {
120+ test = " Bool"
121+ values = [" true" ]
122+ variable = " aws:SecureTransport"
123+ }
124+ }
125+ }
126+
127+ # ensure only secure transport is allowed
128+
129+ resource "aws_s3_bucket_policy" "consumer_mapping_s3_bucket" {
130+ bucket = module. s3_consumer_mappings_bucket . storage_bucket_id
131+ policy = data. aws_iam_policy_document . s3_consumer_mapping_bucket_policy . json
132+ }
133+
134+ data "aws_iam_policy_document" "consumer_mapping_s3_bucket_policy" {
135+ statement {
136+ sid = " AllowSslRequestsOnly"
137+ actions = [
138+ " s3:*" ,
139+ ]
140+ effect = " Deny"
141+ resources = [
142+ module . s3_consumer_mappings_bucket . storage_bucket_arn ,
143+ " ${ module . s3_consumer_mappings_bucket . storage_bucket_arn } /*" ,
144+ ]
145+ principals {
146+ type = " *"
147+ identifiers = [" *" ]
148+ }
149+ condition {
150+ test = " Bool"
151+ values = [
152+ " false" ,
153+ ]
154+
155+ variable = " aws:SecureTransport"
156+ }
157+ }
158+ }
159+
160+ # audit bucket
107161resource "aws_s3_bucket_policy" "audit_s3_bucket" {
108162 bucket = module. s3_audit_bucket . storage_bucket_id
109163 policy = data. aws_iam_policy_document . audit_s3_bucket_policy . json
@@ -136,12 +190,18 @@ data "aws_iam_policy_document" "audit_s3_bucket_policy" {
136190}
137191
138192# Attach s3 read policy to Lambda role
139- resource "aws_iam_role_policy" "lambda_s3_read_policy " {
140- name = " S3ReadAccess "
193+ resource "aws_iam_role_policy" "lambda_s3_rules_read_policy " {
194+ name = " S3RulesReadAccess "
141195 role = aws_iam_role. eligibility_lambda_role . id
142196 policy = data. aws_iam_policy_document . s3_rules_bucket_policy . json
143197}
144198
199+ resource "aws_iam_role_policy" "lambda_s3_mapping_read_policy" {
200+ name = " S3ConsumerMappingReadAccess"
201+ role = aws_iam_role. eligibility_lambda_role . id
202+ policy = data. aws_iam_policy_document . s3_consumer_mapping_bucket_policy . json
203+ }
204+
145205# Attach s3 write policy to kinesis firehose role
146206resource "aws_iam_role_policy" "kinesis_firehose_s3_write_policy" {
147207 name = " S3WriteAccess"
0 commit comments