|
| 1 | +import { Template } from '@aws-cdk/assertions'; |
1 | 2 | import * as ccommit from '@aws-cdk/aws-codecommit';
|
2 | 3 | import * as sqs from '@aws-cdk/aws-sqs';
|
3 | 4 | import * as cdk from '@aws-cdk/core';
|
4 | 5 | import { Construct } from 'constructs';
|
5 | 6 | import * as cdkp from '../../lib';
|
6 |
| -import { PIPELINE_ENV, TestApp } from '../testhelpers'; |
| 7 | +import { PIPELINE_ENV, TestApp, ModernTestGitHubNpmPipeline } from '../testhelpers'; |
7 | 8 |
|
8 | 9 | let app: TestApp;
|
9 | 10 |
|
@@ -52,24 +53,48 @@ describe('CodePipeline support stack reuse', () => {
|
52 | 53 | const supportStackAArtifact = assembly.getStackByName(`PipelineStackA-support-${testStageEnv.region}`);
|
53 | 54 | const supportStackBArtifact = assembly.getStackByName(`PipelineStackB-support-${testStageEnv.region}`);
|
54 | 55 |
|
55 |
| - const supportStackATemplate = supportStackAArtifact.template; |
56 |
| - expect(supportStackATemplate).toHaveResourceLike('AWS::S3::Bucket', { |
| 56 | + const supportStackATemplate = Template.fromJSON(supportStackAArtifact.template); |
| 57 | + supportStackATemplate.hasResourceProperties('AWS::S3::Bucket', { |
57 | 58 | BucketName: 'pipelinestacka-support-useplicationbucket80db3753a0ebbf052279',
|
58 | 59 | });
|
59 |
| - expect(supportStackATemplate).toHaveResourceLike('AWS::KMS::Alias', { |
| 60 | + supportStackATemplate.hasResourceProperties('AWS::KMS::Alias', { |
60 | 61 | AliasName: 'alias/pport-ustencryptionalias5cad45754e1ff088476b',
|
61 | 62 | });
|
62 | 63 |
|
63 |
| - const supportStackBTemplate = supportStackBArtifact.template; |
64 |
| - expect(supportStackBTemplate).toHaveResourceLike('AWS::S3::Bucket', { |
| 64 | + const supportStackBTemplate = Template.fromJSON(supportStackBArtifact.template); |
| 65 | + supportStackBTemplate.hasResourceProperties('AWS::S3::Bucket', { |
65 | 66 | BucketName: 'pipelinestackb-support-useplicationbucket1d556ec7f959b336abf8',
|
66 | 67 | });
|
67 |
| - expect(supportStackBTemplate).toHaveResourceLike('AWS::KMS::Alias', { |
| 68 | + supportStackBTemplate.hasResourceProperties('AWS::KMS::Alias', { |
68 | 69 | AliasName: 'alias/pport-ustencryptionalias668c7ffd0de17c9867b0',
|
69 | 70 | });
|
70 | 71 | });
|
71 | 72 | });
|
72 | 73 |
|
| 74 | +test('CodeBuild action role has the right AssumeRolePolicyDocument', () => { |
| 75 | + const pipelineStack = new cdk.Stack(app, 'PipelineStack', { env: PIPELINE_ENV }); |
| 76 | + new ModernTestGitHubNpmPipeline(pipelineStack, 'Cdk'); |
| 77 | + |
| 78 | + const template = Template.fromStack(pipelineStack); |
| 79 | + template.hasResourceProperties('AWS::IAM::Role', { |
| 80 | + AssumeRolePolicyDocument: { |
| 81 | + Statement: [ |
| 82 | + { |
| 83 | + Action: 'sts:AssumeRole', |
| 84 | + Principal: { |
| 85 | + AWS: { 'Fn::Join': ['', ['arn:', { Ref: 'AWS::Partition' }, ':iam::123pipeline:root']] }, |
| 86 | + }, |
| 87 | + Condition: { |
| 88 | + Bool: { |
| 89 | + 'aws:ViaAWSService': 'codepipeline.amazonaws.com', |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + ], |
| 94 | + }, |
| 95 | + }); |
| 96 | +}); |
| 97 | + |
73 | 98 | interface ReuseCodePipelineStackProps extends cdk.StackProps {
|
74 | 99 | reuseCrossRegionSupportStacks?: boolean;
|
75 | 100 | }
|
|
0 commit comments