aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

cli: document the necessary permissions needed for a successful deployment with assets

Open iliapolo opened this issue 6 years ago • 3 comments

When running cdk deploy with as assumed role, one must configure the exact permissions this role should have. We should document exactly which policies should these role have. For example:

  • s3:GetBucketLocation
  • s3:PutObject*
  • ...

These are probably just the permissions described here:

https://github.com/aws/aws-cdk/blob/ddd29b485d5e07c0661ce135460b34d9f2b712e9/packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml#L289-L313

But we should bubble these up to some documentation source.


This is a 📕 documentation issue

iliapolo avatar Aug 20 '20 11:08 iliapolo

I believe cloudformation:GetTemplate might also be needed, or at least I received errors to that effect.

birtles avatar Feb 04 '21 07:02 birtles

"s3:PutObject", "s3:GetObject", "s3:ListBucket", "s3:GetBucketLocation" these are required permissions. it should be given to user who will assume the role . even if you give s3:* to role it will not work but if you give these above to the IAM user that is assuming the role, cdk will work

yogeshdass avatar Mar 22 '21 15:03 yogeshdass

This policy works for our CDK deployment, just put your own account ID in the iam:PassRole resource:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:GetBucketLocation",
                "s3:PutObject",
                "s3:DeleteObject"
                ],
            "Resource": "arn:aws:s3:::cdk*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
                ],
            "Resource": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/cdk-*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudformation:GetTemplate",
                "cloudformation:CreateChangeSet",
                "cloudformation:DeleteChangeSet",
                "cloudformation:DescribeChangeSet",
                "cloudformation:DescribeStacks",
                "cloudformation:ExecuteChangeSet"
                ],
            "Resource": "arn:aws:cloudformation:*"
        }
    ]
}

er0k avatar Feb 10 '23 00:02 er0k