Skip to content

Commit

Permalink
fix(aws-batch): computeResources tags are not configured properly (#…
Browse files Browse the repository at this point in the history
…10209)

Use key-value map of tags for `ComputeResources.computeResourcesTags`.

Previously used type `Tag` disallowed adding multiple tags.

Fixes #7350

BREAKING CHANGE: Changed type of `ComputeResources.computeResourcesTags` from `Tag` to map


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rsmogura authored Sep 8, 2020
1 parent a388d70 commit 40222ef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/@aws-cdk/aws-batch/lib/compute-environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import * as iam from '@aws-cdk/aws-iam';
import { Construct, IResource, Resource, Stack, Tag } from '@aws-cdk/core';
import { Construct, IResource, Resource, Stack } from '@aws-cdk/core';
import { CfnComputeEnvironment } from './batch.generated';

/**
Expand Down Expand Up @@ -210,7 +210,9 @@ export interface ComputeResources {
*
* @default - no tags will be assigned on compute resources.
*/
readonly computeResourcesTags?: Tag;
readonly computeResourcesTags?: {
[key: string]: string
};
}

/**
Expand Down
11 changes: 6 additions & 5 deletions packages/@aws-cdk/aws-batch/test/compute-environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ describe('Batch Compute Evironment', () => {
computeResources: {
allocationStrategy: batch.AllocationStrategy.BEST_FIT,
vpc,
computeResourcesTags: new cdk.Tag('foo', 'bar'),
computeResourcesTags: {
'Name': 'AWS Batch Instance - C4OnDemand',
'Tag Other': 'Has other value',
},
desiredvCpus: 1,
ec2KeyPair: 'my-key-pair',
image: new ecs.EcsOptimizedAmi({
Expand Down Expand Up @@ -244,10 +247,8 @@ describe('Batch Compute Evironment', () => {
},
],
Tags: {
key: 'foo',
props: {},
defaultPriority: 100,
value: 'bar',
'Name': 'AWS Batch Instance - C4OnDemand',
'Tag Other': 'Has other value',
},
Type: 'EC2',
},
Expand Down
5 changes: 4 additions & 1 deletion packages/@aws-cdk/aws-batch/test/integ.batch.expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,9 @@
"Ref": "vpcPrivateSubnet3Subnet985AC459"
}
],
"Tags": {
"compute-env-tag": "123XYZ"
},
"Type": "EC2"
},
"State": "ENABLED"
Expand Down Expand Up @@ -1351,4 +1354,4 @@
}
}
}
}
}
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-batch/test/integ.batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ new batch.JobQueue(stack, 'batch-job-queue', {
launchTemplate: {
launchTemplateName: launchTemplate.launchTemplateName as string,
},
computeResourcesTags: {
'compute-env-tag': '123XYZ',
},
},
}),
order: 2,
Expand Down

0 comments on commit 40222ef

Please sign in to comment.