Skip to content

Commit

Permalink
chore(codepipeline-actions): integ tests should be env agnostic (aws#…
Browse files Browse the repository at this point in the history
…19682)

Updated the stacksets integration test to be environment agnostic. This
allows us to deploy the integration test to different regions/accounts
without the template changing

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [x] Did you use `cdk-integ` to deploy the infrastructure and generate the snapshot (i.e. `cdk-integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored and Stephen Potter committed Apr 27, 2022
1 parent ec7facb commit dbe14ba
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,177 @@
"Resources": {
"ArtifactBucket7410C9EF": {
"Type": "AWS::S3::Bucket",
"Properties": {
"Tags": [
{
"Key": "aws-cdk:auto-delete-objects",
"Value": "true"
}
]
},
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"ArtifactBucketPolicy4B4B7752": {
"Type": "AWS::S3::BucketPolicy",
"Properties": {
"Bucket": {
"Ref": "ArtifactBucket7410C9EF"
},
"PolicyDocument": {
"Statement": [
{
"Action": [
"s3:DeleteObject*",
"s3:GetBucket*",
"s3:List*"
],
"Effect": "Allow",
"Principal": {
"AWS": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
"Arn"
]
}
},
"Resource": [
{
"Fn::GetAtt": [
"ArtifactBucket7410C9EF",
"Arn"
]
},
{
"Fn::Join": [
"",
[
{
"Fn::GetAtt": [
"ArtifactBucket7410C9EF",
"Arn"
]
},
"/*"
]
]
}
]
}
],
"Version": "2012-10-17"
}
}
},
"ArtifactBucketAutoDeleteObjectsCustomResource0BB47FD6": {
"Type": "Custom::S3AutoDeleteObjects",
"Properties": {
"ServiceToken": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F",
"Arn"
]
},
"BucketName": {
"Ref": "ArtifactBucket7410C9EF"
}
},
"DependsOn": [
"ArtifactBucketPolicy4B4B7752"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
},
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
]
},
"ManagedPolicyArns": [
{
"Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
}
]
}
},
"CustomS3AutoDeleteObjectsCustomResourceProviderHandler9D90184F": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232"
},
"S3Key": {
"Fn::Join": [
"",
[
{
"Fn::Select": [
0,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE"
}
]
}
]
},
{
"Fn::Select": [
1,
{
"Fn::Split": [
"||",
{
"Ref": "AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE"
}
]
}
]
}
]
]
}
},
"Timeout": 900,
"MemorySize": 128,
"Handler": "__entrypoint__.handler",
"Role": {
"Fn::GetAtt": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092",
"Arn"
]
},
"Runtime": "nodejs12.x",
"Description": {
"Fn::Join": [
"",
[
"Lambda function for auto-deleting objects in ",
{
"Ref": "ArtifactBucket7410C9EF"
},
" S3 bucket."
]
]
}
},
"DependsOn": [
"CustomS3AutoDeleteObjectsCustomResourceProviderRole3B1BD092"
]
},
"PipelineRoleD68726F7": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -263,7 +431,11 @@
{
"Ref": "AWS::Partition"
},
":iam::12345678:root"
":iam::",
{
"Ref": "AWS::AccountId"
},
":root"
]
]
}
Expand Down Expand Up @@ -408,7 +580,11 @@
{
"Ref": "AWS::Partition"
},
":iam::12345678:root"
":iam::",
{
"Ref": "AWS::AccountId"
},
":root"
]
]
}
Expand Down Expand Up @@ -442,7 +618,15 @@
{
"Ref": "AWS::Partition"
},
":cloudformation:test-region:12345678:stackset/TestStackSet:*"
":cloudformation:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":stackset/TestStackSet:*"
]
]
}
Expand Down Expand Up @@ -584,7 +768,11 @@
{
"Ref": "AWS::Partition"
},
":iam::12345678:root"
":iam::",
{
"Ref": "AWS::AccountId"
},
":root"
]
]
}
Expand Down Expand Up @@ -618,7 +806,15 @@
{
"Ref": "AWS::Partition"
},
":cloudformation:test-region:12345678:stackset/TestStackSet:*"
":cloudformation:",
{
"Ref": "AWS::Region"
},
":",
{
"Ref": "AWS::AccountId"
},
":stackset/TestStackSet:*"
]
]
}
Expand All @@ -636,6 +832,18 @@
}
},
"Parameters": {
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3Bucket09A62232": {
"Type": "String",
"Description": "S3 bucket for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
},
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824S3VersionKeyA28118BE": {
"Type": "String",
"Description": "S3 key for asset version \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
},
"AssetParametersbe270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824ArtifactHash76F8FCF2": {
"Type": "String",
"Description": "Artifact hash for asset \"be270bbdebe0851c887569796e3997437cca54ce86893ed94788500448e92824\""
},
"AssetParameters5bcf205623ea5b34a1944fea4c9982e835555e710235ae6f60172097737302e2S3Bucket3C8B9651": {
"Type": "String",
"Description": "S3 bucket for asset \"5bcf205623ea5b34a1944fea4c9982e835555e710235ae6f60172097737302e2\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import { Construct } from 'constructs';
import * as cpactions from '../../lib';

export class StackSetPipelineStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const pipeline = new codepipeline.Pipeline(this, 'Pipeline', {
artifactBucket: new s3.Bucket(this, 'ArtifactBucket', {
removalPolicy: RemovalPolicy.DESTROY,
autoDeleteObjects: true,
}),
});

Expand Down Expand Up @@ -75,9 +76,4 @@ export class StackSetPipelineStack extends Stack {
}

const app = new App();
new StackSetPipelineStack(app, 'StackSetPipelineStack', {
env: {
region: process.env.CDK_DEFAULT_REGION,
account: process.env.CDK_DEFAULT_ACCOUNT,
},
});
new StackSetPipelineStack(app, 'StackSetPipelineStack');

0 comments on commit dbe14ba

Please sign in to comment.