Skip to content

Commit 209fffe

Browse files
committed
Adapt CopySnapshot policy to latest IAM changes
1 parent 274e8fb commit 209fffe

File tree

1 file changed

+17
-2
lines changed
  • modules/scanning-delegate-role

1 file changed

+17
-2
lines changed

modules/scanning-delegate-role/main.tf

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,29 @@ data "aws_iam_policy_document" "scanning_orchestrator_policy_document" {
7373
}
7474
}
7575

76+
// IAM makes a distinction between source and destination snapshot permissions
77+
// when using CopySnapshot. We need a policy statement for both of them.
78+
//
79+
// reference: https://aws.amazon.com/blogs/storage/enhancing-resource-level-permissions-for-copying-amazon-ebs-snapshots/
7680
statement {
77-
sid = "DatadogAgentlessScannerCopySnapshot"
81+
sid = "DatadogAgentlessScannerCopySnapshotSource"
7882
effect = "Allow"
7983
actions = [
8084
"ec2:CopySnapshot"
8185
]
8286
resources = [
83-
"arn:${data.aws_partition.current.partition}:ec2:*:*:snapshot/*",
87+
"arn:${data.aws_partition.current.partition}:ec2:*:*:snapshot/snap-*",
88+
]
89+
}
90+
91+
statement {
92+
sid = "DatadogAgentlessScannerCopySnapshotDestination"
93+
effect = "Allow"
94+
actions = [
95+
"ec2:CopySnapshot"
96+
]
97+
resources = [
98+
"arn:${data.aws_partition.current.partition}:ec2:*:*:snapshot/$${*}",
8499
]
85100
// Enforcing created snapshot has DatadogAgentlessScanner tag
86101
condition {

0 commit comments

Comments
 (0)