Skip to content

Commit 5a31d62

Browse files
committed
fix: allow iams for code deploy
1 parent 201b34c commit 5a31d62

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

infra/modules/aws/lambda/data.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ data "aws_iam_policy_document" "codedeploy_lambda" {
4444
]
4545
}
4646

47+
statement {
48+
sid = "ReadArtifactObject"
49+
effect = "Allow"
50+
actions = ["s3:GetObject", "s3:GetObjectVersion"]
51+
resources = [
52+
"arn:aws:s3:::${data.aws_s3_bucket.lambda_code.bucket}/${local.lambda_code_zip_key}",
53+
"arn:aws:s3:::${data.aws_s3_bucket.lambda_code.bucket}/${var.lambda_version}/*"
54+
]
55+
}
56+
57+
# Allow listing the bucket for that prefix (some SDKs call this)
58+
statement {
59+
sid = "ListArtifactPrefix"
60+
effect = "Allow"
61+
actions = ["s3:ListBucket", "s3:GetBucketLocation"]
62+
resources = ["arn:aws:s3:::${data.aws_s3_bucket.lambda_code.bucket}"]
63+
condition {
64+
test = "StringLike"
65+
variable = "s3:prefix"
66+
values = ["${var.lambda_version}/*"]
67+
}
68+
}
69+
4770
statement {
4871
sid = "DescribeAlarms"
4972
effect = "Allow"

infra/modules/aws/lambda/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ resource "aws_iam_role_policy" "cd_lambda" {
5858
}
5959

6060
resource "aws_codedeploy_deployment_group" "dg" {
61-
app_name = aws_codedeploy_app.app.name
62-
deployment_group_name = "${local.lambda_name}-dg"
63-
service_role_arn = aws_iam_role.code_deploy_role.arn
61+
app_name = aws_codedeploy_app.app.name
62+
deployment_group_name = "${local.lambda_name}-dg"
63+
service_role_arn = aws_iam_role.code_deploy_role.arn
6464

6565
deployment_style {
6666
deployment_type = "BLUE_GREEN"

0 commit comments

Comments
 (0)