@@ -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 . consumer_mapping_s3_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
@@ -137,11 +191,18 @@ data "aws_iam_policy_document" "audit_s3_bucket_policy" {
137191
138192# Attach s3 read policy to Lambda role
139193resource "aws_iam_role_policy" "lambda_s3_read_policy" {
194+ # for rules bucket
140195 name = " S3ReadAccess"
141196 role = aws_iam_role. eligibility_lambda_role . id
142197 policy = data. aws_iam_policy_document . s3_rules_bucket_policy . json
143198}
144199
200+ resource "aws_iam_role_policy" "lambda_s3_mapping_read_policy" {
201+ name = " S3ConsumerMappingReadAccess"
202+ role = aws_iam_role. eligibility_lambda_role . id
203+ policy = data. aws_iam_policy_document . s3_consumer_mapping_bucket_policy . json
204+ }
205+
145206# Attach s3 write policy to kinesis firehose role
146207resource "aws_iam_role_policy" "kinesis_firehose_s3_write_policy" {
147208 name = " S3WriteAccess"
@@ -290,6 +351,41 @@ resource "aws_kms_key_policy" "s3_rules_kms_key" {
290351 policy = data. aws_iam_policy_document . s3_rules_kms_key_policy . json
291352}
292353
354+ data "aws_iam_policy_document" "s3_consumer_mapping_kms_key_policy" {
355+ # checkov:skip=CKV_AWS_111: Root user needs full KMS key management
356+ # checkov:skip=CKV_AWS_356: Root user needs full KMS key management
357+ # checkov:skip=CKV_AWS_109: Root user needs full KMS key management
358+ statement {
359+ sid = " EnableIamUserPermissions"
360+ effect = " Allow"
361+ principals {
362+ type = " AWS"
363+ identifiers = [" arn:aws:iam::${ data . aws_caller_identity . current . account_id } :root" ]
364+ }
365+ actions = [" kms:*" ]
366+ resources = [" *" ]
367+ }
368+
369+ # checkov:skip=CKV_AWS_111: Permission boundary enforces restrictions for this policy
370+ # checkov:skip=CKV_AWS_356: Permission boundary enforces resource-level controls
371+ # checkov:skip=CKV_AWS_109: Permission boundary governs write-access constraints
372+ statement {
373+ sid = " AllowLambdaDecrypt"
374+ effect = " Allow"
375+ principals {
376+ type = " AWS"
377+ identifiers = [aws_iam_role . eligibility_lambda_role . arn ]
378+ }
379+ actions = [" kms:Decrypt" ]
380+ resources = [" *" ]
381+ }
382+ }
383+
384+ resource "aws_kms_key_policy" "s3_consumer_mapping_kms_key" {
385+ key_id = module. s3_consumer_mappings_bucket . storage_bucket_kms_key_id
386+ policy = data. aws_iam_policy_document . s3_consumer_mapping_kms_key_policy . json
387+ }
388+
293389resource "aws_iam_role_policy" "splunk_firehose_policy" {
294390 # checkov:skip=CKV_AWS_290: Firehose requires write access to dynamic log streams without static constraints
295391 # checkov:skip=CKV_AWS_355: Firehose logging requires wildcard resource for CloudWatch log groups/streams
0 commit comments