-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(codepipeline): cross-environment (account+region) actions #3694
feat(codepipeline): cross-environment (account+region) actions #3694
Conversation
Pull Request Checklist
|
Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged. |
1 similar comment
Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged. |
Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged. |
Pull Request Checklist
|
c5ac2d8
to
65b7cd3
Compare
Updated the |
new kms.Alias(this, 'ArtifactsBucketEncryptionKeyAlias', { | ||
aliasName: this.generateNameForDefaultBucketKeyAlias(), | ||
targetKey: encryptionKey, | ||
removalPolicy: RemovalPolicy.RETAIN, // alias should be retained, like the key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that not mean that destroying and redeploying the stack will fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that was always true, even before adding the Alias
(because of the orphaned, physically-named S3 Bucket backing the Pipeline).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinging about this.
65b7cd3
to
2556de0
Compare
Added retention policy Retain to the scaffold Alias. |
Codebuild (Continuous Integration) build failed for current commits. Please check log and resolve before PR is merged. |
Pull Request Checklist
|
Pull Request Checklist
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the title talks about "simultaneous". You basically mean "support cross account and region actions"?
const replicationBucket = new s3.Bucket(replicationStack, 'ReplicationBucket', { | ||
// like was said above - replication buckets need a set physical name | ||
bucketName: PhysicalName.GENERATE_IF_NEEDED, | ||
encryptionKey: key, // does not work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what "does not work!" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll get a "Can only reference cross stacks in the same region and account." error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow up with @jerry-aws in a separate PR and revisit this doc. I think he will be able to help.
@@ -128,6 +133,53 @@ $ cdk deploy MyMainStack | |||
See [the AWS docs here](https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-create-cross-region.html) | |||
for more information on cross-region CodePipelines. | |||
|
|||
#### Creating an encrypted replication bucket | |||
|
|||
If you're passing a replication bucket created in a different stack, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation is weird. Should mostly describe how to do things and not what doesn't work...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wanted to point out a potential "gotcha!" that might trip people up.
If you have a suggestion how to re-structure this documentation, I'm all ears.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a walk through this code. I am really struggling to understand what's going on here (it's me!).
Any chance you can schedule some time next week?
// This is a problem if the stack the grantee is part of depends on the key stack | ||
// (as it won't exist before the key policy is attempted to be created). | ||
// In that case, make the account the resource policy principal | ||
const granteeStackDependsOnKeyStack = this.granteeStackDependsOnKeyStack(grantee); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have some doc reference (or appsec consultation) that this is the best practice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you suggest as an alternative here, given the comment?
@@ -160,7 +167,7 @@ export class Grant { | |||
const statement = new PolicyStatement({ | |||
actions: options.actions, | |||
resources: (options.resourceSelfArns || options.resourceArns), | |||
principals: [options.grantee!.grantPrincipal] | |||
principals: [options.resourcePolicyPrincipal || options.grantee!.grantPrincipal] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have separate tests in the IAM library for methods like addToPrincipalAndResource
- they're exercised only through tests in the particular Construct Libraries that use them. I'd rather not add them as part of this change. With the KMS test added above, this is now covered as well.
"Simultaneous" means "at the same time", because this PR deals specifically with actions that are both cross-region and cross-account at the same time. "Simultaneous" is just shorter. |
2556de0
to
e71e78c
Compare
Pull request has been modified.
Updated with feedback from comments & rebased. |
const replicationBucket = new s3.Bucket(replicationStack, 'ReplicationBucket', { | ||
// like was said above - replication buckets need a set physical name | ||
bucketName: PhysicalName.GENERATE_IF_NEEDED, | ||
encryptionKey: key, // does not work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow up with @jerry-aws in a separate PR and revisit this doc. I think he will be able to help.
Continuous integration build failed |
73df832
to
898cd8e
Compare
Fixed the |
Done: #4031 |
This changes the scaffolding stack logic for the cross-region CodePipelines to include a KMS key and alias as part of it, which are required if an action is simultaneously cross-region and cross-account. We also change to use the KMS key ID instead of the key ARN when rendering the ArtifactStores property.
We also add an alias to the default pipeline artifact bucket.
This required a bunch of changes to the KMS and S3 modules:
Fixes #52
Concerns #1584
Fixes #2517
Fixes #2569
Concerns #3275
Fixes #3138
Fixes #3388
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license