Skip to content

Commit 746b9e6

Browse files
authored
Merge branch 'main' into corymhall/apigateway/disable-cloudwatchrole
2 parents e6aa347 + 16c0c98 commit 746b9e6

248 files changed

Lines changed: 3799 additions & 3044 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as codepipeline from '@aws-cdk/aws-codepipeline';
22
import * as ecr from '@aws-cdk/aws-ecr';
3+
import { Rule } from '@aws-cdk/aws-events';
34
import * as targets from '@aws-cdk/aws-events-targets';
45
import * as iam from '@aws-cdk/aws-iam';
56
import { Names } from '@aws-cdk/core';
@@ -85,16 +86,27 @@ export class EcrSourceAction extends Action {
8586
};
8687
}
8788

88-
protected bound(_scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
89+
protected bound(scope: Construct, stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
8990
codepipeline.ActionConfig {
9091
options.role.addToPolicy(new iam.PolicyStatement({
9192
actions: ['ecr:DescribeImages'],
9293
resources: [this.props.repository.repositoryArn],
9394
}));
9495

95-
this.props.repository.onCloudTrailImagePushed(Names.nodeUniqueId(stage.pipeline.node) + 'SourceEventRule', {
96-
target: new targets.CodePipeline(stage.pipeline),
97-
imageTag: this.props.imageTag === '' ? undefined : (this.props.imageTag ?? 'latest'),
96+
new Rule(scope, Names.nodeUniqueId(stage.pipeline.node) + 'SourceEventRule', {
97+
targets: [
98+
new targets.CodePipeline(stage.pipeline),
99+
],
100+
eventPattern: {
101+
detailType: ['ECR Image Action'],
102+
source: ['aws.ecr'],
103+
detail: {
104+
'result': ['SUCCESS'],
105+
'repository-name': [this.props.repository.repositoryName],
106+
'image-tag': [this.props.imageTag === '' ? undefined : (this.props.imageTag ?? 'latest')],
107+
'action-type': ['PUSH'],
108+
},
109+
},
98110
});
99111

100112
// the Action Role also needs to write to the Pipeline's bucket

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ describe('ecr source action', () => {
6363
Template.fromStack(stack).hasResourceProperties('AWS::Events::Rule', {
6464
'EventPattern': {
6565
'detail': {
66-
'requestParameters': {
67-
'imageTag': ['latest'],
68-
},
66+
'result': ['SUCCESS'],
67+
'repository-name': ['repo'],
68+
'image-tag': ['latest'],
69+
'action-type': ['PUSH'],
6970
},
7071
},
7172
});
@@ -110,9 +111,10 @@ describe('ecr source action', () => {
110111
'aws.ecr',
111112
],
112113
'detail': {
113-
'requestParameters': {
114-
'imageTag': Match.absent(),
115-
},
114+
'result': ['SUCCESS'],
115+
'repository-name': ['repo'],
116+
'image-tag': [],
117+
'action-type': ['PUSH'],
116118
},
117119
},
118120
});

packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,28 @@ import * as codepipeline from '@aws-cdk/aws-codepipeline';
22
import * as ecr from '@aws-cdk/aws-ecr';
33
import * as s3 from '@aws-cdk/aws-s3';
44
import * as cdk from '@aws-cdk/core';
5+
import { IntegTest } from '@aws-cdk/integ-tests';
56
import * as cpactions from '../lib';
67

8+
/**
9+
* Manual validation steps
10+
*
11+
* Run test with `-vv` so that the outputs are printed and
12+
* `--no-clean` flag so that the stack is not deleted after the deployment is complete
13+
*
14+
* You should see output like:
15+
*
16+
* Outputs:
17+
* aws-cdk-codepipeline-ecr-source.PipelineConsoleLink = https://us-east-1.console.aws.amazon.com/codesuite/codepipeline/pipelines/aws-cdk-codepipeline-ecr-source-MyPipelineAED38ECF-1P0OYRLWF8FHY/view?region=us-east-1
18+
* aws-cdk-codepipeline-ecr-source.LoginCommand = aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 11111111111.dkr.ecr.us-east-1.amazonaws.com
19+
* aws-cdk-codepipeline-ecr-source.PushCommand = docker tag public.ecr.aws/lambda/provided 11111111111.dkr.ecr.us-east-1.amazonaws.com/aws-cdk-codepipeline-ecr-source-myecrrepo767466d0-gsrntpvfwc5w:latest \
20+
* && docker push 11111111111.dkr.ecr.us-east-1.amazonaws.com/aws-cdk-codepipeline-ecr-source-myecrrepo767466d0-gsrntpvfwc5w:latest
21+
*
22+
* Run the LoginCommand & PushCommand to tag and push an image to the ECR repository.
23+
* Then use the PipelineConsoleLink to navigate to the pipeline console page to validate that the pipeline
24+
* was triggered successfully.
25+
*/
26+
727
const app = new cdk.App();
828

929
const stack = new cdk.Stack(app, 'aws-cdk-codepipeline-ecr-source');
@@ -28,4 +48,18 @@ sourceStage.addAction(new cpactions.EcrSourceAction({
2848
const approveStage = pipeline.addStage({ stageName: 'Approve' });
2949
approveStage.addAction(new cpactions.ManualApprovalAction({ actionName: 'ManualApproval' }));
3050

31-
app.synth();
51+
new cdk.CfnOutput(stack, 'LoginCommand', {
52+
value: `aws ecr get-login-password --region ${stack.region} | docker login --username AWS --password-stdin ${stack.account}.dkr.ecr.${stack.region}.amazonaws.com`,
53+
});
54+
55+
new cdk.CfnOutput(stack, 'PushCommand', {
56+
value: `docker tag public.ecr.aws/lambda/provided ${repository.repositoryUriForTag('latest')} && docker push ${repository.repositoryUriForTag('latest')}`,
57+
});
58+
59+
new cdk.CfnOutput(stack, 'PipelineConsoleLink', {
60+
value: `https://${stack.region}.console.aws.amazon.com/codesuite/codepipeline/pipelines/${pipeline.pipelineName}/view?region=${stack.region}`,
61+
});
62+
63+
new IntegTest(app, 'ecr-source-action', {
64+
testCases: [stack],
65+
});

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-cfn-cross-region.integ.snapshot/aws-cdk-codepipeline-cloudformation-cross-region.assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "17.0.0",
2+
"version": "20.0.0",
33
"files": {
44
"64e4857ead2a6d40a579c8325f31ac188170c3658ab06c2020de84e581a6069d": {
55
"source": {

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-cfn-cross-region.integ.snapshot/aws-cdk-codepipeline-cloudformation-cross-region.template.json

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,7 @@
209209
"Fn::Join": [
210210
"",
211211
[
212-
"arn:",
213-
{
214-
"Ref": "AWS::Partition"
215-
},
216-
":iam::",
212+
"arn:aws:iam::",
217213
{
218214
"Ref": "AWS::AccountId"
219215
},
@@ -321,11 +317,7 @@
321317
"Fn::Join": [
322318
"",
323319
[
324-
"arn:",
325-
{
326-
"Ref": "AWS::Partition"
327-
},
328-
":iam::",
320+
"arn:aws:iam::",
329321
{
330322
"Ref": "AWS::AccountId"
331323
},
@@ -400,11 +392,7 @@
400392
"Fn::Join": [
401393
"",
402394
[
403-
"arn:",
404-
{
405-
"Ref": "AWS::Partition"
406-
},
407-
":cloudformation:us-west-2:",
395+
"arn:aws:cloudformation:us-west-2:",
408396
{
409397
"Ref": "AWS::AccountId"
410398
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"17.0.0"}
1+
{"version":"20.0.0"}

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-cfn-cross-region.integ.snapshot/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "17.0.0",
2+
"version": "20.0.0",
33
"artifacts": {
44
"Tree": {
55
"type": "cdk:tree",

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-cfn-cross-region.integ.snapshot/tree.json

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"path": "Tree",
1010
"constructInfo": {
1111
"fqn": "constructs.Construct",
12-
"version": "10.0.9"
12+
"version": "10.1.65"
1313
}
1414
},
1515
"aws-cdk-codepipeline-cloudformation-cross-region": {
@@ -300,11 +300,7 @@
300300
"Fn::Join": [
301301
"",
302302
[
303-
"arn:",
304-
{
305-
"Ref": "AWS::Partition"
306-
},
307-
":iam::",
303+
"arn:aws:iam::",
308304
{
309305
"Ref": "AWS::AccountId"
310306
},
@@ -431,13 +427,13 @@
431427
},
432428
"constructInfo": {
433429
"fqn": "constructs.Construct",
434-
"version": "10.0.9"
430+
"version": "10.1.65"
435431
}
436432
}
437433
},
438434
"constructInfo": {
439435
"fqn": "constructs.Construct",
440-
"version": "10.0.9"
436+
"version": "10.1.65"
441437
}
442438
},
443439
"CFN": {
@@ -468,11 +464,7 @@
468464
"Fn::Join": [
469465
"",
470466
[
471-
"arn:",
472-
{
473-
"Ref": "AWS::Partition"
474-
},
475-
":iam::",
467+
"arn:aws:iam::",
476468
{
477469
"Ref": "AWS::AccountId"
478470
},
@@ -497,7 +489,7 @@
497489
"path": "aws-cdk-codepipeline-cloudformation-cross-region/MyPipeline/CFN/CFN_Deploy/CodePipelineActionRole/8389e75f-0810-4838-bf64-d6f85a95cf83",
498490
"constructInfo": {
499491
"fqn": "constructs.Construct",
500-
"version": "10.0.9"
492+
"version": "10.1.65"
501493
}
502494
},
503495
"DefaultPolicy": {
@@ -567,11 +559,7 @@
567559
"Fn::Join": [
568560
"",
569561
[
570-
"arn:",
571-
{
572-
"Ref": "AWS::Partition"
573-
},
574-
":cloudformation:us-west-2:",
562+
"arn:aws:cloudformation:us-west-2:",
575563
{
576564
"Ref": "AWS::AccountId"
577565
},
@@ -710,13 +698,13 @@
710698
},
711699
"constructInfo": {
712700
"fqn": "constructs.Construct",
713-
"version": "10.0.9"
701+
"version": "10.1.65"
714702
}
715703
}
716704
},
717705
"constructInfo": {
718706
"fqn": "constructs.Construct",
719-
"version": "10.0.9"
707+
"version": "10.1.65"
720708
}
721709
}
722710
},

packages/@aws-cdk/aws-codepipeline-actions/test/pipeline-ecr-source.integ.snapshot/aws-cdk-codepipeline-ecr-source.assets.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)