From 99698c3b6dfbc1fc8c10e69963151d06cba651cc Mon Sep 17 00:00:00 2001 From: Steve Houel Date: Thu, 3 Nov 2022 17:14:59 +0100 Subject: [PATCH] Upgrading integration test to integ-tests --- packages/@aws-cdk/aws-gamelift/lib/build.ts | 3 + packages/@aws-cdk/aws-gamelift/lib/content.ts | 23 +- packages/@aws-cdk/aws-gamelift/package.json | 1 + .../@aws-cdk/aws-gamelift/test/build.test.ts | 41 ++-- .../aws-gamelift/test/content.test.ts | 122 +++++----- ...efaultTestDeployAssert0688841C.assets.json | 19 ++ ...aultTestDeployAssert0688841C.template.json | 36 +++ .../aws-gamelift-build.assets.json | 4 +- .../aws-gamelift-build.template.json | 212 ++++++++---------- .../test/integ.build.js.snapshot/integ.json | 10 +- .../integ.build.js.snapshot/manifest.json | 61 ++++- .../test/integ.build.js.snapshot/tree.json | 132 ++++++----- .../@aws-cdk/aws-gamelift/test/integ.build.ts | 19 +- ...efaultTestDeployAssert5DF38444.assets.json | 19 ++ ...aultTestDeployAssert5DF38444.template.json | 36 +++ .../aws-gamelift-script.assets.json | 4 +- .../aws-gamelift-script.template.json | 210 ++++++++--------- .../test/integ.script.js.snapshot/integ.json | 10 +- .../integ.script.js.snapshot/manifest.json | 61 ++++- .../test/integ.script.js.snapshot/tree.json | 132 ++++++----- .../aws-gamelift/test/integ.script.ts | 19 +- .../@aws-cdk/aws-gamelift/test/script.test.ts | 41 ++-- 22 files changed, 730 insertions(+), 485 deletions(-) create mode 100644 packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.assets.json create mode 100644 packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.template.json create mode 100644 packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.assets.json create mode 100644 packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.template.json diff --git a/packages/@aws-cdk/aws-gamelift/lib/build.ts b/packages/@aws-cdk/aws-gamelift/lib/build.ts index a2d4422e47453..346ca94618d6d 100644 --- a/packages/@aws-cdk/aws-gamelift/lib/build.ts +++ b/packages/@aws-cdk/aws-gamelift/lib/build.ts @@ -188,6 +188,7 @@ export class Build extends BuildBase { throw new Error(`Build name can not be longer than 1024 characters but has ${props.buildName.length} characters.`); } } + this.role = props.role ?? new iam.Role(this, 'ServiceRole', { assumedBy: new iam.ServicePrincipal('gamelift.amazonaws.com'), }); @@ -206,6 +207,8 @@ export class Build extends BuildBase { }, }); + resource.node.addDependency(this.role); + this.buildId = resource.ref; } diff --git a/packages/@aws-cdk/aws-gamelift/lib/content.ts b/packages/@aws-cdk/aws-gamelift/lib/content.ts index 3c510757b3880..387535c439160 100644 --- a/packages/@aws-cdk/aws-gamelift/lib/content.ts +++ b/packages/@aws-cdk/aws-gamelift/lib/content.ts @@ -32,7 +32,7 @@ export abstract class Content { /** * Called when the Build is initialized to allow this object to bind */ - public abstract bind(scope: Construct, grantable: iam.IGrantable): ContentConfig; + public abstract bind(scope: Construct, role: iam.IRole): ContentConfig; } @@ -58,8 +58,14 @@ export class S3Content extends Content { } } - public bind(_scope: Construct, grantable: iam.IGrantable): ContentConfig { - this.bucket.grantRead(grantable, this.key); + public bind(_scope: Construct, role: iam.IRole): ContentConfig { + // Adding permission to access specific content + role.addToPrincipalPolicy(new iam.PolicyStatement({ + effect: iam.Effect.ALLOW, + resources: [this.bucket.arnForObjects(this.key)], + actions: ['s3:GetObject', 's3:GetObjectVersion'], + })); + return { s3Location: { bucketName: this.bucket.bucketName, @@ -83,7 +89,7 @@ export class AssetContent extends Content { super(); } - public bind(scope: Construct, grantable: iam.IGrantable): ContentConfig { + public bind(scope: Construct, role: iam.IRole): ContentConfig { // If the same AssetContent is used multiple times, retain only the first instantiation. if (!this.asset) { this.asset = new s3_assets.Asset(scope, 'Content', { @@ -94,7 +100,14 @@ export class AssetContent extends Content { throw new Error(`Asset is already associated with another stack '${cdk.Stack.of(this.asset).stackName}'. ` + 'Create a new Content instance for every stack.'); } - this.asset.grantRead(grantable); + const bucket = s3.Bucket.fromBucketName(scope, 'AssetBucket', this.asset.s3BucketName); + + // Adding permission to access specific content + role.addToPrincipalPolicy(new iam.PolicyStatement({ + effect: iam.Effect.ALLOW, + resources: [bucket.arnForObjects(this.asset.s3ObjectKey)], + actions: ['s3:GetObject', 's3:GetObjectVersion'], + })); if (!this.asset.isZipArchive) { throw new Error(`Asset must be a .zip file or a directory (${this.path})`); diff --git a/packages/@aws-cdk/aws-gamelift/package.json b/packages/@aws-cdk/aws-gamelift/package.json index 6f133644d1d2b..1096537b3c54e 100644 --- a/packages/@aws-cdk/aws-gamelift/package.json +++ b/packages/@aws-cdk/aws-gamelift/package.json @@ -83,6 +83,7 @@ "@aws-cdk/assertions": "0.0.0", "@aws-cdk/cdk-build-tools": "0.0.0", "@aws-cdk/integ-runner": "0.0.0", + "@aws-cdk/integ-tests": "0.0.0", "@aws-cdk/cfn2ts": "0.0.0", "@aws-cdk/pkglint": "0.0.0", "@aws-cdk/cx-api": "0.0.0", diff --git a/packages/@aws-cdk/aws-gamelift/test/build.test.ts b/packages/@aws-cdk/aws-gamelift/test/build.test.ts index 9e5b6bd6855db..a206119abddb7 100644 --- a/packages/@aws-cdk/aws-gamelift/test/build.test.ts +++ b/packages/@aws-cdk/aws-gamelift/test/build.test.ts @@ -47,37 +47,22 @@ describe('build', () => { const contentBucketName = 'bucketname'; const contentBucketAccessStatement = { Action: [ - 's3:GetObject*', - 's3:GetBucket*', - 's3:List*', + 's3:GetObject', + 's3:GetObjectVersion', ], Effect: 'Allow', - Resource: [ - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - `:s3:::${contentBucketName}`, - ], - ], - }, - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - `:s3:::${contentBucketName}/content`, - ], + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + `:s3:::${contentBucketName}/content`, ], - }, - ], + ], + }, }; let contentBucket: s3.IBucket; let content: gamelift.Content; diff --git a/packages/@aws-cdk/aws-gamelift/test/content.test.ts b/packages/@aws-cdk/aws-gamelift/test/content.test.ts index 0c1f6e0617121..226859dcab37a 100644 --- a/packages/@aws-cdk/aws-gamelift/test/content.test.ts +++ b/packages/@aws-cdk/aws-gamelift/test/content.test.ts @@ -38,37 +38,22 @@ describe('Code', () => { Statement: [ { Action: [ - 's3:GetObject*', - 's3:GetBucket*', - 's3:List*', + 's3:GetObject', + 's3:GetObjectVersion', ], Effect: 'Allow', - Resource: [ - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - ':s3:::bucketname', - ], - ], - }, - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - ':s3:::bucketname/content', - ], + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':s3:::bucketname/content', ], - }, - ], + ], + }, }, ], }, @@ -88,7 +73,7 @@ describe('Code', () => { content = gamelift.Content.fromAsset(directoryPath); }); - test("with valid and existing file path and bound to job sets job's script location and permissions stack metadata", () => { + test('with valid and existing file path and bound to script location and permissions stack metadata', () => { new gamelift.Build(stack, 'Build1', { content: content, }); @@ -146,44 +131,52 @@ describe('Code', () => { Statement: [ { Action: [ - 's3:GetObject*', - 's3:GetBucket*', - 's3:List*', + 's3:GetObject', + 's3:GetObjectVersion', ], Effect: 'Allow', - Resource: [ - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - ':s3:::', - { - Ref: 'AssetParameters6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7S3Bucket72AA8348', - }, - ], - ], - }, - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - ':s3:::', - { - Ref: 'AssetParameters6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7S3Bucket72AA8348', - }, - '/*', - ], + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + ':s3:::', + { + Ref: 'AssetParameters6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7S3Bucket72AA8348', + }, + '/', + { + 'Fn::Select': [ + 0, + { + 'Fn::Split': [ + '||', + { + Ref: 'AssetParameters6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7S3VersionKey720D3160', + }, + ], + }, + ], + }, + { + 'Fn::Select': [ + 1, + { + 'Fn::Split': [ + '||', + { + Ref: 'AssetParameters6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7S3VersionKey720D3160', + }, + ], + }, + ], + }, ], - }, - ], + ], + }, }, ], }, @@ -257,7 +250,6 @@ describe('Code', () => { }; expect(stack.node.metadata.find(m => m.type === 'aws:cdk:asset')).toBeDefined(); - // Job1 and Job2 use reuse the asset Template.fromStack(stack).hasResourceProperties('AWS::GameLift::Build', { StorageLocation, }); diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.assets.json new file mode 100644 index 0000000000000..c960bddbecb0d --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "BuildDefaultTestDeployAssert0688841C.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/BuildDefaultTestDeployAssert0688841C.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.assets.json index d27cd073bc49a..288379fb15a56 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.assets.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.assets.json @@ -14,7 +14,7 @@ } } }, - "9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222": { + "56a977de7626326c13fb108674329fc1a0952d0c525384c951169c7c75812e47": { "source": { "path": "aws-gamelift-build.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222.json", + "objectKey": "56a977de7626326c13fb108674329fc1a0952d0c525384c951169c7c75812e47.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.template.json index 394b49a1b66ff..ebdf264e941a1 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.template.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/aws-gamelift-build.template.json @@ -1,129 +1,115 @@ { - "Resources": { - "BuildServiceRole1F57E904": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "gamelift.amazonaws.com" - } + "Resources": { + "BuildServiceRole1F57E904": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "gamelift.amazonaws.com" } - ], - "Version": "2012-10-17" - } + } + ], + "Version": "2012-10-17" } - }, - "BuildServiceRoleDefaultPolicyCB7101C6": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "s3:GetBucket*", - "s3:GetObject*", - "s3:List*" - ], - "Effect": "Allow", - "Resource": [ + } + }, + "BuildServiceRoleDefaultPolicyCB7101C6": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:GetObject", + "s3:GetObjectVersion" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "/*" - ] - ] - }, - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - } - ] - ] - } + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip" + ] ] } - ], - "Version": "2012-10-17" - }, - "PolicyName": "BuildServiceRoleDefaultPolicyCB7101C6", - "Roles": [ - { - "Ref": "BuildServiceRole1F57E904" - } - ] - } - }, - "Build45A36621": { - "Type": "AWS::GameLift::Build", - "Properties": { - "StorageLocation": { - "Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "Key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", - "RoleArn": { - "Fn::GetAtt": [ - "BuildServiceRole1F57E904", - "Arn" - ] } + ], + "Version": "2012-10-17" + }, + "PolicyName": "BuildServiceRoleDefaultPolicyCB7101C6", + "Roles": [ + { + "Ref": "BuildServiceRole1F57E904" } - } + ] } }, - "Parameters": { - "BootstrapVersion": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/cdk-bootstrap/hnb659fds/version", - "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + "Build45A36621": { + "Type": "AWS::GameLift::Build", + "Properties": { + "StorageLocation": { + "Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "Key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", + "RoleArn": { + "Fn::GetAtt": [ + "BuildServiceRole1F57E904", + "Arn" + ] + } } }, - "Rules": { - "CheckBootstrapVersion": { - "Assertions": [ - { - "Assert": { - "Fn::Not": [ + "DependsOn": [ + "BuildServiceRoleDefaultPolicyCB7101C6", + "BuildServiceRole1F57E904" + ] + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], { - "Fn::Contains": [ - [ - "1", - "2", - "3", - "4", - "5" - ], - { - "Ref": "BootstrapVersion" - } - ] + "Ref": "BootstrapVersion" } ] - }, - "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." - } - ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." } - } - } \ No newline at end of file + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/integ.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/integ.json index f646149706bea..7ab31f50206b7 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/integ.json @@ -1,14 +1,12 @@ { "version": "21.0.0", "testCases": { - "integ.build": { + "Build/DefaultTest": { "stacks": [ "aws-gamelift-build" ], - "diffAssets": false, - "stackUpdateWorkflow": true + "assertionStack": "Build/DefaultTest/DeployAssert", + "assertionStackName": "BuildDefaultTestDeployAssert0688841C" } - }, - "synthContext": {}, - "enableLookups": false + } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/manifest.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/manifest.json index 43fe5eb776640..c0fe7b2462be3 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/manifest.json @@ -23,7 +23,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/56a977de7626326c13fb108674329fc1a0952d0c525384c951169c7c75812e47.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -56,9 +56,68 @@ "type": "aws:cdk:logicalId", "data": "Build45A36621" } + ], + "/aws-gamelift-build/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-gamelift-build/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } ] }, "displayName": "aws-gamelift-build" + }, + "BuildDefaultTestDeployAssert0688841C.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "BuildDefaultTestDeployAssert0688841C.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "BuildDefaultTestDeployAssert0688841C": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "BuildDefaultTestDeployAssert0688841C.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "BuildDefaultTestDeployAssert0688841C.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "BuildDefaultTestDeployAssert0688841C.assets" + ], + "metadata": { + "/Build/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/Build/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "Build/DefaultTest/DeployAssert" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/tree.json b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/tree.json index 96d14a552e490..58798a9740d0c 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.js.snapshot/tree.json @@ -9,24 +9,24 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.33" + "version": "10.1.140" } }, - "build-test-assets": { - "id": "build-test-assets", - "path": "build-test-assets", + "aws-gamelift-build": { + "id": "aws-gamelift-build", + "path": "aws-gamelift-build", "children": { "Build": { "id": "Build", - "path": "build-test-assets/Build", + "path": "aws-gamelift-build/Build", "children": { - "Service Role": { - "id": "Service Role", - "path": "build-test-assets/Build/Service Role", + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-gamelift-build/Build/ServiceRole", "children": { "Resource": { "id": "Resource", - "path": "build-test-assets/Build/Service Role/Resource", + "path": "aws-gamelift-build/Build/ServiceRole/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Role", "aws:cdk:cloudformation:props": { @@ -51,11 +51,11 @@ }, "DefaultPolicy": { "id": "DefaultPolicy", - "path": "build-test-assets/Build/Service Role/DefaultPolicy", + "path": "aws-gamelift-build/Build/ServiceRole/DefaultPolicy", "children": { "Resource": { "id": "Resource", - "path": "build-test-assets/Build/Service Role/DefaultPolicy/Resource", + "path": "aws-gamelift-build/Build/ServiceRole/DefaultPolicy/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Policy", "aws:cdk:cloudformation:props": { @@ -63,52 +63,34 @@ "Statement": [ { "Action": [ - "s3:GetObject*", - "s3:GetBucket*", - "s3:List*" + "s3:GetObject", + "s3:GetObjectVersion" ], "Effect": "Allow", - "Resource": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - } - ] + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip" ] - }, - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "/*" - ] - ] - } - ] + ] + } } ], "Version": "2012-10-17" }, - "policyName": "BuildServiceRoleDefaultPolicy90803718", + "policyName": "BuildServiceRoleDefaultPolicyCB7101C6", "roles": [ { - "Ref": "BuildServiceRole4643E19E" + "Ref": "BuildServiceRole1F57E904" } ] } @@ -132,11 +114,11 @@ }, "Content": { "id": "Content", - "path": "build-test-assets/Build/Content", + "path": "aws-gamelift-build/Build/Content", "children": { "Stage": { "id": "Stage", - "path": "build-test-assets/Build/Content/Stage", + "path": "aws-gamelift-build/Build/Content/Stage", "constructInfo": { "fqn": "@aws-cdk/core.AssetStaging", "version": "0.0.0" @@ -144,7 +126,7 @@ }, "AssetBucket": { "id": "AssetBucket", - "path": "build-test-assets/Build/Content/AssetBucket", + "path": "aws-gamelift-build/Build/Content/AssetBucket", "constructInfo": { "fqn": "@aws-cdk/aws-s3.BucketBase", "version": "0.0.0" @@ -156,9 +138,17 @@ "version": "0.0.0" } }, + "AssetBucket": { + "id": "AssetBucket", + "path": "aws-gamelift-build/Build/AssetBucket", + "constructInfo": { + "fqn": "@aws-cdk/aws-s3.BucketBase", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", - "path": "build-test-assets/Build/Resource", + "path": "aws-gamelift-build/Build/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::GameLift::Build", "aws:cdk:cloudformation:props": { @@ -169,7 +159,7 @@ "key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", "roleArn": { "Fn::GetAtt": [ - "BuildServiceRole4643E19E", + "BuildServiceRole1F57E904", "Arn" ] } @@ -192,6 +182,42 @@ "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } + }, + "Build": { + "id": "Build", + "path": "Build", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "Build/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "Build/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.140" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "Build/DefaultTest/DeployAssert", + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.build.ts b/packages/@aws-cdk/aws-gamelift/test/integ.build.ts index d216cbccd9212..75d260e07c58d 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.build.ts +++ b/packages/@aws-cdk/aws-gamelift/test/integ.build.ts @@ -1,13 +1,24 @@ import * as path from 'path'; import * as cdk from '@aws-cdk/core'; +import { IntegTest } from '@aws-cdk/integ-tests'; +import { Construct } from 'constructs'; import * as gamelift from '../lib'; -const app = new cdk.App(); +class TestStack extends cdk.Stack { + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); -const stack = new cdk.Stack(app, 'aws-gamelift-build'); + new gamelift.Build(this, 'Build', { + content: gamelift.Content.fromAsset(path.join(__dirname, 'my-game-build')), + }); + } +} -new gamelift.Build(stack, 'Build', { - content: gamelift.Content.fromAsset(path.join(__dirname, 'my-game-build')), +// Beginning of the test suite +const app = new cdk.App(); +const stack = new TestStack(app, 'aws-gamelift-build'); +new IntegTest(app, 'Build', { + testCases: [stack], }); app.synth(); diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.assets.json new file mode 100644 index 0000000000000..28c49512b1554 --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "ScriptDefaultTestDeployAssert5DF38444.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/ScriptDefaultTestDeployAssert5DF38444.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.assets.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.assets.json index b5db81d532125..c0d1ef04d9899 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.assets.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.assets.json @@ -14,7 +14,7 @@ } } }, - "9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222": { + "439bb85886f61ae43e9d2c68c630173885845b15d18e3048b76531bdcac17954": { "source": { "path": "aws-gamelift-script.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222.json", + "objectKey": "439bb85886f61ae43e9d2c68c630173885845b15d18e3048b76531bdcac17954.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.template.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.template.json index fe0c724ffaad9..5d609b0676bc2 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.template.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/aws-gamelift-script.template.json @@ -1,129 +1,111 @@ { - "Resources": { - "ScriptServiceRole23DD8079": { - "Type": "AWS::IAM::Role", - "Properties": { - "AssumeRolePolicyDocument": { - "Statement": [ - { - "Action": "sts:AssumeRole", - "Effect": "Allow", - "Principal": { - "Service": "gamelift.amazonaws.com" - } + "Resources": { + "ScriptServiceRole23DD8079": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "gamelift.amazonaws.com" } - ], - "Version": "2012-10-17" - } + } + ], + "Version": "2012-10-17" } - }, - "ScriptServiceRoleDefaultPolicyEE85DAE7": { - "Type": "AWS::IAM::Policy", - "Properties": { - "PolicyDocument": { - "Statement": [ - { - "Action": [ - "s3:GetBucket*", - "s3:GetObject*", - "s3:List*" - ], - "Effect": "Allow", - "Resource": [ + } + }, + "ScriptServiceRoleDefaultPolicyEE85DAE7": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:GetObject", + "s3:GetObjectVersion" + ], + "Effect": "Allow", + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "/*" - ] - ] - }, - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - } - ] - ] - } + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip" + ] ] } - ], - "Version": "2012-10-17" - }, - "PolicyName": "ScriptServiceRoleDefaultPolicyEE85DAE7", - "Roles": [ - { - "Ref": "ScriptServiceRole23DD8079" - } - ] - } - }, - "Script09016516": { - "Type": "AWS::GameLift::Script", - "Properties": { - "StorageLocation": { - "Bucket": { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "Key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", - "RoleArn": { - "Fn::GetAtt": [ - "ScriptServiceRole23DD8079", - "Arn" - ] } + ], + "Version": "2012-10-17" + }, + "PolicyName": "ScriptServiceRoleDefaultPolicyEE85DAE7", + "Roles": [ + { + "Ref": "ScriptServiceRole23DD8079" } - } + ] } }, - "Parameters": { - "BootstrapVersion": { - "Type": "AWS::SSM::Parameter::Value", - "Default": "/cdk-bootstrap/hnb659fds/version", - "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + "Script09016516": { + "Type": "AWS::GameLift::Script", + "Properties": { + "StorageLocation": { + "Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "Key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", + "RoleArn": { + "Fn::GetAtt": [ + "ScriptServiceRole23DD8079", + "Arn" + ] + } } - }, - "Rules": { - "CheckBootstrapVersion": { - "Assertions": [ - { - "Assert": { - "Fn::Not": [ + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], { - "Fn::Contains": [ - [ - "1", - "2", - "3", - "4", - "5" - ], - { - "Ref": "BootstrapVersion" - } - ] + "Ref": "BootstrapVersion" } ] - }, - "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." - } - ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." } - } - } \ No newline at end of file + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/integ.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/integ.json index 87f04519b0e06..88f34b488452f 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/integ.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/integ.json @@ -1,14 +1,12 @@ { "version": "21.0.0", "testCases": { - "integ.script": { + "Script/DefaultTest": { "stacks": [ "aws-gamelift-script" ], - "diffAssets": false, - "stackUpdateWorkflow": true + "assertionStack": "Script/DefaultTest/DeployAssert", + "assertionStackName": "ScriptDefaultTestDeployAssert5DF38444" } - }, - "synthContext": {}, - "enableLookups": false + } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/manifest.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/manifest.json index 5bc5612710eb2..af9cc636b170c 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/manifest.json @@ -23,7 +23,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/9c561e93c7a2947a15dba683670660e922cf493e17b2a6f8ca03cf221442c222.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/439bb85886f61ae43e9d2c68c630173885845b15d18e3048b76531bdcac17954.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -56,9 +56,68 @@ "type": "aws:cdk:logicalId", "data": "Script09016516" } + ], + "/aws-gamelift-script/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-gamelift-script/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } ] }, "displayName": "aws-gamelift-script" + }, + "ScriptDefaultTestDeployAssert5DF38444.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "ScriptDefaultTestDeployAssert5DF38444.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "ScriptDefaultTestDeployAssert5DF38444": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "ScriptDefaultTestDeployAssert5DF38444.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "ScriptDefaultTestDeployAssert5DF38444.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "ScriptDefaultTestDeployAssert5DF38444.assets" + ], + "metadata": { + "/Script/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/Script/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "Script/DefaultTest/DeployAssert" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/tree.json b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/tree.json index 8a6195c91e0cc..456822143785a 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/tree.json +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.js.snapshot/tree.json @@ -9,24 +9,24 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.1.33" + "version": "10.1.140" } }, - "script-test-assets": { - "id": "script-test-assets", - "path": "script-test-assets", + "aws-gamelift-script": { + "id": "aws-gamelift-script", + "path": "aws-gamelift-script", "children": { "Script": { "id": "Script", - "path": "script-test-assets/Script", + "path": "aws-gamelift-script/Script", "children": { - "Service Role": { - "id": "Service Role", - "path": "script-test-assets/Script/Service Role", + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-gamelift-script/Script/ServiceRole", "children": { "Resource": { "id": "Resource", - "path": "script-test-assets/Script/Service Role/Resource", + "path": "aws-gamelift-script/Script/ServiceRole/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Role", "aws:cdk:cloudformation:props": { @@ -51,11 +51,11 @@ }, "DefaultPolicy": { "id": "DefaultPolicy", - "path": "script-test-assets/Script/Service Role/DefaultPolicy", + "path": "aws-gamelift-script/Script/ServiceRole/DefaultPolicy", "children": { "Resource": { "id": "Resource", - "path": "script-test-assets/Script/Service Role/DefaultPolicy/Resource", + "path": "aws-gamelift-script/Script/ServiceRole/DefaultPolicy/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Policy", "aws:cdk:cloudformation:props": { @@ -63,52 +63,34 @@ "Statement": [ { "Action": [ - "s3:GetObject*", - "s3:GetBucket*", - "s3:List*" + "s3:GetObject", + "s3:GetObjectVersion" ], "Effect": "Allow", - "Resource": [ - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - } - ] + "Resource": { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip" ] - }, - { - "Fn::Join": [ - "", - [ - "arn:", - { - "Ref": "AWS::Partition" - }, - ":s3:::", - { - "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" - }, - "/*" - ] - ] - } - ] + ] + } } ], "Version": "2012-10-17" }, - "policyName": "ScriptServiceRoleDefaultPolicy90803718", + "policyName": "ScriptServiceRoleDefaultPolicyEE85DAE7", "roles": [ { - "Ref": "ScriptServiceRole4643E19E" + "Ref": "ScriptServiceRole23DD8079" } ] } @@ -132,11 +114,11 @@ }, "Content": { "id": "Content", - "path": "script-test-assets/Script/Content", + "path": "aws-gamelift-script/Script/Content", "children": { "Stage": { "id": "Stage", - "path": "script-test-assets/Script/Content/Stage", + "path": "aws-gamelift-script/Script/Content/Stage", "constructInfo": { "fqn": "@aws-cdk/core.AssetStaging", "version": "0.0.0" @@ -144,7 +126,7 @@ }, "AssetBucket": { "id": "AssetBucket", - "path": "script-test-assets/Script/Content/AssetBucket", + "path": "aws-gamelift-script/Script/Content/AssetBucket", "constructInfo": { "fqn": "@aws-cdk/aws-s3.BucketBase", "version": "0.0.0" @@ -156,9 +138,17 @@ "version": "0.0.0" } }, + "AssetBucket": { + "id": "AssetBucket", + "path": "aws-gamelift-script/Script/AssetBucket", + "constructInfo": { + "fqn": "@aws-cdk/aws-s3.BucketBase", + "version": "0.0.0" + } + }, "Resource": { "id": "Resource", - "path": "script-test-assets/Script/Resource", + "path": "aws-gamelift-script/Script/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::GameLift::Script", "aws:cdk:cloudformation:props": { @@ -169,7 +159,7 @@ "key": "6019bfc8ab05a24b0ae9b5d8f4585cbfc7d1c30a23286d0b25ce7066a368a5d7.zip", "roleArn": { "Fn::GetAtt": [ - "ScriptServiceRole4643E19E", + "ScriptServiceRole23DD8079", "Arn" ] } @@ -192,6 +182,42 @@ "fqn": "@aws-cdk/core.Stack", "version": "0.0.0" } + }, + "Script": { + "id": "Script", + "path": "Script", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "Script/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "Script/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.140" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "Script/DefaultTest/DeployAssert", + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } } }, "constructInfo": { diff --git a/packages/@aws-cdk/aws-gamelift/test/integ.script.ts b/packages/@aws-cdk/aws-gamelift/test/integ.script.ts index fb85f5b00ab37..1c5c2dfd194db 100644 --- a/packages/@aws-cdk/aws-gamelift/test/integ.script.ts +++ b/packages/@aws-cdk/aws-gamelift/test/integ.script.ts @@ -1,13 +1,24 @@ import * as path from 'path'; import * as cdk from '@aws-cdk/core'; +import { IntegTest } from '@aws-cdk/integ-tests'; +import { Construct } from 'constructs'; import * as gamelift from '../lib'; -const app = new cdk.App(); +class TestStack extends cdk.Stack { + constructor(scope: Construct, id: string, props?: cdk.StackProps) { + super(scope, id, props); -const stack = new cdk.Stack(app, 'aws-gamelift-script'); + new gamelift.Script(this, 'Script', { + content: gamelift.Content.fromAsset(path.join(__dirname, 'my-game-script')), + }); + } +} -new gamelift.Script(stack, 'Script', { - content: gamelift.Content.fromAsset(path.join(__dirname, 'my-game-script')), +// Beginning of the test suite +const app = new cdk.App(); +const stack = new TestStack(app, 'aws-gamelift-script'); +new IntegTest(app, 'Script', { + testCases: [stack], }); app.synth(); diff --git a/packages/@aws-cdk/aws-gamelift/test/script.test.ts b/packages/@aws-cdk/aws-gamelift/test/script.test.ts index b7c5efc2f075d..9dd5828f7c34b 100644 --- a/packages/@aws-cdk/aws-gamelift/test/script.test.ts +++ b/packages/@aws-cdk/aws-gamelift/test/script.test.ts @@ -53,37 +53,22 @@ describe('script', () => { const contentBucketName = 'bucketname'; const contentBucketAccessStatement = { Action: [ - 's3:GetObject*', - 's3:GetBucket*', - 's3:List*', + 's3:GetObject', + 's3:GetObjectVersion', ], Effect: 'Allow', - Resource: [ - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - `:s3:::${contentBucketName}`, - ], - ], - }, - { - 'Fn::Join': [ - '', - [ - 'arn:', - { - Ref: 'AWS::Partition', - }, - `:s3:::${contentBucketName}/content`, - ], + Resource: { + 'Fn::Join': [ + '', + [ + 'arn:', + { + Ref: 'AWS::Partition', + }, + `:s3:::${contentBucketName}/content`, ], - }, - ], + ], + }, }; let contentBucket: s3.IBucket; let content: gamelift.Content;