From eed854ed4be6b76abc909721d6baa14140681dcc Mon Sep 17 00:00:00 2001 From: Dzhuneyt <1754428+Dzhuneyt@users.noreply.github.com> Date: Fri, 22 Jul 2022 02:04:19 +0300 Subject: [PATCH] feat(batch): add default AWS_ACCOUNT and AWS_REGION to Batch container, if they are not explicitly set (#21041) Closes https://github.com/aws/aws-cdk/issues/10952 ---- ### All Submissions: * [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [X] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-batch/README.md | 2 + .../@aws-cdk/aws-batch/lib/job-definition.ts | 26 +- packages/@aws-cdk/aws-batch/package.json | 1 + .../batch-stack.assets.json | 4 +- .../batch-stack.template.json | 42 ++ .../test/batch.integ.snapshot/manifest.json | 30 + .../test/batch.integ.snapshot/tree.json | 278 ++++++++ .../aws-batch/test/integ.job-definition.ts | 40 ++ .../BatchDefaultEnvVarsStack.template.json | 46 ++ ...aultTestDeployAssertC15EFFF2.template.json | 162 +++++ .../index.js | 620 ++++++++++++++++++ .../job-definition.integ.snapshot/cdk.out | 1 + .../job-definition.integ.snapshot/integ.json | 14 + .../manifest.json | 101 +++ .../job-definition.integ.snapshot/tree.json | 319 +++++++++ .../aws-batch/test/job-definition.test.ts | 24 + .../batch-events.assets.json | 19 + .../batch-events.template.json | 14 + .../cdk.out | 2 +- .../manifest.json | 2 +- .../tree.json | 18 +- .../aws-stepfunctions-integ.assets.json | 6 +- .../aws-stepfunctions-integ.template.json | 14 + .../run-batch-job.integ.snapshot/cdk.out | 2 +- .../manifest.json | 2 +- .../run-batch-job.integ.snapshot/tree.json | 16 +- .../aws-stepfunctions-integ.assets.json | 6 +- .../aws-stepfunctions-integ.template.json | 14 + .../batch/submit-job.integ.snapshot/cdk.out | 2 +- .../submit-job.integ.snapshot/manifest.json | 2 +- .../batch/submit-job.integ.snapshot/tree.json | 16 +- 31 files changed, 1823 insertions(+), 22 deletions(-) create mode 100644 packages/@aws-cdk/aws-batch/test/integ.job-definition.ts create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json create mode 100644 packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.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 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-batch/README.md b/packages/@aws-cdk/aws-batch/README.md index 0ef420a0422a5..02252a8cc6625 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', { }); ``` +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 ARN diff --git a/packages/@aws-cdk/aws-batch/lib/job-definition.ts b/packages/@aws-cdk/aws-batch/lib/job-definition.ts index 99c28fa03d5c6..3666356c5b06f 100644 --- a/packages/@aws-cdk/aws-batch/lib/job-definition.ts +++ b/packages/@aws-cdk/aws-batch/lib/job-definition.ts @@ -476,11 +476,11 @@ 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) => { @@ -519,9 +519,27 @@ 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 = 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_ACCOUNT', + value: Stack.of(this).account, + }); + } + return { command: container.command, - environment: this.deserializeEnvVariables(container.environment), + environment, secrets: container.secrets ? Object.entries(container.secrets).map(([key, value]) => { return { @@ -584,4 +602,4 @@ export class JobDefinition extends Resource implements IJobDefinition { }; }); } -} +} \ No newline at end of file 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/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/integ.job-definition.ts b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts new file mode 100644 index 0000000000000..a2eef5e103edc --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/integ.job-definition.ts @@ -0,0 +1,40 @@ +/* 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 { JobDefinition } from "../lib"; + +const app = new App(); + +const stack = new Stack(app, "BatchDefaultEnvVarsStack", { + env: { + account: process.env.CDK_DEFAULT_ACCOUNT, + region: process.env.CDK_DEFAULT_REGION, + }, +}); + +new JobDefinition(stack, "JobDefinition", { + container: { + image: ContainerImage.fromRegistry("docker/whalesay"), + }, +}); + +const integ = new IntegTest(app, "IntegTest-BatchDefaultEnvVarsStack", { + testCases: [stack], + regions: ["us-east-1"], +}); + +const awsApiCallDescribeJobDefinition = integ.assertions.awsApiCall( + "Batch", + "describeJobDefinitions", + { + status: "ACTIVE", + }, +); + +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/BatchDefaultEnvVarsStack.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json new file mode 100644 index 0000000000000..dcb6d09b0f981 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/BatchDefaultEnvVarsStack.template.json @@ -0,0 +1,46 @@ +{ + "Resources": { + "JobDefinition24FFE3ED": { + "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" + } + ] + }, + "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/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json new file mode 100644 index 0000000000000..f2573075a37ae --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json @@ -0,0 +1,162 @@ +{ + "Resources": { + "AwsApiCallBatchdescribeJobDefinitions": { + "Type": "Custom::DeployAssert@SdkCallBatchdescribeJobDefinitions", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "service": "Batch", + "api": "describeJobDefinitions", + "parameters": { + "status": "ACTIVE" + }, + "flattenResponse": "true", + "salt": "1658183315795" + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C": { + "Type": "Custom::DeployAssert@AssertEquals", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "actual": { + "Fn::GetAtt": [ + "AwsApiCallBatchdescribeJobDefinitions", + "apiCallResponse.jobDefinitions.0.containerProperties.environment.0.name" + ] + }, + "expected": "{\"$StringLike\":\"AWS_REGION\"}", + "salt": "1658183315795" + }, + "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/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..f5356f44b77e0 --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/integ.json @@ -0,0 +1,14 @@ +{ + "version": "20.0.0", + "testCases": { + "IntegTest-BatchDefaultEnvVarsStack/DefaultTest": { + "stacks": [ + "BatchDefaultEnvVarsStack" + ], + "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 new file mode 100644 index 0000000000000..866278ef905de --- /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" + } + }, + "BatchDefaultEnvVarsStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://347315207830/us-east-1", + "properties": { + "templateFile": "BatchDefaultEnvVarsStack.template.json", + "validateOnSynth": false + }, + "metadata": { + "/BatchDefaultEnvVarsStack/JobDefinition/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "JobDefinition24FFE3ED" + } + ] + }, + "displayName": "BatchDefaultEnvVarsStack" + }, + "IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "IntegTestBatchDefaultEnvVarsStackDefaultTestDeployAssertC15EFFF2.template.json", + "validateOnSynth": false + }, + "metadata": { + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert": [ + { + "type": "aws:cdk:asset", + "data": { + "path": "asset.ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3.bundle", + "id": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "packaging": "zip", + "sourceHash": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "s3BucketParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4", + "s3KeyParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6", + "artifactHashParameter": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521" + } + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallBatchdescribeJobDefinitions" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallBatchdescribeJobDefinitionsAssertEqualsBatchdescribeJobDefinitions39706B7C" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsAssertEqualsBatchdescribeJobDefinitions" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81Role37ABCE73" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3Bucket5F1832C4" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3S3VersionKeyA04E23E6" + } + ], + "/IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/ArtifactHash": [ + { + "type": "aws:cdk:logicalId", + "data": "AssetParametersec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3ArtifactHash000AF521" + } + ] + }, + "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 new file mode 100644 index 0000000000000..2b77ee40fa90f --- /dev/null +++ b/packages/@aws-cdk/aws-batch/test/job-definition.integ.snapshot/tree.json @@ -0,0 +1,319 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + }, + "BatchDefaultEnvVarsStack": { + "id": "BatchDefaultEnvVarsStack", + "path": "BatchDefaultEnvVarsStack", + "children": { + "JobDefinition": { + "id": "JobDefinition", + "path": "BatchDefaultEnvVarsStack/JobDefinition", + "children": { + "Resource-Batch-Task-Definition-Role": { + "id": "Resource-Batch-Task-Definition-Role", + "path": "BatchDefaultEnvVarsStack/JobDefinition/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": "BatchDefaultEnvVarsStack/JobDefinition/Resource-Batch-Job-Container-Definition", + "constructInfo": { + "fqn": "@aws-cdk/aws-ecs.ContainerDefinition", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "BatchDefaultEnvVarsStack/JobDefinition/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Batch::JobDefinition", + "aws:cdk:cloudformation:props": { + "type": "container", + "containerProperties": { + "environment": [ + { + "name": "AWS_REGION", + "value": "us-east-1" + }, + { + "name": "AWS_ACCOUNT", + "value": "347315207830" + } + ], + "image": "docker/whalesay", + "privileged": false, + "readonlyRootFilesystem": false, + "resourceRequirements": [ + { + "type": "VCPU", + "value": "1" + }, + { + "type": "MEMORY", + "value": "4" + } + ] + }, + "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-BatchDefaultEnvVarsStack": { + "id": "IntegTest-BatchDefaultEnvVarsStack", + "path": "IntegTest-BatchDefaultEnvVarsStack", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.33" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert", + "children": { + "AwsApiCallBatchdescribeJobDefinitions": { + "id": "AwsApiCallBatchdescribeJobDefinitions", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/SdkProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/Default", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions", + "children": { + "AssertionProvider": { + "id": "AssertionProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/AssertionProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "IntegTest-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AwsApiCallBatchdescribeJobDefinitions/AssertEqualsBatchdescribeJobDefinitions/Default", + "children": { + "Default": { + "id": "Default", + "path": "IntegTest-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81", + "children": { + "Staging": { + "id": "Staging", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Staging", + "constructInfo": { + "fqn": "@aws-cdk/core.AssetStaging", + "version": "0.0.0" + } + }, + "Role": { + "id": "Role", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/SingletonFunction1488541a7b23466481b69b4408076b81/Role", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnResource", + "version": "0.0.0" + } + }, + "Handler": { + "id": "Handler", + "path": "IntegTest-BatchDefaultEnvVarsStack/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-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters", + "children": { + "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3": { + "id": "ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3", + "children": { + "S3Bucket": { + "id": "S3Bucket", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3Bucket", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "S3VersionKey": { + "id": "S3VersionKey", + "path": "IntegTest-BatchDefaultEnvVarsStack/DefaultTest/DeployAssert/AssetParameters/ec094b96e98289a8faed4f4280a8531224c0191f583bc684c21c91a65319e4a3/S3VersionKey", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "ArtifactHash": { + "id": "ArtifactHash", + "path": "IntegTest-BatchDefaultEnvVarsStack/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 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: [ { 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, 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": [ "",