What IAM permissions are needed to use CDK Deploy?

前端 未结 3 1139
余生分开走
余生分开走 2020-12-28 18:56

My team has a pipeline which runs under an execution IAM role. We want to deploy code to AWS through CloudFormation or the CDK.

In the past, we would upload some art

3条回答
  •  星月不相逢
    2020-12-28 19:15

    I'm using below policy to deploy CDK apps. Besides CFN full access and S3 full access to the CDK staging bucket, it grants permission to do everything through CloudFormation.

    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Action": [
                    "cloudformation:*"
                ],
                "Resource": "*",
                "Effect": "Allow"
            },
            {
                "Condition": {
                    "ForAnyValue:StringEquals": {
                        "aws:CalledVia": [
                            "cloudformation.amazonaws.com"
                        ]
                    }
                },
                "Action": "*",
                "Resource": "*",
                "Effect": "Allow"
            },
            {
                "Action": "s3:*",
                "Resource": "arn:aws:s3:::cdktoolkit-stagingbucket-*",
                "Effect": "Allow"
            }
        ]
    }
    

    You might want to add some explicit denies for things you don't want to allow.

    Also, be aware that above condition does not mean the principal is limited to things possible with CloudFormation. A potential attack vector would be to create a custom CFN resource, backed by a Lambda function. When creating resources through that custom resource you then could do anything in the Lambda, because it is triggered via CloudFormation.

提交回复
热议问题