From c0389215372d0b55ae1382fa42516ab768136889 Mon Sep 17 00:00:00 2001 From: Cory Hall <43035978+corymhall@users.noreply.github.com> Date: Mon, 31 Jan 2022 08:46:28 -0500 Subject: [PATCH 01/17] fix(ec2): `UserData.addSignalOnExitCommand` does not work in combination with `userDataCausesReplacement` (#18726) If both `addSignalOnExitCommand` _and_ `userDataCausesReplacement` are used it results in an invalid logicalId being used in the `cfn-signal` call. This is due to `addSignalOnExitCommand` getting the logicalID from `Stack.getLogicalId` which does not take into consideration logicalId overrides which `userDataCausesReplacement` uses. This updates `addSignalOnExitCommand` to use the `logicalId` of the resource which is evaluated lazily and happens after all overrides. fixes #12749 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-ec2/lib/user-data.ts | 6 +- .../@aws-cdk/aws-ec2/test/userdata.test.ts | 86 ++++++++++++++++++- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/user-data.ts b/packages/@aws-cdk/aws-ec2/lib/user-data.ts index 1e92eb888e6f8..82e256b9a895a 100644 --- a/packages/@aws-cdk/aws-ec2/lib/user-data.ts +++ b/packages/@aws-cdk/aws-ec2/lib/user-data.ts @@ -1,5 +1,5 @@ import { IBucket } from '@aws-cdk/aws-s3'; -import { CfnElement, Fn, Resource, Stack } from '@aws-cdk/core'; +import { Fn, Resource, Stack, CfnResource } from '@aws-cdk/core'; import { OperatingSystemType } from './machine-image'; /** @@ -178,7 +178,7 @@ class LinuxUserData extends UserData { public addSignalOnExitCommand( resource: Resource ): void { const stack = Stack.of(resource); - const resourceID = stack.getLogicalId(resource.node.defaultChild as CfnElement); + const resourceID = (resource.node.defaultChild as CfnResource).logicalId; this.addOnExitCommands(`/opt/aws/bin/cfn-signal --stack ${stack.stackName} --resource ${resourceID} --region ${stack.region} -e $exitCode || echo 'Failed to send Cloudformation Signal'`); } @@ -235,7 +235,7 @@ class WindowsUserData extends UserData { public addSignalOnExitCommand( resource: Resource ): void { const stack = Stack.of(resource); - const resourceID = stack.getLogicalId(resource.node.defaultChild as CfnElement); + const resourceID = (resource.node.defaultChild as CfnResource).logicalId; this.addOnExitCommands(`cfn-signal --stack ${stack.stackName} --resource ${resourceID} --region ${stack.region} --success ($success.ToString().ToLower())`); } diff --git a/packages/@aws-cdk/aws-ec2/test/userdata.test.ts b/packages/@aws-cdk/aws-ec2/test/userdata.test.ts index e2596d8699abd..c385ce83a7254 100644 --- a/packages/@aws-cdk/aws-ec2/test/userdata.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/userdata.test.ts @@ -1,5 +1,6 @@ import { Bucket } from '@aws-cdk/aws-s3'; -import { Aws, Stack } from '@aws-cdk/core'; +import { Template, Match } from '@aws-cdk/assertions'; +import { Aws, Stack, CfnResource } from '@aws-cdk/core'; import * as ec2 from '../lib'; describe('user data', () => { @@ -41,6 +42,7 @@ describe('user data', () => { const stack = new Stack(); const resource = new ec2.Vpc(stack, 'RESOURCE'); const userData = ec2.UserData.forWindows(); + const logicalId = (resource.node.defaultChild as CfnResource).logicalId; // WHEN userData.addSignalOnExitCommand( resource ); @@ -49,9 +51,10 @@ describe('user data', () => { // THEN const rendered = userData.render(); + expect(stack.resolve(logicalId)).toEqual('RESOURCE1989552F'); expect(rendered).toEqual('trap {\n' + '$success=($PSItem.Exception.Message -eq "Success")\n' + - `cfn-signal --stack Default --resource RESOURCE1989552F --region ${Aws.REGION} --success ($success.ToString().ToLower())\n` + + `cfn-signal --stack Default --resource ${logicalId} --region ${Aws.REGION} --success ($success.ToString().ToLower())\n` + 'break\n' + '}\n' + 'command1\n' + @@ -59,6 +62,44 @@ describe('user data', () => { ); }); + test('can create Windows with Signal Command and userDataCausesReplacement', () => { + // GIVEN + const stack = new Stack(); + const vpc = new ec2.Vpc(stack, 'Vpc'); + const userData = ec2.UserData.forWindows(); + const resource = new ec2.Instance(stack, 'RESOURCE', { + vpc, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.genericWindows({ ['us-east-1']: 'ami-12345678' }), + userDataCausesReplacement: true, + userData, + }); + + const logicalId = (resource.node.defaultChild as CfnResource).logicalId; + + // WHEN + userData.addSignalOnExitCommand( resource ); + userData.addCommands('command1'); + + // THEN + Template.fromStack(stack).templateMatches({ + Resources: Match.objectLike({ + RESOURCE1989552Fdfd505305f427919: { + Type: 'AWS::EC2::Instance', + }, + }), + }); + expect(stack.resolve(logicalId)).toEqual('RESOURCE1989552Fdfd505305f427919'); + const rendered = userData.render(); + expect(rendered).toEqual('trap {\n' + + '$success=($PSItem.Exception.Message -eq "Success")\n' + + `cfn-signal --stack Default --resource ${logicalId} --region ${Aws.REGION} --success ($success.ToString().ToLower())\n` + + 'break\n' + + '}\n' + + 'command1\n' + + 'throw "Success"', + ); + }); test('can windows userdata download S3 files', () => { // GIVEN const stack = new Stack(); @@ -174,6 +215,7 @@ describe('user data', () => { // GIVEN const stack = new Stack(); const resource = new ec2.Vpc(stack, 'RESOURCE'); + const logicalId = (resource.node.defaultChild as CfnResource).logicalId; // WHEN const userData = ec2.UserData.forLinux(); @@ -182,15 +224,53 @@ describe('user data', () => { // THEN const rendered = userData.render(); + expect(stack.resolve(logicalId)).toEqual('RESOURCE1989552F'); expect(rendered).toEqual('#!/bin/bash\n' + 'function exitTrap(){\n' + 'exitCode=$?\n' + - `/opt/aws/bin/cfn-signal --stack Default --resource RESOURCE1989552F --region ${Aws.REGION} -e $exitCode || echo \'Failed to send Cloudformation Signal\'\n` + + `/opt/aws/bin/cfn-signal --stack Default --resource ${logicalId} --region ${Aws.REGION} -e $exitCode || echo \'Failed to send Cloudformation Signal\'\n` + '}\n' + 'trap exitTrap EXIT\n' + 'command1'); }); + test('can create Linux with Signal Command and userDataCausesReplacement', () => { + // GIVEN + const stack = new Stack(); + const vpc = new ec2.Vpc(stack, 'Vpc'); + const userData = ec2.UserData.forLinux(); + const resource = new ec2.Instance(stack, 'RESOURCE', { + vpc, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE), + machineImage: ec2.MachineImage.genericLinux({ ['us-east-1']: 'ami-12345678' }), + userDataCausesReplacement: true, + userData, + }); + + const logicalId = (resource.node.defaultChild as CfnResource).logicalId; + + // WHEN + userData.addSignalOnExitCommand( resource ); + userData.addCommands('command1'); + + // THEN + Template.fromStack(stack).templateMatches({ + Resources: Match.objectLike({ + RESOURCE1989552F74a24ef4fbc89422: { + Type: 'AWS::EC2::Instance', + }, + }), + }); + expect(stack.resolve(logicalId)).toEqual('RESOURCE1989552F74a24ef4fbc89422'); + const rendered = userData.render(); + expect(rendered).toEqual('#!/bin/bash\n' + + 'function exitTrap(){\n' + + 'exitCode=$?\n' + + `/opt/aws/bin/cfn-signal --stack Default --resource ${logicalId} --region ${Aws.REGION} -e $exitCode || echo \'Failed to send Cloudformation Signal\'\n` + + '}\n' + + 'trap exitTrap EXIT\n' + + 'command1'); + }); test('can linux userdata download S3 files', () => { // GIVEN const stack = new Stack(); From 7fef2a269803d17a9a106a3e9a36c090ebaa3ace Mon Sep 17 00:00:00 2001 From: Dzhuneyt <1754428+Dzhuneyt@users.noreply.github.com> Date: Thu, 7 Jul 2022 18:15:49 +0000 Subject: [PATCH 02/17] feat: Pass default AWS_REGION and AWS_ACCOUNT --- packages/@aws-cdk/aws-batch/lib/job-definition.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-batch/lib/job-definition.ts b/packages/@aws-cdk/aws-batch/lib/job-definition.ts index 99c28fa03d5c6..849c8c60ae0d5 100644 --- a/packages/@aws-cdk/aws-batch/lib/job-definition.ts +++ b/packages/@aws-cdk/aws-batch/lib/job-definition.ts @@ -519,9 +519,17 @@ export class JobDefinition extends Resource implements IJobDefinition { return undefined; } + // If the AWS_*** environment variables are not explicitly set to the container, infer them from the current environment. + // This makes the usage of tools like AWS SDK inside the container frictionless + const environment = { + AWS_REGION: Stack.of(this).region, + AWS_ACCOUNT: Stack.of(this).account, + ...this.deserializeEnvVariables(container.environment), + }; + return { command: container.command, - environment: this.deserializeEnvVariables(container.environment), + environment, secrets: container.secrets ? Object.entries(container.secrets).map(([key, value]) => { return { From 248319ca39ed787e4143f276aaa3fafd2e375972 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 12 Jul 2022 15:05:18 +0300 Subject: [PATCH 03/17] chore: Update README.md --- packages/@aws-cdk/aws-batch/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@aws-cdk/aws-batch/README.md b/packages/@aws-cdk/aws-batch/README.md index 0ef420a0422a5..b770280300b3a 100644 --- a/packages/@aws-cdk/aws-batch/README.md +++ b/packages/@aws-cdk/aws-batch/README.md @@ -333,6 +333,8 @@ new batch.JobDefinition(this, 'batch-job-def-secrets', { }); ``` +Note that the AWS_ACCOUNT and AWS_REGION environment variables are always available to JobDefiniton constructs, unless you device to overwrite them. + ### Importing an existing Job Definition #### From ARN From 364c74a3101044ae6f3b98093b03b45aa8603955 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 12 Jul 2022 15:12:27 +0300 Subject: [PATCH 04/17] feat: Pass default environment variables --- .../@aws-cdk/aws-batch/lib/job-definition.ts | 164 +++++++++++++----- 1 file changed, 117 insertions(+), 47 deletions(-) diff --git a/packages/@aws-cdk/aws-batch/lib/job-definition.ts b/packages/@aws-cdk/aws-batch/lib/job-definition.ts index 849c8c60ae0d5..1c45994391321 100644 --- a/packages/@aws-cdk/aws-batch/lib/job-definition.ts +++ b/packages/@aws-cdk/aws-batch/lib/job-definition.ts @@ -49,7 +49,7 @@ export enum LogDriver { /** * Specifies the syslog logging driver. */ - SYSLOG = 'syslog' + SYSLOG = 'syslog', } /** @@ -64,7 +64,7 @@ export enum PlatformCapabilities { /** * Specifies Fargate environment. */ - FARGATE = 'FARGATE' + FARGATE = 'FARGATE', } /** @@ -225,7 +225,7 @@ export interface JobDefinitionContainer { * * @default - LATEST platform version will be used */ - readonly platformVersion?: ecs.FargatePlatformVersion + readonly platformVersion?: ecs.FargatePlatformVersion; /** * The IAM role that AWS Batch can assume. @@ -240,7 +240,7 @@ export interface JobDefinitionContainer { * * @default - false */ - readonly assignPublicIp?: boolean + readonly assignPublicIp?: boolean; } /** @@ -387,9 +387,16 @@ export class JobDefinition extends Resource implements IJobDefinition { * @param id * @param jobDefinitionArn */ - public static fromJobDefinitionArn(scope: Construct, id: string, jobDefinitionArn: string): IJobDefinition { + public static fromJobDefinitionArn( + scope: Construct, + id: string, + jobDefinitionArn: string, + ): IJobDefinition { const stack = Stack.of(scope); - const jobDefName = stack.splitArn(jobDefinitionArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName!; + const jobDefName = stack.splitArn( + jobDefinitionArn, + ArnFormat.SLASH_RESOURCE_NAME, + ).resourceName!; class Import extends Resource implements IJobDefinition { public readonly jobDefinitionArn = jobDefinitionArn; @@ -407,7 +414,11 @@ export class JobDefinition extends Resource implements IJobDefinition { * @param id * @param jobDefinitionName */ - public static fromJobDefinitionName(scope: Construct, id: string, jobDefinitionName: string): IJobDefinition { + public static fromJobDefinitionName( + scope: Construct, + id: string, + jobDefinitionName: string, + ): IJobDefinition { const stack = Stack.of(scope); const jobDefArn = stack.formatArn({ service: 'batch', @@ -437,7 +448,9 @@ export class JobDefinition extends Resource implements IJobDefinition { this.imageConfig = new JobDefinitionImageConfig(this, props.container); - const isFargate = !!props.platformCapabilities?.includes(PlatformCapabilities.FARGATE); + const isFargate = !!props.platformCapabilities?.includes( + PlatformCapabilities.FARGATE, + ); const jobDef = new CfnJobDefinition(this, 'Resource', { jobDefinitionName: props.jobDefinitionName, @@ -446,7 +459,10 @@ export class JobDefinition extends Resource implements IJobDefinition { nodeProperties: props.nodeProps ? { mainNode: props.nodeProps.mainNode, - nodeRangeProperties: this.buildNodeRangeProps(props.nodeProps, isFargate), + nodeRangeProperties: this.buildNodeRangeProps( + props.nodeProps, + isFargate, + ), numNodes: props.nodeProps.count, } : undefined, @@ -455,13 +471,17 @@ export class JobDefinition extends Resource implements IJobDefinition { attempts: props.retryAttempts || 1, }, timeout: { - attemptDurationSeconds: props.timeout ? props.timeout.toSeconds() : undefined, + attemptDurationSeconds: props.timeout + ? props.timeout.toSeconds() + : undefined, }, - platformCapabilities: props.platformCapabilities ?? [PlatformCapabilities.EC2], + platformCapabilities: props.platformCapabilities ?? [ + PlatformCapabilities.EC2, + ], }); // add read secrets permission to execution role - if ( props.container.secrets && props.container.executionRole ) { + if (props.container.secrets && props.container.executionRole) { const executionRole = props.container.executionRole; Object.values(props.container.secrets).forEach((secret) => { secret.grantRead(executionRole); @@ -476,11 +496,13 @@ export class JobDefinition extends Resource implements IJobDefinition { this.jobDefinitionName = this.getResourceNameAttribute(jobDef.ref); } - private deserializeEnvVariables(env?: { [name: string]: string }): CfnJobDefinition.EnvironmentProperty[] | undefined { + private deserializeEnvVariables(env?: { + [name: string]: string; + }): CfnJobDefinition.EnvironmentProperty[] { const vars = new Array(); if (env === undefined) { - return undefined; + return vars; } Object.keys(env).map((name: string) => { @@ -498,34 +520,56 @@ export class JobDefinition extends Resource implements IJobDefinition { return; } - if (props.platformCapabilities !== undefined && props.platformCapabilities.includes(PlatformCapabilities.FARGATE) - && props.container.executionRole === undefined) { + if ( + props.platformCapabilities !== undefined && + props.platformCapabilities.includes(PlatformCapabilities.FARGATE) && + props.container.executionRole === undefined + ) { throw new Error('Fargate job must have executionRole set'); } - if (props.platformCapabilities !== undefined && props.platformCapabilities.includes(PlatformCapabilities.FARGATE) - && props.container.gpuCount !== undefined) { + if ( + props.platformCapabilities !== undefined && + props.platformCapabilities.includes(PlatformCapabilities.FARGATE) && + props.container.gpuCount !== undefined + ) { throw new Error('Fargate job must not have gpuCount set'); } - if ((props.platformCapabilities === undefined || props.platformCapabilities.includes(PlatformCapabilities.EC2)) - && props.container.assignPublicIp !== undefined) { + if ( + (props.platformCapabilities === undefined || + props.platformCapabilities.includes(PlatformCapabilities.EC2)) && + props.container.assignPublicIp !== undefined + ) { throw new Error('EC2 job must not have assignPublicIp set'); } } - private buildJobContainer(container: JobDefinitionContainer, isFargate: boolean): CfnJobDefinition.ContainerPropertiesProperty | undefined { + private buildJobContainer( + container: JobDefinitionContainer, + isFargate: boolean, + ): CfnJobDefinition.ContainerPropertiesProperty | undefined { if (container === undefined) { return undefined; } // If the AWS_*** environment variables are not explicitly set to the container, infer them from the current environment. // This makes the usage of tools like AWS SDK inside the container frictionless - const environment = { - AWS_REGION: Stack.of(this).region, - AWS_ACCOUNT: Stack.of(this).account, - ...this.deserializeEnvVariables(container.environment), - }; + + const environment = this.deserializeEnvVariables(container.environment); + + if (!environment.find((x) => x.name === 'AWS_REGION')) { + environment.push({ + name: 'AWS_REGION', + value: Stack.of(this).region, + }); + } + if (!environment.find((x) => x.name === 'AWS_ACCOUNT')) { + environment.push({ + name: 'AWS_REGION', + value: Stack.of(this).account, + }); + } return { command: container.command, @@ -541,51 +585,77 @@ export class JobDefinition extends Resource implements IJobDefinition { image: this.imageConfig.imageName, instanceType: container.instanceType && container.instanceType.toString(), jobRoleArn: container.jobRole && container.jobRole.roleArn, - executionRoleArn: container.executionRole && container.executionRole.roleArn, + executionRoleArn: + container.executionRole && container.executionRole.roleArn, linuxParameters: container.linuxParams ? { devices: container.linuxParams.renderLinuxParameters().devices } : undefined, - logConfiguration: container.logConfiguration ? { - logDriver: container.logConfiguration.logDriver, - options: container.logConfiguration.options, - secretOptions: container.logConfiguration.secretOptions - ? this.buildLogConfigurationSecretOptions(container.logConfiguration.secretOptions) - : undefined, - } : undefined, + logConfiguration: container.logConfiguration + ? { + logDriver: container.logConfiguration.logDriver, + options: container.logConfiguration.options, + secretOptions: container.logConfiguration.secretOptions + ? this.buildLogConfigurationSecretOptions( + container.logConfiguration.secretOptions, + ) + : undefined, + } + : undefined, mountPoints: container.mountPoints, privileged: container.privileged || false, - networkConfiguration: container.assignPublicIp ? { - assignPublicIp: container.assignPublicIp ? 'ENABLED' : 'DISABLED', - } : undefined, + networkConfiguration: container.assignPublicIp + ? { + assignPublicIp: container.assignPublicIp ? 'ENABLED' : 'DISABLED', + } + : undefined, readonlyRootFilesystem: container.readOnly || false, ulimits: container.ulimits, user: container.user, volumes: container.volumes, - fargatePlatformConfiguration: container.platformVersion ? { - platformVersion: container.platformVersion, - } : undefined, + fargatePlatformConfiguration: container.platformVersion + ? { + platformVersion: container.platformVersion, + } + : undefined, resourceRequirements: [ - { type: 'VCPU', value: String(container.vcpus || (isFargate ? 0.25 : 1)) }, - { type: 'MEMORY', value: String(container.memoryLimitMiB || (isFargate ? 512 : 4)) }, - ].concat(container.gpuCount ? [{ type: 'GPU', value: String(container.gpuCount) }] : []), + { + type: 'VCPU', + value: String(container.vcpus || (isFargate ? 0.25 : 1)), + }, + { + type: 'MEMORY', + value: String(container.memoryLimitMiB || (isFargate ? 512 : 4)), + }, + ].concat( + container.gpuCount + ? [{ type: 'GPU', value: String(container.gpuCount) }] + : [], + ), }; } - private buildNodeRangeProps(multiNodeProps: IMultiNodeProps, isFargate: boolean): CfnJobDefinition.NodeRangePropertyProperty[] { + private buildNodeRangeProps( + multiNodeProps: IMultiNodeProps, + isFargate: boolean, + ): CfnJobDefinition.NodeRangePropertyProperty[] { const rangeProps = new Array(); for (const prop of multiNodeProps.rangeProps) { rangeProps.push({ container: this.buildJobContainer(prop.container, isFargate), - targetNodes: `${prop.fromNodeIndex || 0}:${prop.toNodeIndex || multiNodeProps.count}`, + targetNodes: `${prop.fromNodeIndex || 0}:${ + prop.toNodeIndex || multiNodeProps.count + }`, }); } return rangeProps; } - private buildLogConfigurationSecretOptions(secretOptions: ExposedSecret[]): CfnJobDefinition.SecretProperty[] { - return secretOptions.map(secretOption => { + private buildLogConfigurationSecretOptions( + secretOptions: ExposedSecret[], + ): CfnJobDefinition.SecretProperty[] { + return secretOptions.map((secretOption) => { return { name: secretOption.optionName, valueFrom: secretOption.secretArn, From d488b86814236a9b445eb8e5c9841fd7f6fed837 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 12 Jul 2022 15:13:41 +0300 Subject: [PATCH 05/17] feat: Pass default environment variables --- packages/@aws-cdk/aws-batch/lib/job-definition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-batch/lib/job-definition.ts b/packages/@aws-cdk/aws-batch/lib/job-definition.ts index 1c45994391321..6e90d70ecc4bd 100644 --- a/packages/@aws-cdk/aws-batch/lib/job-definition.ts +++ b/packages/@aws-cdk/aws-batch/lib/job-definition.ts @@ -566,7 +566,7 @@ export class JobDefinition extends Resource implements IJobDefinition { } if (!environment.find((x) => x.name === 'AWS_ACCOUNT')) { environment.push({ - name: 'AWS_REGION', + name: 'AWS_ACCOUNT', value: Stack.of(this).account, }); } From 52a9b4cea7cff891005d4a44b4c45322abf946e7 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 12 Jul 2022 16:20:26 +0300 Subject: [PATCH 06/17] chore: Fix tests --- .../aws-batch/test/job-definition.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.test.ts b/packages/@aws-cdk/aws-batch/test/job-definition.test.ts index addaa5447f6ec..0174ad372b2ab 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.test.ts +++ b/packages/@aws-cdk/aws-batch/test/job-definition.test.ts @@ -91,6 +91,18 @@ describe('Batch Job Definition', () => { Name: 'foo', Value: 'bar', }, + { + Name: 'AWS_REGION', + Value: { + Ref: 'AWS::Region', + }, + }, + { + Name: 'AWS_ACCOUNT', + Value: { + Ref: 'AWS::AccountId', + }, + }, ], Secrets: [ { @@ -184,6 +196,18 @@ describe('Batch Job Definition', () => { Name: 'foo', Value: 'bar', }, + { + Name: 'AWS_REGION', + Value: { + Ref: 'AWS::Region', + }, + }, + { + Name: 'AWS_ACCOUNT', + Value: { + Ref: 'AWS::AccountId', + }, + }, ], Secrets: [ { From 66d92aa7df5b080d4f85c6de6f7b5b5fbbcfb223 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Wed, 13 Jul 2022 12:01:41 +0300 Subject: [PATCH 07/17] chore: Restore original formatting --- .../@aws-cdk/aws-batch/lib/job-definition.ts | 144 +++++------------- 1 file changed, 42 insertions(+), 102 deletions(-) diff --git a/packages/@aws-cdk/aws-batch/lib/job-definition.ts b/packages/@aws-cdk/aws-batch/lib/job-definition.ts index 6e90d70ecc4bd..3666356c5b06f 100644 --- a/packages/@aws-cdk/aws-batch/lib/job-definition.ts +++ b/packages/@aws-cdk/aws-batch/lib/job-definition.ts @@ -49,7 +49,7 @@ export enum LogDriver { /** * Specifies the syslog logging driver. */ - SYSLOG = 'syslog', + SYSLOG = 'syslog' } /** @@ -64,7 +64,7 @@ export enum PlatformCapabilities { /** * Specifies Fargate environment. */ - FARGATE = 'FARGATE', + FARGATE = 'FARGATE' } /** @@ -225,7 +225,7 @@ export interface JobDefinitionContainer { * * @default - LATEST platform version will be used */ - readonly platformVersion?: ecs.FargatePlatformVersion; + readonly platformVersion?: ecs.FargatePlatformVersion /** * The IAM role that AWS Batch can assume. @@ -240,7 +240,7 @@ export interface JobDefinitionContainer { * * @default - false */ - readonly assignPublicIp?: boolean; + readonly assignPublicIp?: boolean } /** @@ -387,16 +387,9 @@ export class JobDefinition extends Resource implements IJobDefinition { * @param id * @param jobDefinitionArn */ - public static fromJobDefinitionArn( - scope: Construct, - id: string, - jobDefinitionArn: string, - ): IJobDefinition { + public static fromJobDefinitionArn(scope: Construct, id: string, jobDefinitionArn: string): IJobDefinition { const stack = Stack.of(scope); - const jobDefName = stack.splitArn( - jobDefinitionArn, - ArnFormat.SLASH_RESOURCE_NAME, - ).resourceName!; + const jobDefName = stack.splitArn(jobDefinitionArn, ArnFormat.SLASH_RESOURCE_NAME).resourceName!; class Import extends Resource implements IJobDefinition { public readonly jobDefinitionArn = jobDefinitionArn; @@ -414,11 +407,7 @@ export class JobDefinition extends Resource implements IJobDefinition { * @param id * @param jobDefinitionName */ - public static fromJobDefinitionName( - scope: Construct, - id: string, - jobDefinitionName: string, - ): IJobDefinition { + public static fromJobDefinitionName(scope: Construct, id: string, jobDefinitionName: string): IJobDefinition { const stack = Stack.of(scope); const jobDefArn = stack.formatArn({ service: 'batch', @@ -448,9 +437,7 @@ export class JobDefinition extends Resource implements IJobDefinition { this.imageConfig = new JobDefinitionImageConfig(this, props.container); - const isFargate = !!props.platformCapabilities?.includes( - PlatformCapabilities.FARGATE, - ); + const isFargate = !!props.platformCapabilities?.includes(PlatformCapabilities.FARGATE); const jobDef = new CfnJobDefinition(this, 'Resource', { jobDefinitionName: props.jobDefinitionName, @@ -459,10 +446,7 @@ export class JobDefinition extends Resource implements IJobDefinition { nodeProperties: props.nodeProps ? { mainNode: props.nodeProps.mainNode, - nodeRangeProperties: this.buildNodeRangeProps( - props.nodeProps, - isFargate, - ), + nodeRangeProperties: this.buildNodeRangeProps(props.nodeProps, isFargate), numNodes: props.nodeProps.count, } : undefined, @@ -471,17 +455,13 @@ export class JobDefinition extends Resource implements IJobDefinition { attempts: props.retryAttempts || 1, }, timeout: { - attemptDurationSeconds: props.timeout - ? props.timeout.toSeconds() - : undefined, + attemptDurationSeconds: props.timeout ? props.timeout.toSeconds() : undefined, }, - platformCapabilities: props.platformCapabilities ?? [ - PlatformCapabilities.EC2, - ], + platformCapabilities: props.platformCapabilities ?? [PlatformCapabilities.EC2], }); // add read secrets permission to execution role - if (props.container.secrets && props.container.executionRole) { + if ( props.container.secrets && props.container.executionRole ) { const executionRole = props.container.executionRole; Object.values(props.container.secrets).forEach((secret) => { secret.grantRead(executionRole); @@ -496,9 +476,7 @@ export class JobDefinition extends Resource implements IJobDefinition { this.jobDefinitionName = this.getResourceNameAttribute(jobDef.ref); } - private deserializeEnvVariables(env?: { - [name: string]: string; - }): CfnJobDefinition.EnvironmentProperty[] { + private deserializeEnvVariables(env?: { [name: string]: string }): CfnJobDefinition.EnvironmentProperty[] { const vars = new Array(); if (env === undefined) { @@ -520,35 +498,23 @@ export class JobDefinition extends Resource implements IJobDefinition { return; } - if ( - props.platformCapabilities !== undefined && - props.platformCapabilities.includes(PlatformCapabilities.FARGATE) && - props.container.executionRole === undefined - ) { + if (props.platformCapabilities !== undefined && props.platformCapabilities.includes(PlatformCapabilities.FARGATE) + && props.container.executionRole === undefined) { throw new Error('Fargate job must have executionRole set'); } - if ( - props.platformCapabilities !== undefined && - props.platformCapabilities.includes(PlatformCapabilities.FARGATE) && - props.container.gpuCount !== undefined - ) { + if (props.platformCapabilities !== undefined && props.platformCapabilities.includes(PlatformCapabilities.FARGATE) + && props.container.gpuCount !== undefined) { throw new Error('Fargate job must not have gpuCount set'); } - if ( - (props.platformCapabilities === undefined || - props.platformCapabilities.includes(PlatformCapabilities.EC2)) && - props.container.assignPublicIp !== undefined - ) { + if ((props.platformCapabilities === undefined || props.platformCapabilities.includes(PlatformCapabilities.EC2)) + && props.container.assignPublicIp !== undefined) { throw new Error('EC2 job must not have assignPublicIp set'); } } - private buildJobContainer( - container: JobDefinitionContainer, - isFargate: boolean, - ): CfnJobDefinition.ContainerPropertiesProperty | undefined { + private buildJobContainer(container: JobDefinitionContainer, isFargate: boolean): CfnJobDefinition.ContainerPropertiesProperty | undefined { if (container === undefined) { return undefined; } @@ -585,81 +551,55 @@ export class JobDefinition extends Resource implements IJobDefinition { image: this.imageConfig.imageName, instanceType: container.instanceType && container.instanceType.toString(), jobRoleArn: container.jobRole && container.jobRole.roleArn, - executionRoleArn: - container.executionRole && container.executionRole.roleArn, + executionRoleArn: container.executionRole && container.executionRole.roleArn, linuxParameters: container.linuxParams ? { devices: container.linuxParams.renderLinuxParameters().devices } : undefined, - logConfiguration: container.logConfiguration - ? { - logDriver: container.logConfiguration.logDriver, - options: container.logConfiguration.options, - secretOptions: container.logConfiguration.secretOptions - ? this.buildLogConfigurationSecretOptions( - container.logConfiguration.secretOptions, - ) - : undefined, - } - : undefined, + logConfiguration: container.logConfiguration ? { + logDriver: container.logConfiguration.logDriver, + options: container.logConfiguration.options, + secretOptions: container.logConfiguration.secretOptions + ? this.buildLogConfigurationSecretOptions(container.logConfiguration.secretOptions) + : undefined, + } : undefined, mountPoints: container.mountPoints, privileged: container.privileged || false, - networkConfiguration: container.assignPublicIp - ? { - assignPublicIp: container.assignPublicIp ? 'ENABLED' : 'DISABLED', - } - : undefined, + networkConfiguration: container.assignPublicIp ? { + assignPublicIp: container.assignPublicIp ? 'ENABLED' : 'DISABLED', + } : undefined, readonlyRootFilesystem: container.readOnly || false, ulimits: container.ulimits, user: container.user, volumes: container.volumes, - fargatePlatformConfiguration: container.platformVersion - ? { - platformVersion: container.platformVersion, - } - : undefined, + fargatePlatformConfiguration: container.platformVersion ? { + platformVersion: container.platformVersion, + } : undefined, resourceRequirements: [ - { - type: 'VCPU', - value: String(container.vcpus || (isFargate ? 0.25 : 1)), - }, - { - type: 'MEMORY', - value: String(container.memoryLimitMiB || (isFargate ? 512 : 4)), - }, - ].concat( - container.gpuCount - ? [{ type: 'GPU', value: String(container.gpuCount) }] - : [], - ), + { type: 'VCPU', value: String(container.vcpus || (isFargate ? 0.25 : 1)) }, + { type: 'MEMORY', value: String(container.memoryLimitMiB || (isFargate ? 512 : 4)) }, + ].concat(container.gpuCount ? [{ type: 'GPU', value: String(container.gpuCount) }] : []), }; } - private buildNodeRangeProps( - multiNodeProps: IMultiNodeProps, - isFargate: boolean, - ): CfnJobDefinition.NodeRangePropertyProperty[] { + private buildNodeRangeProps(multiNodeProps: IMultiNodeProps, isFargate: boolean): CfnJobDefinition.NodeRangePropertyProperty[] { const rangeProps = new Array(); for (const prop of multiNodeProps.rangeProps) { rangeProps.push({ container: this.buildJobContainer(prop.container, isFargate), - targetNodes: `${prop.fromNodeIndex || 0}:${ - prop.toNodeIndex || multiNodeProps.count - }`, + targetNodes: `${prop.fromNodeIndex || 0}:${prop.toNodeIndex || multiNodeProps.count}`, }); } return rangeProps; } - private buildLogConfigurationSecretOptions( - secretOptions: ExposedSecret[], - ): CfnJobDefinition.SecretProperty[] { - return secretOptions.map((secretOption) => { + private buildLogConfigurationSecretOptions(secretOptions: ExposedSecret[]): CfnJobDefinition.SecretProperty[] { + return secretOptions.map(secretOption => { return { name: secretOption.optionName, valueFrom: secretOption.secretArn, }; }); } -} +} \ No newline at end of file From ccd5dc8e9af0e2811fc64e8a7021c69287a6dae1 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Wed, 13 Jul 2022 12:04:28 +0300 Subject: [PATCH 08/17] chore: Update README.md --- packages/@aws-cdk/aws-batch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-batch/README.md b/packages/@aws-cdk/aws-batch/README.md index b770280300b3a..44200017a2e77 100644 --- a/packages/@aws-cdk/aws-batch/README.md +++ b/packages/@aws-cdk/aws-batch/README.md @@ -333,7 +333,7 @@ new batch.JobDefinition(this, 'batch-job-def-secrets', { }); ``` -Note that the AWS_ACCOUNT and AWS_REGION environment variables are always available to JobDefiniton constructs, unless you device to overwrite them. +It is common practice to invoke other AWS services from within AWS Batch jobs (e.g. using the AWS SDK). For this reason, the AWS_ACCOUNT and AWS_REGION environments are always provided by default to the JobDefinition construct. You can always overwrite them by setting these environment variables explicitly though. ### Importing an existing Job Definition From f8f765eba0db6fd89a42310c60812807b0bea472 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Wed, 13 Jul 2022 12:05:19 +0300 Subject: [PATCH 09/17] chore: Update README.md --- packages/@aws-cdk/aws-batch/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-batch/README.md b/packages/@aws-cdk/aws-batch/README.md index 44200017a2e77..02252a8cc6625 100644 --- a/packages/@aws-cdk/aws-batch/README.md +++ b/packages/@aws-cdk/aws-batch/README.md @@ -333,7 +333,7 @@ new batch.JobDefinition(this, 'batch-job-def-secrets', { }); ``` -It is common practice to invoke other AWS services from within AWS Batch jobs (e.g. using the AWS SDK). For this reason, the AWS_ACCOUNT and AWS_REGION environments are always provided by default to the JobDefinition construct. You can always overwrite them by setting these environment variables explicitly though. +It is common practice to invoke other AWS services from within AWS Batch jobs (e.g. using the AWS SDK). For this reason, the AWS_ACCOUNT and AWS_REGION environments are always provided by default to the JobDefinition construct with the values inferred from the current context. You can always overwrite them by setting these environment variables explicitly though. ### Importing an existing Job Definition From c5b01061510f8c7ccd2a4388f64b4caf763cc547 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Wed, 13 Jul 2022 15:07:01 +0300 Subject: [PATCH 10/17] test: Try creating an integration test --- packages/@aws-cdk/aws-batch/package.json | 1 + .../aws-batch/test/integ.job-definition.ts | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 packages/@aws-cdk/aws-batch/test/integ.job-definition.ts diff --git a/packages/@aws-cdk/aws-batch/package.json b/packages/@aws-cdk/aws-batch/package.json index 323256ed2632c..40bf13643c57c 100644 --- a/packages/@aws-cdk/aws-batch/package.json +++ b/packages/@aws-cdk/aws-batch/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", "@types/jest": "^27.5.2", diff --git a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts new file mode 100644 index 0000000000000..e8a79a14a6e1a --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts @@ -0,0 +1,49 @@ +/* eslint-disable quotes */ +import { ContainerImage } from "@aws-cdk/aws-ecs"; +import { App, Stack } from "@aws-cdk/core"; +import { ExpectedResult, IntegTest } from "@aws-cdk/integ-tests"; +import { Construct } from "constructs"; +import { JobDefinition } from "../lib"; + +const jobDefinitionName = "aws-batch-with-fallback-env"; + +class SampleStack extends Stack { + constructor(scope: Construct, id: string) { + super(scope, id); + + new JobDefinition(this, "batch", { + jobDefinitionName, + container: { + image: ContainerImage.fromRegistry("docker/whalesay"), + }, + }); + } +} + +// Beginning of the test suite +const app = new App(); + +const integ = new IntegTest(app, "IntegTest-aws-batch-default-env-variables", { + testCases: [ + new SampleStack(app, "SampleStack-aws-batch-default-env-variables"), + ], +}); +const awsApiCallResponse = integ.assertions.awsApiCall( + "Batch", + "describeJobDefinitions", + { + jobDefinitionName, + }, +); + +awsApiCallResponse.assertAtPath( + "jobDefinitions.0.containerProperties.environment", + ExpectedResult.arrayWith([ + { + name: "AWS_REGION", + value: "", + }, + ]), +); + +app.synth(); From aa4478e7993129f65013e6b4a995ab2e5018a8a7 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Fri, 15 Jul 2022 01:10:49 +0300 Subject: [PATCH 11/17] chore: Update integration test snapshots --- packages/@aws-cdk/aws-batch/test/integ.job-definition.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts index e8a79a14a6e1a..5a9607dfc59e1 100644 --- a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts +++ b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts @@ -5,7 +5,7 @@ import { ExpectedResult, IntegTest } from "@aws-cdk/integ-tests"; import { Construct } from "constructs"; import { JobDefinition } from "../lib"; -const jobDefinitionName = "aws-batch-with-fallback-env"; +const jobDefinitionName = "aws-batch-test"; class SampleStack extends Stack { constructor(scope: Construct, id: string) { @@ -33,7 +33,7 @@ const awsApiCallResponse = integ.assertions.awsApiCall( "describeJobDefinitions", { jobDefinitionName, - }, + } ); awsApiCallResponse.assertAtPath( @@ -43,7 +43,7 @@ awsApiCallResponse.assertAtPath( name: "AWS_REGION", value: "", }, - ]), + ]) ); app.synth(); From c2f1ac2b2e07911c7df69e8034cc37508325fc2e Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Fri, 15 Jul 2022 01:10:58 +0300 Subject: [PATCH 12/17] chore: Update integration test snapshots --- .../batch-stack.assets.json | 4 +- .../batch-stack.template.json | 42 ++ .../test/batch.integ.snapshot/manifest.json | 30 + .../test/batch.integ.snapshot/tree.json | 278 ++++++++ ...aultTestDeployAssert58502566.template.json | 162 +++++ ...-batch-default-env-variables.template.json | 47 ++ .../index.js | 620 ++++++++++++++++++ .../job-definition.integ.snapshot/cdk.out | 1 + .../job-definition.integ.snapshot/integ.json | 11 + .../manifest.json | 101 +++ .../job-definition.integ.snapshot/tree.json | 324 +++++++++ 11 files changed, 1618 insertions(+), 2 deletions(-) create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle/index.js create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json diff --git a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.assets.json b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.assets.json index 10c7b228276fe..e8f7e16a4dbbb 100644 --- a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.assets.json +++ b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.assets.json @@ -1,7 +1,7 @@ { "version": "20.0.0", "files": { - "d3685c79f9ec67f5dd6fda839a136b079f201b3d72695fe0ea3b3788c3471cc8": { + "dd24d4801d80a639d9d7dcd67e4caa9af438a4af95a6243cdebbe188e79ba312": { "source": { "path": "batch-stack.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "d3685c79f9ec67f5dd6fda839a136b079f201b3d72695fe0ea3b3788c3471cc8.json", + "objectKey": "dd24d4801d80a639d9d7dcd67e4caa9af438a4af95a6243cdebbe188e79ba312.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-batch/test/batch.integ.snapshot/batch-stack.template.json b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.template.json index 363a7d93cb0ec..c7637933fee61 100644 --- a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.template.json +++ b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/batch-stack.template.json @@ -1659,6 +1659,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "Image": { "Fn::Join": [ "", @@ -1735,6 +1749,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "Image": "docker/whalesay", "Privileged": false, "ReadonlyRootFilesystem": false, @@ -1806,6 +1834,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "ExecutionRoleArn": { "Fn::GetAtt": [ "executionroleD9A39BE6", diff --git a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/manifest.json index 4d08217715b57..2dd614ef193fb 100644 --- a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/manifest.json @@ -231,6 +231,36 @@ "data": "batchspotcomputeenv2CE4DFD9" } ], + "/batch-stack/batch-demand-compute-env-launch-template-2/Resource-Security-Group/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "batchdemandcomputeenvlaunchtemplate2ResourceSecurityGroupBEA8DDD5" + } + ], + "/batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "batchdemandcomputeenvlaunchtemplate2EcsInstanceRoleEE146754" + } + ], + "/batch-stack/batch-demand-compute-env-launch-template-2/Instance-Profile": [ + { + "type": "aws:cdk:logicalId", + "data": "batchdemandcomputeenvlaunchtemplate2InstanceProfileC5A36CBC" + } + ], + "/batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "batchdemandcomputeenvlaunchtemplate2ResourceServiceInstanceRole41CADAC1" + } + ], + "/batch-stack/batch-demand-compute-env-launch-template-2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "batchdemandcomputeenvlaunchtemplate2E12D5CBC" + } + ], "/batch-stack/batch-job-queue/Resource": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/tree.json b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/tree.json index 5c7381ec38e8b..aeaca262c2d79 100644 --- a/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-batch/test/batch.integ.snapshot/tree.json @@ -1240,6 +1240,236 @@ "version": "0.0.0" } }, + "batch-demand-compute-env-launch-template-2": { + "id": "batch-demand-compute-env-launch-template-2", + "path": "batch-stack/batch-demand-compute-env-launch-template-2", + "children": { + "Resource-Security-Group": { + "id": "Resource-Security-Group", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Security-Group", + "children": { + "Resource": { + "id": "Resource", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Security-Group/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Security-Group", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "vpcId": { + "Ref": "vpcA2121C38" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "Ecs-Instance-Role": { + "id": "Ecs-Instance-Role", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role", + "children": { + "Resource": { + "id": "Resource", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Ecs-Instance-Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": { + "Fn::Join": [ + "", + [ + "ec2.", + { + "Ref": "AWS::URLSuffix" + } + ] + ] + } + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Instance-Profile": { + "id": "Instance-Profile", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Instance-Profile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "batchdemandcomputeenvlaunchtemplate2EcsInstanceRoleEE146754" + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource-Service-Instance-Role": { + "id": "Resource-Service-Instance-Role", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role", + "children": { + "Resource": { + "id": "Resource", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource-Service-Instance-Role/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "batch.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSBatchServiceRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "batch-stack/batch-demand-compute-env-launch-template-2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Batch::ComputeEnvironment", + "aws:cdk:cloudformation:props": { + "type": "MANAGED", + "computeResources": { + "launchTemplate": { + "launchTemplateId": { + "Ref": "ec2launchtemplate" + } + }, + "maxvCpus": 256, + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "batchdemandcomputeenvlaunchtemplate2ResourceSecurityGroupBEA8DDD5", + "GroupId" + ] + } + ], + "subnets": [ + { + "Ref": "vpcPrivateSubnet1Subnet934893E8" + }, + { + "Ref": "vpcPrivateSubnet2Subnet7031C2BA" + } + ], + "tags": { + "compute-env-tag": "123XYZ" + }, + "type": "EC2", + "allocationStrategy": "BEST_FIT", + "instanceRole": { + "Fn::GetAtt": [ + "batchdemandcomputeenvlaunchtemplate2InstanceProfileC5A36CBC", + "Arn" + ] + }, + "instanceTypes": [ + "optimal" + ], + "minvCpus": 0 + }, + "serviceRole": { + "Fn::GetAtt": [ + "batchdemandcomputeenvlaunchtemplate2ResourceServiceInstanceRole41CADAC1", + "Arn" + ] + }, + "state": "ENABLED" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-batch.CfnComputeEnvironment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-batch.ComputeEnvironment", + "version": "0.0.0" + } + }, "batch-job-queue": { "id": "batch-job-queue", "path": "batch-stack/batch-job-queue", @@ -1268,6 +1498,12 @@ "Ref": "batchspotcomputeenv2CE4DFD9" }, "order": 3 + }, + { + "computeEnvironment": { + "Ref": "batchdemandcomputeenvlaunchtemplate2E12D5CBC" + }, + "order": 4 } ], "priority": 1, @@ -1666,6 +1902,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "image": { "Fn::Join": [ "", @@ -1776,6 +2026,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "image": "docker/whalesay", "privileged": false, "readonlyRootFilesystem": false, @@ -1917,6 +2181,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "secrets": [ { "name": "SECRET", diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json new file mode 100644 index 0000000000000..d0312428b2cd1 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json @@ -0,0 +1,162 @@ +{ + "Resources": { + "AwsApiCallBatchdescribeJobDefinitions": { + "Type": "Custom::DeployAssert@SdkCallBatchdescribeJobDefinitions", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "service": "Batch", + "api": "describeJobDefinitions", + "parameters": { + "jobDefinitionName": "aws-batch-test" + }, + "flattenResponse": "true", + "salt": "1657836599834" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C": { + "Type": "Custom::DeployAssert@AssertEquals", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "actual": { + "Fn::GetAtt": [ + "AwsApiCallBatchdescribeJobDefinitions", + "apiCallResponse.jobDefinitions.0.containerProperties.environment" + ] + }, + "expected": "{\"$ArrayWith\":[{\"name\":\"AWS_REGION\",\"value\":\"\"}]}", + "salt": "1657836599835" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73": { + "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" + } + ], + "Policies": [ + { + "PolicyName": "Inline", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": [ + "batch:DescribeJobDefinitions" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + } + ] + } + } + ] + } + }, + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Runtime": "nodejs14.x", + "Code": { + "S3Bucket": { + "Ref": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4" + }, + "S3Key": { + "Fn::Join": [ + "", + [ + { + "Fn::Select": [ + 0, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6" + } + ] + } + ] + }, + { + "Fn::Select": [ + 1, + { + "Fn::Split": [ + "||", + { + "Ref": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6" + } + ] + } + ] + } + ] + ] + } + }, + "Timeout": 120, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73", + "Arn" + ] + } + } + } + }, + "Outputs": { + "AssertionResultsAssertEqualsBatchdescribeJobDefinitions": { + "Value": { + "Fn::GetAtt": [ + "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C", + "data" + ] + } + } + }, + "Parameters": { + "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4": { + "Type": "String", + "Description": "S3 bucket for asset \"ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3\"" + }, + "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6": { + "Type": "String", + "Description": "S3 key for asset version \"ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3\"" + }, + "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521": { + "Type": "String", + "Description": "Artifact hash for asset \"ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3\"" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json new file mode 100644 index 0000000000000..fc5efe0dadae9 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json @@ -0,0 +1,47 @@ +{ + "Resources": { + "batchC9C7DC44": { + "Type": "AWS::Batch::JobDefinition", + "Properties": { + "Type": "container", + "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], + "Image": "docker/whalesay", + "Privileged": false, + "ReadonlyRootFilesystem": false, + "ResourceRequirements": [ + { + "Type": "VCPU", + "Value": "1" + }, + { + "Type": "MEMORY", + "Value": "4" + } + ] + }, + "JobDefinitionName": "aws-batch-test", + "PlatformCapabilities": [ + "EC2" + ], + "RetryStrategy": { + "Attempts": 1 + }, + "Timeout": {} + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle/index.js b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle/index.js new file mode 100644 index 0000000000000..394eb62dcc75e --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle/index.js @@ -0,0 +1,620 @@ +var __create = Object.create; +var __defProp = Object.defineProperty; +var __defProps = Object.defineProperties; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropDescs = Object.getOwnPropertyDescriptors; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getOwnPropSymbols = Object.getOwnPropertySymbols; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __propIsEnum = Object.prototype.propertyIsEnumerable; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __spreadValues = (a, b) => { + for (var prop in b || (b = {})) + if (__hasOwnProp.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + if (__getOwnPropSymbols) + for (var prop of __getOwnPropSymbols(b)) { + if (__propIsEnum.call(b, prop)) + __defNormalProp(a, prop, b[prop]); + } + return a; +}; +var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// lib/assertions/providers/lambda-handler/index.ts +var lambda_handler_exports = {}; +__export(lambda_handler_exports, { + handler: () => handler +}); +module.exports = __toCommonJS(lambda_handler_exports); + +// ../assertions/lib/matcher.ts +var Matcher = class { + static isMatcher(x) { + return x && x instanceof Matcher; + } +}; +var MatchResult = class { + constructor(target) { + this.failures = []; + this.captures = /* @__PURE__ */ new Map(); + this.finalized = false; + this.target = target; + } + push(matcher, path, message) { + return this.recordFailure({ matcher, path, message }); + } + recordFailure(failure) { + this.failures.push(failure); + return this; + } + hasFailed() { + return this.failures.length !== 0; + } + get failCount() { + return this.failures.length; + } + compose(id, inner) { + const innerF = inner.failures; + this.failures.push(...innerF.map((f) => { + return { path: [id, ...f.path], message: f.message, matcher: f.matcher }; + })); + inner.captures.forEach((vals, capture) => { + vals.forEach((value) => this.recordCapture({ capture, value })); + }); + return this; + } + finished() { + if (this.finalized) { + return this; + } + if (this.failCount === 0) { + this.captures.forEach((vals, cap) => cap._captured.push(...vals)); + } + this.finalized = true; + return this; + } + toHumanStrings() { + return this.failures.map((r) => { + const loc = r.path.length === 0 ? "" : ` at ${r.path.join("")}`; + return "" + r.message + loc + ` (using ${r.matcher.name} matcher)`; + }); + } + recordCapture(options) { + let values = this.captures.get(options.capture); + if (values === void 0) { + values = []; + } + values.push(options.value); + this.captures.set(options.capture, values); + } +}; + +// ../assertions/lib/private/matchers/absent.ts +var AbsentMatch = class extends Matcher { + constructor(name) { + super(); + this.name = name; + } + test(actual) { + const result = new MatchResult(actual); + if (actual !== void 0) { + result.recordFailure({ + matcher: this, + path: [], + message: `Received ${actual}, but key should be absent` + }); + } + return result; + } +}; + +// ../assertions/lib/private/type.ts +function getType(obj) { + return Array.isArray(obj) ? "array" : typeof obj; +} + +// ../assertions/lib/match.ts +var Match = class { + static absent() { + return new AbsentMatch("absent"); + } + static arrayWith(pattern) { + return new ArrayMatch("arrayWith", pattern); + } + static arrayEquals(pattern) { + return new ArrayMatch("arrayEquals", pattern, { subsequence: false }); + } + static exact(pattern) { + return new LiteralMatch("exact", pattern, { partialObjects: false }); + } + static objectLike(pattern) { + return new ObjectMatch("objectLike", pattern); + } + static objectEquals(pattern) { + return new ObjectMatch("objectEquals", pattern, { partial: false }); + } + static not(pattern) { + return new NotMatch("not", pattern); + } + static serializedJson(pattern) { + return new SerializedJson("serializedJson", pattern); + } + static anyValue() { + return new AnyMatch("anyValue"); + } + static stringLikeRegexp(pattern) { + return new StringLikeRegexpMatch("stringLikeRegexp", pattern); + } +}; +var LiteralMatch = class extends Matcher { + constructor(name, pattern, options = {}) { + super(); + this.name = name; + this.pattern = pattern; + this.partialObjects = options.partialObjects ?? false; + if (Matcher.isMatcher(this.pattern)) { + throw new Error("LiteralMatch cannot directly contain another matcher. Remove the top-level matcher or nest it more deeply."); + } + } + test(actual) { + if (Array.isArray(this.pattern)) { + return new ArrayMatch(this.name, this.pattern, { subsequence: false, partialObjects: this.partialObjects }).test(actual); + } + if (typeof this.pattern === "object") { + return new ObjectMatch(this.name, this.pattern, { partial: this.partialObjects }).test(actual); + } + const result = new MatchResult(actual); + if (typeof this.pattern !== typeof actual) { + result.recordFailure({ + matcher: this, + path: [], + message: `Expected type ${typeof this.pattern} but received ${getType(actual)}` + }); + return result; + } + if (actual !== this.pattern) { + result.recordFailure({ + matcher: this, + path: [], + message: `Expected ${this.pattern} but received ${actual}` + }); + } + return result; + } +}; +var ArrayMatch = class extends Matcher { + constructor(name, pattern, options = {}) { + super(); + this.name = name; + this.pattern = pattern; + this.subsequence = options.subsequence ?? true; + this.partialObjects = options.partialObjects ?? false; + } + test(actual) { + if (!Array.isArray(actual)) { + return new MatchResult(actual).recordFailure({ + matcher: this, + path: [], + message: `Expected type array but received ${getType(actual)}` + }); + } + if (!this.subsequence && this.pattern.length !== actual.length) { + return new MatchResult(actual).recordFailure({ + matcher: this, + path: [], + message: `Expected array of length ${this.pattern.length} but received ${actual.length}` + }); + } + let patternIdx = 0; + let actualIdx = 0; + const result = new MatchResult(actual); + while (patternIdx < this.pattern.length && actualIdx < actual.length) { + const patternElement = this.pattern[patternIdx]; + const matcher = Matcher.isMatcher(patternElement) ? patternElement : new LiteralMatch(this.name, patternElement, { partialObjects: this.partialObjects }); + const matcherName = matcher.name; + if (this.subsequence && (matcherName == "absent" || matcherName == "anyValue")) { + throw new Error(`The Matcher ${matcherName}() cannot be nested within arrayWith()`); + } + const innerResult = matcher.test(actual[actualIdx]); + if (!this.subsequence || !innerResult.hasFailed()) { + result.compose(`[${actualIdx}]`, innerResult); + patternIdx++; + actualIdx++; + } else { + actualIdx++; + } + } + for (; patternIdx < this.pattern.length; patternIdx++) { + const pattern = this.pattern[patternIdx]; + const element = Matcher.isMatcher(pattern) || typeof pattern === "object" ? " " : ` [${pattern}] `; + result.recordFailure({ + matcher: this, + path: [], + message: `Missing element${element}at pattern index ${patternIdx}` + }); + } + return result; + } +}; +var ObjectMatch = class extends Matcher { + constructor(name, pattern, options = {}) { + super(); + this.name = name; + this.pattern = pattern; + this.partial = options.partial ?? true; + } + test(actual) { + if (typeof actual !== "object" || Array.isArray(actual)) { + return new MatchResult(actual).recordFailure({ + matcher: this, + path: [], + message: `Expected type object but received ${getType(actual)}` + }); + } + const result = new MatchResult(actual); + if (!this.partial) { + for (const a of Object.keys(actual)) { + if (!(a in this.pattern)) { + result.recordFailure({ + matcher: this, + path: [`/${a}`], + message: "Unexpected key" + }); + } + } + } + for (const [patternKey, patternVal] of Object.entries(this.pattern)) { + if (!(patternKey in actual) && !(patternVal instanceof AbsentMatch)) { + result.recordFailure({ + matcher: this, + path: [`/${patternKey}`], + message: `Missing key '${patternKey}' among {${Object.keys(actual).join(",")}}` + }); + continue; + } + const matcher = Matcher.isMatcher(patternVal) ? patternVal : new LiteralMatch(this.name, patternVal, { partialObjects: this.partial }); + const inner = matcher.test(actual[patternKey]); + result.compose(`/${patternKey}`, inner); + } + return result; + } +}; +var SerializedJson = class extends Matcher { + constructor(name, pattern) { + super(); + this.name = name; + this.pattern = pattern; + } + test(actual) { + const result = new MatchResult(actual); + if (getType(actual) !== "string") { + result.recordFailure({ + matcher: this, + path: [], + message: `Expected JSON as a string but found ${getType(actual)}` + }); + return result; + } + let parsed; + try { + parsed = JSON.parse(actual); + } catch (err) { + if (err instanceof SyntaxError) { + result.recordFailure({ + matcher: this, + path: [], + message: `Invalid JSON string: ${actual}` + }); + return result; + } else { + throw err; + } + } + const matcher = Matcher.isMatcher(this.pattern) ? this.pattern : new LiteralMatch(this.name, this.pattern); + const innerResult = matcher.test(parsed); + result.compose(`(${this.name})`, innerResult); + return result; + } +}; +var NotMatch = class extends Matcher { + constructor(name, pattern) { + super(); + this.name = name; + this.pattern = pattern; + } + test(actual) { + const matcher = Matcher.isMatcher(this.pattern) ? this.pattern : new LiteralMatch(this.name, this.pattern); + const innerResult = matcher.test(actual); + const result = new MatchResult(actual); + if (innerResult.failCount === 0) { + result.recordFailure({ + matcher: this, + path: [], + message: `Found unexpected match: ${JSON.stringify(actual, void 0, 2)}` + }); + } + return result; + } +}; +var AnyMatch = class extends Matcher { + constructor(name) { + super(); + this.name = name; + } + test(actual) { + const result = new MatchResult(actual); + if (actual == null) { + result.recordFailure({ + matcher: this, + path: [], + message: "Expected a value but found none" + }); + } + return result; + } +}; +var StringLikeRegexpMatch = class extends Matcher { + constructor(name, pattern) { + super(); + this.name = name; + this.pattern = pattern; + } + test(actual) { + const result = new MatchResult(actual); + const regex = new RegExp(this.pattern, "gm"); + if (typeof actual !== "string") { + result.recordFailure({ + matcher: this, + path: [], + message: `Expected a string, but got '${typeof actual}'` + }); + } + if (!regex.test(actual)) { + result.recordFailure({ + matcher: this, + path: [], + message: `String '${actual}' did not match pattern '${this.pattern}'` + }); + } + return result; + } +}; + +// lib/assertions/providers/lambda-handler/base.ts +var https = __toESM(require("https")); +var url = __toESM(require("url")); +var CustomResourceHandler = class { + constructor(event, context) { + this.event = event; + this.context = context; + this.timedOut = false; + this.timeout = setTimeout(async () => { + await this.respond({ + status: "FAILED", + reason: "Lambda Function Timeout", + data: this.context.logStreamName + }); + this.timedOut = true; + }, context.getRemainingTimeInMillis() - 1200); + this.event = event; + this.physicalResourceId = extractPhysicalResourceId(event); + } + async handle() { + try { + console.log(`Event: ${JSON.stringify(__spreadProps(__spreadValues({}, this.event), { ResponseURL: "..." }))}`); + const response = await this.processEvent(this.event.ResourceProperties); + console.log(`Event output : ${JSON.stringify(response)}`); + await this.respond({ + status: "SUCCESS", + reason: "OK", + data: response + }); + } catch (e) { + console.log(e); + await this.respond({ + status: "FAILED", + reason: e.message ?? "Internal Error" + }); + } finally { + clearTimeout(this.timeout); + } + } + respond(response) { + if (this.timedOut) { + return; + } + const cfResponse = { + Status: response.status, + Reason: response.reason, + PhysicalResourceId: this.physicalResourceId, + StackId: this.event.StackId, + RequestId: this.event.RequestId, + LogicalResourceId: this.event.LogicalResourceId, + NoEcho: false, + Data: response.data + }; + const responseBody = JSON.stringify(cfResponse); + console.log("Responding to CloudFormation", responseBody); + const parsedUrl = url.parse(this.event.ResponseURL); + const requestOptions = { + hostname: parsedUrl.hostname, + path: parsedUrl.path, + method: "PUT", + headers: { "content-type": "", "content-length": responseBody.length } + }; + return new Promise((resolve, reject) => { + try { + const request2 = https.request(requestOptions, resolve); + request2.on("error", reject); + request2.write(responseBody); + request2.end(); + } catch (e) { + reject(e); + } + }); + } +}; +function extractPhysicalResourceId(event) { + switch (event.RequestType) { + case "Create": + return event.LogicalResourceId; + case "Update": + case "Delete": + return event.PhysicalResourceId; + } +} + +// lib/assertions/providers/lambda-handler/assertion.ts +var AssertionHandler = class extends CustomResourceHandler { + async processEvent(request2) { + let actual = decodeCall(request2.actual); + const expected = decodeCall(request2.expected); + let result; + const matcher = new MatchCreator(expected).getMatcher(); + console.log(`Testing equality between ${JSON.stringify(request2.actual)} and ${JSON.stringify(request2.expected)}`); + const matchResult = matcher.test(actual); + matchResult.finished(); + if (matchResult.hasFailed()) { + result = { + data: JSON.stringify({ + status: "fail", + message: [ + ...matchResult.toHumanStrings(), + JSON.stringify(matchResult.target, void 0, 2) + ].join("\n") + }) + }; + if (request2.failDeployment) { + throw new Error(result.data); + } + } else { + result = { + data: JSON.stringify({ + status: "pass" + }) + }; + } + return result; + } +}; +var MatchCreator = class { + constructor(obj) { + this.parsedObj = { + matcher: obj + }; + } + getMatcher() { + try { + const final = JSON.parse(JSON.stringify(this.parsedObj), function(_k, v) { + const nested = Object.keys(v)[0]; + switch (nested) { + case "$ArrayWith": + return Match.arrayWith(v[nested]); + case "$ObjectLike": + return Match.objectLike(v[nested]); + case "$StringLike": + return Match.stringLikeRegexp(v[nested]); + default: + return v; + } + }); + if (Matcher.isMatcher(final.matcher)) { + return final.matcher; + } + return Match.exact(final.matcher); + } catch { + return Match.exact(this.parsedObj.matcher); + } + } +}; +function decodeCall(call) { + if (!call) { + return void 0; + } + try { + const parsed = JSON.parse(call); + return parsed; + } catch (e) { + return call; + } +} + +// lib/assertions/providers/lambda-handler/utils.ts +function decode(object) { + return JSON.parse(JSON.stringify(object), (_k, v) => { + switch (v) { + case "TRUE:BOOLEAN": + return true; + case "FALSE:BOOLEAN": + return false; + default: + return v; + } + }); +} + +// lib/assertions/providers/lambda-handler/sdk.ts +function flatten(object) { + return Object.assign({}, ...function _flatten(child, path = []) { + return [].concat(...Object.keys(child).map((key) => { + const childKey = Buffer.isBuffer(child[key]) ? child[key].toString("utf8") : child[key]; + return typeof childKey === "object" && childKey !== null ? _flatten(childKey, path.concat([key])) : { [path.concat([key]).join(".")]: childKey }; + })); + }(object)); +} +var AwsApiCallHandler = class extends CustomResourceHandler { + async processEvent(request2) { + const AWS = require("aws-sdk"); + console.log(`AWS SDK VERSION: ${AWS.VERSION}`); + const service = new AWS[request2.service](); + const response = await service[request2.api](request2.parameters && decode(request2.parameters)).promise(); + console.log(`SDK response received ${JSON.stringify(response)}`); + delete response.ResponseMetadata; + const respond = { + apiCallResponse: response + }; + const flatData = __spreadValues({}, flatten(respond)); + return request2.flattenResponse === "true" ? flatData : respond; + } +}; + +// lib/assertions/providers/lambda-handler/types.ts +var ASSERT_RESOURCE_TYPE = "Custom::DeployAssert@AssertEquals"; +var SDK_RESOURCE_TYPE_PREFIX = "Custom::DeployAssert@SdkCall"; + +// lib/assertions/providers/lambda-handler/index.ts +async function handler(event, context) { + const provider = createResourceHandler(event, context); + await provider.handle(); +} +function createResourceHandler(event, context) { + if (event.ResourceType.startsWith(SDK_RESOURCE_TYPE_PREFIX)) { + return new AwsApiCallHandler(event, context); + } + switch (event.ResourceType) { + case ASSERT_RESOURCE_TYPE: + return new AssertionHandler(event, context); + default: + throw new Error(`Unsupported resource type "${event.ResourceType}`); + } +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + handler +}); diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/cdk.out new file mode 100644 index 0000000000000..588d7b269d34f --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json new file mode 100644 index 0000000000000..5a0b0f4ee87ac --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json @@ -0,0 +1,11 @@ +{ + "version": "20.0.0", + "testCases": { + "IntegTest-aws-batch-default-env-variables/DefaultTest": { + "stacks": [ + "SampleStack-aws-batch-default-env-variables" + ], + "assertionStack": "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json new file mode 100644 index 0000000000000..5a1a8403c7312 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json @@ -0,0 +1,101 @@ +{ + "version": "20.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, + "SampleStack-aws-batch-default-env-variables": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "SampleStack-aws-batch-default-env-variables.template.json", + "validateOnSynth": false + }, + "metadata": { + "/SampleStack-aws-batch-default-env-variables/batch/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "batchC9C7DC44" + } + ] + }, + "displayName": "SampleStack-aws-batch-default-env-variables" + }, + "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json", + "validateOnSynth": false + }, + "metadata": { + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert": [ + { + "type": "aws:cdk:asset", + "data": { + "path": "asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle", + "id": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "packaging": "zip", + "sourceHash": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "s3BucketParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4", + "s3KeyParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6", + "artifactHashParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521" + } + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallBatchdescribeJobDefinitions" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsAssertEqualsBatchdescribeJobDefinitions" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6" + } + ], + "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521" + } + ] + }, + "displayName": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json new file mode 100644 index 0000000000000..790ba10fbaed4 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json @@ -0,0 +1,324 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + }, + "SampleStack-aws-batch-default-env-variables": { + "id": "SampleStack-aws-batch-default-env-variables", + "path": "SampleStack-aws-batch-default-env-variables", + "children": { + "batch": { + "id": "batch", + "path": "SampleStack-aws-batch-default-env-variables/batch", + "children": { + "Resource-Batch-Task-Definition-Role": { + "id": "Resource-Batch-Task-Definition-Role", + "path": "SampleStack-aws-batch-default-env-variables/batch/Resource-Batch-Task-Definition-Role", + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.LazyRole", + "version": "0.0.0" + } + }, + "Resource-Batch-Job-Container-Definition": { + "id": "Resource-Batch-Job-Container-Definition", + "path": "SampleStack-aws-batch-default-env-variables/batch/Resource-Batch-Job-Container-Definition", + "constructInfo": { + "fqn": "@aws-cdk/aws-ecs.ContainerDefinition", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "SampleStack-aws-batch-default-env-variables/batch/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Batch::JobDefinition", + "aws:cdk:cloudformation:props": { + "type": "container", + "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], + "image": "docker/whalesay", + "privileged": false, + "readonlyRootFilesystem": false, + "resourceRequirements": [ + { + "type": "VCPU", + "value": "1" + }, + { + "type": "MEMORY", + "value": "4" + } + ] + }, + "jobDefinitionName": "aws-batch-test", + "platformCapabilities": [ + "EC2" + ], + "retryStrategy": { + "attempts": 1 + }, + "timeout": {} + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-batch.CfnJobDefinition", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-batch.JobDefinition", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "IntegTest-aws-batch-default-env-variables": { + "id": "IntegTest-aws-batch-default-env-variables", + "path": "IntegTest-aws-batch-default-env-variables", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert", + "children": { + "AwsApiCallBatchdescribeJobDefinitions": { + "id": "AwsApiCallBatchdescribeJobDefinitions", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.CustomResource", + "version": "0.0.0" + } + }, + "AssertEqualsBatchdescribeJobDefinitions": { + "id": "AssertEqualsBatchdescribeJobDefinitions", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions", + "children": { + "AssertionProvider": { + "id": "AssertionProvider", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.EqualsAssertion", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.AwsApiCall", + "version": "0.0.0" + } + }, + "SingletonFunction1488541a7b23466481b69b4408076b81": { + "id": "SingletonFunction1488541a7b23466481b69b4408076b81", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81", + "children": { + "Staging": { + "id": "Staging", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Staging", + "constructInfo": { + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" + } + }, + "Role": { + "id": "Role", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + }, + "Handler": { + "id": "Handler", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + }, + "AssetParameters": { + "id": "AssetParameters", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters", + "children": { + "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3": { + "id": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "children": { + "S3Bucket": { + "id": "S3Bucket", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "S3VersionKey": { + "id": "S3VersionKey", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "ArtifactHash": { + "id": "ArtifactHash", + "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + } + }, + "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": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file From 66dc657e2b84f92c1eb368da20c3d8477b33389f Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Fri, 15 Jul 2022 01:11:24 +0300 Subject: [PATCH 13/17] chore: Update integration test snapshots --- packages/@aws-cdk/aws-batch/test/integ.job-definition.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts index 5a9607dfc59e1..4496da88df34b 100644 --- a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts +++ b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts @@ -33,7 +33,7 @@ const awsApiCallResponse = integ.assertions.awsApiCall( "describeJobDefinitions", { jobDefinitionName, - } + }, ); awsApiCallResponse.assertAtPath( @@ -43,7 +43,7 @@ awsApiCallResponse.assertAtPath( name: "AWS_REGION", value: "", }, - ]) + ]), ); app.synth(); From 85fd70abe4a60c64f8a26734e18d268a40426368 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 19 Jul 2022 01:31:51 +0300 Subject: [PATCH 14/17] chore: Update integration test snapshots --- .../aws-batch/test/integ.job-definition.ts | 51 +++++------- ...=> BatchDefaultEnvVarsStack.template.json} | 11 +-- ...ultTestDeployAssertC15EFFF2.template.json} | 10 +-- .../job-definition.integ.snapshot/integ.json | 9 ++- .../manifest.json | 36 ++++----- .../job-definition.integ.snapshot/tree.json | 79 +++++++++---------- 6 files changed, 90 insertions(+), 106 deletions(-) rename packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/{SampleStack-aws-batch-default-env-variables.template.json => BatchDefaultEnvVarsStack.template.json} (78%) rename packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/{IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json => IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json} (95%) diff --git a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts index 4496da88df34b..a2eef5e103edc 100644 --- a/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts +++ b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts @@ -2,48 +2,39 @@ import { ContainerImage } from "@aws-cdk/aws-ecs"; import { App, Stack } from "@aws-cdk/core"; import { ExpectedResult, IntegTest } from "@aws-cdk/integ-tests"; -import { Construct } from "constructs"; import { JobDefinition } from "../lib"; -const jobDefinitionName = "aws-batch-test"; - -class SampleStack extends Stack { - constructor(scope: Construct, id: string) { - super(scope, id); +const app = new App(); - new JobDefinition(this, "batch", { - jobDefinitionName, - container: { - image: ContainerImage.fromRegistry("docker/whalesay"), - }, - }); - } -} +const stack = new Stack(app, "BatchDefaultEnvVarsStack", { + env: { + account: process.env.CDK_DEFAULT_ACCOUNT, + region: process.env.CDK_DEFAULT_REGION, + }, +}); -// Beginning of the test suite -const app = new App(); +new JobDefinition(stack, "JobDefinition", { + container: { + image: ContainerImage.fromRegistry("docker/whalesay"), + }, +}); -const integ = new IntegTest(app, "IntegTest-aws-batch-default-env-variables", { - testCases: [ - new SampleStack(app, "SampleStack-aws-batch-default-env-variables"), - ], +const integ = new IntegTest(app, "IntegTest-BatchDefaultEnvVarsStack", { + testCases: [stack], + regions: ["us-east-1"], }); -const awsApiCallResponse = integ.assertions.awsApiCall( + +const awsApiCallDescribeJobDefinition = integ.assertions.awsApiCall( "Batch", "describeJobDefinitions", { - jobDefinitionName, + status: "ACTIVE", }, ); -awsApiCallResponse.assertAtPath( - "jobDefinitions.0.containerProperties.environment", - ExpectedResult.arrayWith([ - { - name: "AWS_REGION", - value: "", - }, - ]), +awsApiCallDescribeJobDefinition.assertAtPath( + "jobDefinitions.0.containerProperties.environment.0.name", + ExpectedResult.stringLikeRegexp('AWS_REGION'), ); app.synth(); diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json similarity index 78% rename from packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json rename to packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json index fc5efe0dadae9..6f3c1a085a4f7 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/SampleStack-aws-batch-default-env-variables.template.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json @@ -1,6 +1,6 @@ { "Resources": { - "batchC9C7DC44": { + "JobDefinition24FFE3ED": { "Type": "AWS::Batch::JobDefinition", "Properties": { "Type": "container", @@ -8,15 +8,11 @@ "Environment": [ { "Name": "AWS_REGION", - "Value": { - "Ref": "AWS::Region" - } + "Value": "us-east-1" }, { "Name": "AWS_ACCOUNT", - "Value": { - "Ref": "AWS::AccountId" - } + "Value": "347315207830" } ], "Image": "docker/whalesay", @@ -33,7 +29,6 @@ } ] }, - "JobDefinitionName": "aws-batch-test", "PlatformCapabilities": [ "EC2" ], diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json similarity index 95% rename from packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json rename to packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json index d0312428b2cd1..f2573075a37ae 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json @@ -12,10 +12,10 @@ "service": "Batch", "api": "describeJobDefinitions", "parameters": { - "jobDefinitionName": "aws-batch-test" + "status": "ACTIVE" }, "flattenResponse": "true", - "salt": "1657836599834" + "salt": "1658183315795" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -32,11 +32,11 @@ "actual": { "Fn::GetAtt": [ "AwsApiCallBatchdescribeJobDefinitions", - "apiCallResponse.jobDefinitions.0.containerProperties.environment" + "apiCallResponse.jobDefinitions.0.containerProperties.environment.0.name" ] }, - "expected": "{\"$ArrayWith\":[{\"name\":\"AWS_REGION\",\"value\":\"\"}]}", - "salt": "1657836599835" + "expected": "{\"$StringLike\":\"AWS_REGION\"}", + "salt": "1658183315795" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json index 5a0b0f4ee87ac..f5356f44b77e0 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json @@ -1,11 +1,14 @@ { "version": "20.0.0", "testCases": { - "IntegTest-aws-batch-default-env-variables/DefaultTest": { + "IntegTest-BatchDefaultEnvVarsStack/DefaultTest": { "stacks": [ - "SampleStack-aws-batch-default-env-variables" + "BatchDefaultEnvVarsStack" ], - "assertionStack": "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566" + "regions": [ + "us-east-1" + ], + "assertionStack": "IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json index 5a1a8403c7312..866278ef905de 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/manifest.json @@ -7,32 +7,32 @@ "file": "tree.json" } }, - "SampleStack-aws-batch-default-env-variables": { + "BatchDefaultEnvVarsStack": { "type": "aws:cloudformation:stack", - "environment": "aws://unknown-account/unknown-region", + "environment": "aws://347315207830/us-east-1", "properties": { - "templateFile": "SampleStack-aws-batch-default-env-variables.template.json", + "templateFile": "BatchDefaultEnvVarsStack.template.json", "validateOnSynth": false }, "metadata": { - "/SampleStack-aws-batch-default-env-variables/batch/Resource": [ + "/BatchDefaultEnvVarsStack/JobDefinition/Resource": [ { "type": "aws:cdk:logicalId", - "data": "batchC9C7DC44" + "data": "JobDefinition24FFE3ED" } ] }, - "displayName": "SampleStack-aws-batch-default-env-variables" + "displayName": "BatchDefaultEnvVarsStack" }, - "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566": { + "IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2": { "type": "aws:cloudformation:stack", "environment": "aws://unknown-account/unknown-region", "properties": { - "templateFile": "IntegTestawsbatchdefaultenvvariablesDefaultTestDeployAssert58502566.template.json", + "templateFile": "IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json", "validateOnSynth": false }, "metadata": { - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert": [ { "type": "aws:cdk:asset", "data": { @@ -46,56 +46,56 @@ } } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default": [ { "type": "aws:cdk:logicalId", "data": "AwsApiCallBatchdescribeJobDefinitions" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default": [ { "type": "aws:cdk:logicalId", "data": "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults": [ { "type": "aws:cdk:logicalId", "data": "AssertionResultsAssertEqualsBatchdescribeJobDefinitions" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ { "type": "aws:cdk:logicalId", "data": "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler": [ { "type": "aws:cdk:logicalId", "data": "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket": [ { "type": "aws:cdk:logicalId", "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey": [ { "type": "aws:cdk:logicalId", "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6" } ], - "/IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash": [ + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash": [ { "type": "aws:cdk:logicalId", "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521" } ] }, - "displayName": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert" + "displayName": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert" } } } \ No newline at end of file diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json index 790ba10fbaed4..2b77ee40fa90f 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json @@ -12,17 +12,17 @@ "version": "10.1.33" } }, - "SampleStack-aws-batch-default-env-variables": { - "id": "SampleStack-aws-batch-default-env-variables", - "path": "SampleStack-aws-batch-default-env-variables", + "BatchDefaultEnvVarsStack": { + "id": "BatchDefaultEnvVarsStack", + "path": "BatchDefaultEnvVarsStack", "children": { - "batch": { - "id": "batch", - "path": "SampleStack-aws-batch-default-env-variables/batch", + "JobDefinition": { + "id": "JobDefinition", + "path": "BatchDefaultEnvVarsStack/JobDefinition", "children": { "Resource-Batch-Task-Definition-Role": { "id": "Resource-Batch-Task-Definition-Role", - "path": "SampleStack-aws-batch-default-env-variables/batch/Resource-Batch-Task-Definition-Role", + "path": "BatchDefaultEnvVarsStack/JobDefinition/Resource-Batch-Task-Definition-Role", "constructInfo": { "fqn": "@aws-cdk/aws-iam.LazyRole", "version": "0.0.0" @@ -30,7 +30,7 @@ }, "Resource-Batch-Job-Container-Definition": { "id": "Resource-Batch-Job-Container-Definition", - "path": "SampleStack-aws-batch-default-env-variables/batch/Resource-Batch-Job-Container-Definition", + "path": "BatchDefaultEnvVarsStack/JobDefinition/Resource-Batch-Job-Container-Definition", "constructInfo": { "fqn": "@aws-cdk/aws-ecs.ContainerDefinition", "version": "0.0.0" @@ -38,7 +38,7 @@ }, "Resource": { "id": "Resource", - "path": "SampleStack-aws-batch-default-env-variables/batch/Resource", + "path": "BatchDefaultEnvVarsStack/JobDefinition/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Batch::JobDefinition", "aws:cdk:cloudformation:props": { @@ -47,15 +47,11 @@ "environment": [ { "name": "AWS_REGION", - "value": { - "Ref": "AWS::Region" - } + "value": "us-east-1" }, { "name": "AWS_ACCOUNT", - "value": { - "Ref": "AWS::AccountId" - } + "value": "347315207830" } ], "image": "docker/whalesay", @@ -72,7 +68,6 @@ } ] }, - "jobDefinitionName": "aws-batch-test", "platformCapabilities": [ "EC2" ], @@ -99,17 +94,17 @@ "version": "0.0.0" } }, - "IntegTest-aws-batch-default-env-variables": { - "id": "IntegTest-aws-batch-default-env-variables", - "path": "IntegTest-aws-batch-default-env-variables", + "IntegTest-BatchDefaultEnvVarsStack": { + "id": "IntegTest-BatchDefaultEnvVarsStack", + "path": "IntegTest-BatchDefaultEnvVarsStack", "children": { "DefaultTest": { "id": "DefaultTest", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest", "children": { "Default": { "id": "Default", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", "version": "10.1.33" @@ -117,19 +112,19 @@ }, "DeployAssert": { "id": "DeployAssert", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert", "children": { "AwsApiCallBatchdescribeJobDefinitions": { "id": "AwsApiCallBatchdescribeJobDefinitions", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions", "children": { "SdkProvider": { "id": "SdkProvider", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider", "children": { "AssertionsProvider": { "id": "AssertionsProvider", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider/AssertionsProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", "version": "10.1.33" @@ -143,11 +138,11 @@ }, "Default": { "id": "Default", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default", "children": { "Default": { "id": "Default", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default", "constructInfo": { "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" @@ -161,15 +156,15 @@ }, "AssertEqualsBatchdescribeJobDefinitions": { "id": "AssertEqualsBatchdescribeJobDefinitions", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions", "children": { "AssertionProvider": { "id": "AssertionProvider", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider", "children": { "AssertionsProvider": { "id": "AssertionsProvider", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider/AssertionsProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", "version": "10.1.33" @@ -183,11 +178,11 @@ }, "Default": { "id": "Default", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default", "children": { "Default": { "id": "Default", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default", "constructInfo": { "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" @@ -201,7 +196,7 @@ }, "AssertionResults": { "id": "AssertionResults", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults", "constructInfo": { "fqn": "@aws-cdk/core.CfnOutput", "version": "0.0.0" @@ -221,11 +216,11 @@ }, "SingletonFunction1488541a7b23466481b69b4408076b81": { "id": "SingletonFunction1488541a7b23466481b69b4408076b81", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81", "children": { "Staging": { "id": "Staging", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Staging", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Staging", "constructInfo": { "fqn": "@aws-cdk/core.AssetStaging", "version": "0.0.0" @@ -233,7 +228,7 @@ }, "Role": { "id": "Role", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role", "constructInfo": { "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" @@ -241,7 +236,7 @@ }, "Handler": { "id": "Handler", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler", "constructInfo": { "fqn": "@aws-cdk/core.CfnResource", "version": "0.0.0" @@ -255,15 +250,15 @@ }, "AssetParameters": { "id": "AssetParameters", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters", "children": { "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3": { "id": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", "children": { "S3Bucket": { "id": "S3Bucket", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket", "constructInfo": { "fqn": "@aws-cdk/core.CfnParameter", "version": "0.0.0" @@ -271,7 +266,7 @@ }, "S3VersionKey": { "id": "S3VersionKey", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey", "constructInfo": { "fqn": "@aws-cdk/core.CfnParameter", "version": "0.0.0" @@ -279,7 +274,7 @@ }, "ArtifactHash": { "id": "ArtifactHash", - "path": "IntegTest-aws-batch-default-env-variables/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash", "constructInfo": { "fqn": "@aws-cdk/core.CfnParameter", "version": "0.0.0" From 752defa28f379541ea937beb736887dc7db00aa4 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 19 Jul 2022 01:49:04 +0300 Subject: [PATCH 15/17] chore: Update integration test snapshot of deps --- .../batch-events.assets.json | 19 +++++++++++++++++++ .../batch-events.template.json | 14 ++++++++++++++ .../cdk.out | 2 +- .../manifest.json | 2 +- .../tree.json | 18 ++++++++++++++++-- 5 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.assets.json diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.assets.json b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.assets.json new file mode 100644 index 0000000000000..ff1a9a344196e --- /dev/null +++ b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.assets.json @@ -0,0 +1,19 @@ +{ + "version": "20.0.0", + "files": { + "f4536a01069bddec46bab47fc02dee0ac63696068a6b96a7520dbf9bc48535f3": { + "source": { + "path": "batch-events.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "f4536a01069bddec46bab47fc02dee0ac63696068a6b96a7520dbf9bc48535f3.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-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.template.json b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.template.json index 441cb6a1c878a..cdc064ac9b534 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.template.json +++ b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/batch-events.template.json @@ -64,6 +64,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "Image": "test-repo", "Privileged": false, "ReadonlyRootFilesystem": false, diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/cdk.out index 90bef2e09ad39..588d7b269d34f 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/cdk.out @@ -1 +1 @@ -{"version":"17.0.0"} \ No newline at end of file +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/manifest.json index 5d039a1ae6227..d766e0f6089d8 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "17.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/tree.json b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/tree.json index 090b609a4712c..a9d653c6627a6 100644 --- a/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-events-targets/test/batch/job-definition-events.integ.snapshot/tree.json @@ -8,8 +8,8 @@ "id": "Tree", "path": "Tree", "constructInfo": { - "fqn": "@aws-cdk/core.Construct", - "version": "0.0.0" + "fqn": "constructs.Construct", + "version": "10.1.33" } }, "batch-events": { @@ -157,6 +157,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "image": "test-repo", "privileged": false, "readonlyRootFilesystem": false, From 963aa6ea8ffff12284360cabc323948aae04b428 Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 19 Jul 2022 09:39:05 +0300 Subject: [PATCH 16/17] chore: Update integration test snapshots --- .../BatchDefaultEnvVarsStack.template.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json index 6f3c1a085a4f7..dcb6d09b0f981 100644 --- a/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json @@ -8,11 +8,15 @@ "Environment": [ { "Name": "AWS_REGION", - "Value": "us-east-1" + "Value": { + "Ref": "AWS::Region" + } }, { "Name": "AWS_ACCOUNT", - "Value": "347315207830" + "Value": { + "Ref": "AWS::AccountId" + } } ], "Image": "docker/whalesay", From 2a025ddfa6cc7f0c2a88c139e3a140f79e52682e Mon Sep 17 00:00:00 2001 From: Dzhuneyt Date: Tue, 19 Jul 2022 20:34:37 +0000 Subject: [PATCH 17/17] chore: Update integration test snapshots --- .../aws-stepfunctions-integ.assets.json | 6 +++--- .../aws-stepfunctions-integ.template.json | 14 ++++++++++++++ .../batch/run-batch-job.integ.snapshot/cdk.out | 2 +- .../run-batch-job.integ.snapshot/manifest.json | 2 +- .../batch/run-batch-job.integ.snapshot/tree.json | 16 +++++++++++++++- .../aws-stepfunctions-integ.assets.json | 6 +++--- .../aws-stepfunctions-integ.template.json | 14 ++++++++++++++ .../test/batch/submit-job.integ.snapshot/cdk.out | 2 +- .../submit-job.integ.snapshot/manifest.json | 2 +- .../batch/submit-job.integ.snapshot/tree.json | 16 +++++++++++++++- 10 files changed, 68 insertions(+), 12 deletions(-) diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.assets.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.assets.json index 994ee193b2fc5..7e6900b2072db 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.assets.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.assets.json @@ -1,7 +1,7 @@ { - "version": "17.0.0", + "version": "20.0.0", "files": { - "66edc47915d0cc45b87006321dee167c74c12916123ab1d182b8538d5cad65b4": { + "86037fde601461f919a77ac4009206c4806383c850982f0446726e6550bd3b48": { "source": { "path": "aws-stepfunctions-integ.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "66edc47915d0cc45b87006321dee167c74c12916123ab1d182b8538d5cad65b4.json", + "objectKey": "86037fde601461f919a77ac4009206c4806383c850982f0446726e6550bd3b48.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-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.template.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.template.json index 29dfe0e44351e..3891d5cb8d413 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.template.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/aws-stepfunctions-integ.template.json @@ -670,6 +670,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "Image": { "Fn::Join": [ "", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/cdk.out index 90bef2e09ad39..588d7b269d34f 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/cdk.out @@ -1 +1 @@ -{"version":"17.0.0"} \ No newline at end of file +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/manifest.json index b941ff085130a..b4e417184a400 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "17.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/tree.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/tree.json index 8f4e25656ffd8..9f59d8a93df87 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/run-batch-job.integ.snapshot/tree.json @@ -9,7 +9,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.0.9" + "version": "10.1.49" } }, "aws-stepfunctions-integ": { @@ -996,6 +996,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "image": { "Fn::Join": [ "", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.assets.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.assets.json index a5031039bb361..3230b897865d1 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.assets.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.assets.json @@ -1,7 +1,7 @@ { - "version": "17.0.0", + "version": "20.0.0", "files": { - "f8de7132a9fb75eb1f342dc4dff2ec7de734f7d98caea351f9bba34a5c6c2cb2": { + "b27585131525b14438a70cc9cdc12a1a620b7b567152cac7eec0d511b479b699": { "source": { "path": "aws-stepfunctions-integ.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "f8de7132a9fb75eb1f342dc4dff2ec7de734f7d98caea351f9bba34a5c6c2cb2.json", + "objectKey": "b27585131525b14438a70cc9cdc12a1a620b7b567152cac7eec0d511b479b699.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-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.template.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.template.json index a128bfd730c3b..c9d7331340cab 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.template.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/aws-stepfunctions-integ.template.json @@ -670,6 +670,20 @@ "Properties": { "Type": "container", "ContainerProperties": { + "Environment": [ + { + "Name": "AWS_REGION", + "Value": { + "Ref": "AWS::Region" + } + }, + { + "Name": "AWS_ACCOUNT", + "Value": { + "Ref": "AWS::AccountId" + } + } + ], "Image": { "Fn::Join": [ "", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/cdk.out index 90bef2e09ad39..588d7b269d34f 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/cdk.out +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/cdk.out @@ -1 +1 @@ -{"version":"17.0.0"} \ No newline at end of file +{"version":"20.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/manifest.json index b941ff085130a..b4e417184a400 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/manifest.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "17.0.0", + "version": "20.0.0", "artifacts": { "Tree": { "type": "cdk:tree", diff --git a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/tree.json b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/tree.json index bfad38b4b7b86..99d693f757c8b 100644 --- a/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/tree.json +++ b/packages/@aws-cdk/aws-stepfunctions-tasks/test/batch/submit-job.integ.snapshot/tree.json @@ -9,7 +9,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.0.9" + "version": "10.1.49" } }, "aws-stepfunctions-integ": { @@ -996,6 +996,20 @@ "aws:cdk:cloudformation:props": { "type": "container", "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": { + "Ref": "AWS::Region" + } + }, + { + "name": "AWS_ACCOUNT", + "value": { + "Ref": "AWS::AccountId" + } + } + ], "image": { "Fn::Join": [ "",