File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,10 +3,11 @@ resource "aws_kms_key" "fargate" {
33 deletion_window_in_days = var. key_recovery_period
44 enable_key_rotation = true
55 policy = jsonencode (yamldecode (templatefile (" ${ path . module } /templates/key-policy.yaml.tftpl" , {
6- account_id : data.aws_caller_identity.identity.account_id,
7- partition : data.aws_partition.current.partition,
8- region : data.aws_region.current.name,
9- repository_name : local.prefix,
6+ account_id : data.aws_caller_identity.identity.account_id
7+ ecs_roles : [aws_iam_role.execution.arn, aws_iam_role.task.arn]
8+ partition : data.aws_partition.current.partition
9+ region : data.aws_region.current.name
10+ repository_name : local.prefix
1011 })))
1112
1213 tags = var. tags
Original file line number Diff line number Diff line change 1- Version: ' 2012 - 10 - 17 '
1+ Version: " 2012-10-17"
22Id: Fargate hosting key policy
33Statement:
44- Sid: Enable IAM User Permissions
@@ -20,11 +20,14 @@ Statement:
2020 Condition:
2121 StringEquals:
2222 kms: CallerAccount: " ${ account_id } "
23- kms: EncryptionContext: aws: ecr: arn: arn: ${partition}: ecr: ${region}: ${account_id}: repository/ ${repository_name}
24- - Sid: Allow Fargate containers to encrypt objects
23+ kms: EncryptionContext: aws: ecr: arn: " arn:${ partition } :ecr:${ region } :${ account_id } :repository/${ repository_name } "
24+ - Sid: Allow ECS containers to encrypt objects
2525 Effect: Allow
2626 Resource: " *"
2727 Principal:
28- AWS: " *"
28+ AWS:
29+ % { for arn in ecs_roles ~}
30+ - " ${ arn } "
31+ % { endfor }
2932 Action:
3033 - kms: GenerateDataKey*
You can’t perform that action at this time.
0 commit comments