Skip to content

Commit 1eebf92

Browse files
skinny85mergify[bot]
authored andcommitted
feat(codepipeline): support cross-environment deployments for all actions (#4276)
Previously, we only supported cross-environment deployments for CodeBuild and CloudFormation CodePipeline actions. This change adds this capability to all remaining AWS-owned actions. Fixes #3389
1 parent af79102 commit 1eebf92

24 files changed

+240
-54
lines changed

packages/@aws-cdk/aws-autoscaling/lib/auto-scaling-group.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import elbv2 = require('@aws-cdk/aws-elasticloadbalancingv2');
55
import iam = require('@aws-cdk/aws-iam');
66
import sns = require('@aws-cdk/aws-sns');
77

8-
import { CfnAutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, Resource, Stack, Tag, Token, withResolved } from '@aws-cdk/core';
8+
import {
9+
CfnAutoScalingRollingUpdate, Construct, Duration, Fn, IResource, Lazy, PhysicalName, Resource, Stack,
10+
Tag, Token, withResolved
11+
} from '@aws-cdk/core';
912
import { CfnAutoScalingGroup, CfnAutoScalingGroupProps, CfnLaunchConfiguration } from './autoscaling.generated';
1013
import { BasicLifecycleHookProps, LifecycleHook } from './lifecycle-hook';
1114
import { BasicScheduledActionProps, ScheduledAction } from './scheduled-action';
@@ -414,6 +417,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
414417
this.node.applyAspect(new Tag(NAME_TAG, this.node.path));
415418

416419
this.role = props.role || new iam.Role(this, 'InstanceRole', {
420+
roleName: PhysicalName.GENERATE_IF_NEEDED,
417421
assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com')
418422
});
419423

@@ -1091,4 +1095,4 @@ function stringifyNumber(x: number) {
10911095
} else {
10921096
return `${x}`;
10931097
}
1094-
}
1098+
}

packages/@aws-cdk/aws-codepipeline-actions/lib/codecommit/source-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class CodeCommitSourceAction extends Action {
6868

6969
super({
7070
...props,
71+
resource: props.repository,
7172
category: codepipeline.ActionCategory.SOURCE,
7273
provider: 'CodeCommit',
7374
artifactBounds: sourceArtifactBounds(),

packages/@aws-cdk/aws-codepipeline-actions/lib/codedeploy/server-deploy-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class CodeDeployServerDeployAction extends Action {
2626
constructor(props: CodeDeployServerDeployActionProps) {
2727
super({
2828
...props,
29+
resource: props.deploymentGroup,
2930
category: codepipeline.ActionCategory.DEPLOY,
3031
provider: 'CodeDeploy',
3132
artifactBounds: deployArtifactBounds(),

packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class EcrSourceAction extends Action {
4141
constructor(props: EcrSourceActionProps) {
4242
super({
4343
...props,
44+
resource: props.repository,
4445
category: codepipeline.ActionCategory.SOURCE,
4546
provider: 'ECR',
4647
artifactBounds: sourceArtifactBounds(),

packages/@aws-cdk/aws-codepipeline-actions/lib/lambda/invoke-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class LambdaInvokeAction extends Action {
6060
constructor(props: LambdaInvokeActionProps) {
6161
super({
6262
...props,
63+
resource: props.lambda,
6364
category: codepipeline.ActionCategory.INVOKE,
6465
provider: 'Lambda',
6566
artifactBounds: {

packages/@aws-cdk/aws-codepipeline-actions/lib/s3/deploy-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class S3DeployAction extends Action {
4040
constructor(props: S3DeployActionProps) {
4141
super({
4242
...props,
43+
resource: props.bucket,
4344
category: codepipeline.ActionCategory.DEPLOY,
4445
provider: 'S3',
4546
artifactBounds: deployArtifactBounds(),

packages/@aws-cdk/aws-codepipeline-actions/lib/s3/source-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export class S3SourceAction extends Action {
7474
constructor(props: S3SourceActionProps) {
7575
super({
7676
...props,
77+
resource: props.bucket,
7778
category: codepipeline.ActionCategory.SOURCE,
7879
provider: 'S3',
7980
artifactBounds: sourceArtifactBounds(),

packages/@aws-cdk/aws-codepipeline-actions/test/integ.cfn-template-from-repo.lit.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@
393393
"ArtifactStore": {
394394
"EncryptionKey": {
395395
"Id": {
396-
"Ref": "PipelineArtifactsBucketEncryptionKey01D58D69"
396+
"Fn::GetAtt": [
397+
"PipelineArtifactsBucketEncryptionKey01D58D69",
398+
"Arn"
399+
]
397400
},
398401
"Type": "KMS"
399402
},

packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-deployed-through-codepipeline.lit.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,10 @@
518518
"ArtifactStore": {
519519
"EncryptionKey": {
520520
"Id": {
521-
"Ref": "PipelineArtifactsBucketEncryptionKey01D58D69"
521+
"Fn::GetAtt": [
522+
"PipelineArtifactsBucketEncryptionKey01D58D69",
523+
"Arn"
524+
]
522525
},
523526
"Type": "KMS"
524527
},

packages/@aws-cdk/aws-codepipeline-actions/test/integ.lambda-pipeline.expected.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@
296296
"ArtifactStore": {
297297
"EncryptionKey": {
298298
"Id": {
299-
"Ref": "PipelineArtifactsBucketEncryptionKey01D58D69"
299+
"Fn::GetAtt": [
300+
"PipelineArtifactsBucketEncryptionKey01D58D69",
301+
"Arn"
302+
]
300303
},
301304
"Type": "KMS"
302305
},

0 commit comments

Comments
 (0)