@@ -163,6 +163,8 @@ resource "aws_iam_policy" "s3_management" {
163163 " arn:aws:s3:::*eligibility-signposting-api-${ var . environment } -truststore/*" ,
164164 " arn:aws:s3:::*eligibility-signposting-api-${ var . environment } -truststore-access-logs" ,
165165 " arn:aws:s3:::*eligibility-signposting-api-${ var . environment } -truststore-access-logs/*" ,
166+ " arn:aws:s3:::*eligibility-signposting-api-${ var . environment } -eli-splunk-backup" ,
167+ " arn:aws:s3:::*eligibility-signposting-api-${ var . environment } -eli-splunk-backup/*"
166168 ]
167169 }
168170 ]
@@ -196,20 +198,62 @@ resource "aws_iam_policy" "api_infrastructure" {
196198 # ACM for certs
197199 " acm:DescribeCertificate" ,
198200 " acm:GetCertificate" ,
199- " acm:ListCertificates" ,
200- # S3 for mTLS truststore
201- " s3:GetObject" ,
202- # CloudWatch Logs for logging
203- " logs:CreateLogGroup" ,
204- " logs:CreateLogStream" ,
205- " logs:PutLogEvents" ,
206- # IAM PassRole for logging role association (if needed)
207- " iam:PassRole"
201+ " acm:ListCertificates"
208202
209203 ],
210204 Resource = " *"
211205 # checkov:skip=CKV_AWS_289: Actions require wildcard resource
212206 },
207+ {
208+ Effect = " Allow" ,
209+ Action = [
210+ # CloudWatch Logs creation and management
211+ " logs:CreateLogGroup" ,
212+ " logs:CreateLogStream" ,
213+ " logs:PutLogEvents"
214+ ],
215+ Resource = [
216+ # VPC Flow Logs
217+ " arn:aws:logs:${ var . default_aws_region } :${ data . aws_caller_identity . current . account_id } :log-group:/aws/vpc/*" ,
218+ # Lambda function logs
219+ " arn:aws:logs:${ var . default_aws_region } :${ data . aws_caller_identity . current . account_id } :log-group:/aws/lambda/*" ,
220+ # API Gateway logs
221+ " arn:aws:logs:${ var . default_aws_region } :${ data . aws_caller_identity . current . account_id } :log-group:/aws/apigateway/*" ,
222+ # Kinesis Firehose logs
223+ " arn:aws:logs:${ var . default_aws_region } :${ data . aws_caller_identity . current . account_id } :log-group:/aws/kinesisfirehose/*"
224+ ]
225+ },
226+ {
227+ Effect = " Allow" ,
228+ Action = [
229+ # IAM PassRole for specific service roles only
230+ " iam:PassRole"
231+ ],
232+ Resource = [
233+ # Lambda execution roles
234+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/eligibility_lambda-role*" ,
235+ # API Gateway CloudWatch logging role
236+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/*-api-gateway-*-role" ,
237+ # VPC Flow Logs role
238+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/vpc-flow-logs-role*" ,
239+ # EventBridge to Firehose role
240+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/eventbridge-firehose-role*" ,
241+ # Kinesis Firehose S3 backup roles
242+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/*firehose*role*" ,
243+ " arn:aws:iam::${ data . aws_caller_identity . current . account_id } :role/splunk-firehose-assume-role*"
244+ ],
245+ Condition = {
246+ StringEquals = {
247+ " iam:PassedToService" = [
248+ " lambda.amazonaws.com" ,
249+ " apigateway.amazonaws.com" ,
250+ " vpc-flow-logs.amazonaws.com" ,
251+ " events.amazonaws.com" ,
252+ " firehose.amazonaws.com"
253+ ]
254+ }
255+ }
256+ },
213257 {
214258 Effect = " Allow" ,
215259 Action = [
@@ -299,24 +343,22 @@ resource "aws_iam_policy" "kms_creation" {
299343 {
300344 Effect = " Allow" ,
301345 Action = [
346+ # Key creation and listing actions require wildcard resource
302347 " kms:CreateKey" ,
303- " kms:DescribeKey" ,
304348 " kms:CreateAlias" ,
305349 " kms:List*" ,
306- " kms:ListAliases" ,
307- " kms:Decrypt" ,
308- " kms:Encrypt" ,
309- " kms:ReEncrypt*" ,
350+ " kms:ListAliases"
310351 ],
311352 Resource = " *"
312353 },
313354 {
314355 Effect = " Allow" ,
315356 Action = [
357+ # Key management actions on account-specific keys only
358+ " kms:DescribeKey" ,
316359 " kms:Describe*" ,
317360 " kms:GetKeyPolicy*" ,
318361 " kms:GetKeyRotationStatus" ,
319- " kms:Decrypt*" ,
320362 " kms:DeleteAlias" ,
321363 " kms:UpdateKeyDescription" ,
322364 " kms:CreateGrant" ,
@@ -325,8 +367,9 @@ resource "aws_iam_policy" "kms_creation" {
325367 " kms:ScheduleKeyDeletion" ,
326368 " kms:PutKeyPolicy" ,
327369 " kms:Encrypt" ,
328- " kms:TagResource" ,
329- " kms:GenerateDataKey" ,
370+ " kms:Decrypt" ,
371+ " kms:ReEncrypt*" ,
372+ " kms:GenerateDataKey"
330373 ],
331374 Resource = [
332375 " arn:aws:kms:${ var . default_aws_region } :${ data . aws_caller_identity . current . account_id } :key/*" ,
0 commit comments