(cli): reduce deploy role scope
See original GitHub issueCurrently the deploy role has a lot of access to *:
I wonder if we can scope this down a bit by qualifier, so one bootstrap instance can’t access things from another? Maybe with tags or enforcing a naming scheme? E.g. all stacks must start with cdk-${qualifier}-
Use Case
We’re investigating bootstrapping for each service with different qualifiers to try and reduce the blast radius if access to the deployment role (and others) from one bootstrap instance is compromised. The other roles/policies look like they’re scoped pretty well. The FilePublishingRoleDefaultPolicy
for example can only be used with the StagingBucket.Arn
for that bootstrap instance.
I think we’ll need to create a custom deploy role which can only invoke specific CloudFormation stacks with a restricted execution policy (unless this could be an official feature of the bootstrap stack in the future), but was looking to use this as a template, and if this level of access is really needed, I think the isolation we want really isn’t going to be possible.
Thanks.
Proposed Solution
I’m not sure if we can actually scope the permissions down from *
. The comment
# Permissions needed in CodePipeline.
# S3 and KMS are needed on '*',
# as we don't know the IDs of the CodePipeline's bucket and key in advance
makes it sound like we can’t, but I’m really hoping that’s not the case.
- 👋 I may be able to implement this feature request (depending what the solution ends up being)
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:57 (54 by maintainers)
Top GitHub Comments
To pile on https://github.com/aws/aws-cdk/issues/12985#issuecomment-802793593, here are additional Pros for the proposed change:
cdk diff
orcdk deploy
is executed. Logging the security report would be a welcome improvement only possible with CDK tooling. Related to https://github.com/aws/aws-cdk-rfcs/issues/282Yep this seems to be the case. Opened a PR to get docs updated and hopefully confirmation of that.
This doesn’t work either. Get
so created another PR to document that and get confirmaton.
Spending so much time trying things that could have been avoided if the docs were clearer 😐
Back to one of my original questions:
I’m wondering what the gain really is of using the built-in actions (even for same account deploys) over having a single CodeBuild step with
cdk deploy
, that does everything? That action would just need to run as a role that can assume the deploy and file publish roles that are in the manifest (which would be updated in the UpdatePipeline stage if necessary).It would make the code simpler and remove the need for these * permission on the deploy role, given the template would be uploaded to the artifact bucket of account B (key point) if it needed to be.
Pros:
cdk deploy
output.Cons:
cdk deploy
output should already be clear.@rix0rrr thoughts? Have I missed some cons? Should this be an RFC?