Skip to content

Commit

Permalink
Merge branch 'main' into appsync-log-retention
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Aug 4, 2022
2 parents ea5303d + 3853728 commit ac64ec6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@
]
}
]
}
},
"TagSpecifications": [
{
"ResourceType": "launch-template",
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-asg-integ/MainLT"
}
]
}
]
}
},
"T4gLT8FF7D308": {
Expand Down Expand Up @@ -59,7 +70,18 @@
]
}
]
}
},
"TagSpecifications": [
{
"ResourceType": "launch-template",
"Tags": [
{
"Key": "Name",
"Value": "aws-cdk-asg-integ/T4gLT"
}
]
}
]
}
},
"VPCB9E5F0B4": {
Expand Down
23 changes: 23 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/launch-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr
}

this.tags = new TagManager(TagType.KEY_VALUE, 'AWS::EC2::LaunchTemplate');

const tagsToken = Lazy.any({
produce: () => {
if (this.tags.hasTags()) {
Expand All @@ -588,6 +589,27 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr
},
});

const ltTagsToken = Lazy.any({
produce: () => {
if (this.tags.hasTags()) {
const renderedTags = this.tags.renderTags();
const lowerCaseRenderedTags = renderedTags.map( (tag: { [key: string]: string}) => {
return {
key: tag.Key,
value: tag.Value,
};
});
return [
{
resourceType: 'launch-template',
tags: lowerCaseRenderedTags,
},
];
}
return undefined;
},
});

const resource = new CfnLaunchTemplate(this, 'Resource', {
launchTemplateName: props?.launchTemplateName,
launchTemplateData: {
Expand Down Expand Up @@ -655,6 +677,7 @@ export class LaunchTemplate extends Resource implements ILaunchTemplate, iam.IGr
// placement: undefined,

},
tagSpecifications: ltTagsToken,
});

Tags.of(this).add(NAME_TAG, this.node.path);
Expand Down
37 changes: 37 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/launch-template.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ describe('LaunchTemplate', () => {
},
],
},
TagSpecifications: [
{
ResourceType: 'launch-template',
Tags: [
{
Key: 'Name',
Value: 'Default/Template',
},
],
},
],
});
Template.fromStack(stack).resourceCountIs('AWS::IAM::InstanceProfile', 0);
expect(() => { template.grantPrincipal; }).toThrow();
Expand Down Expand Up @@ -248,6 +259,17 @@ describe('LaunchTemplate', () => {
},
],
},
TagSpecifications: [
{
ResourceType: 'launch-template',
Tags: [
{
Key: 'Name',
Value: 'Default/Template',
},
],
},
],
});
expect(template.role).toBeDefined();
expect(template.grantPrincipal).toBeDefined();
Expand Down Expand Up @@ -533,6 +555,21 @@ describe('LaunchTemplate', () => {
},
],
},
TagSpecifications: [
{
ResourceType: 'launch-template',
Tags: [
{
Key: 'Name',
Value: 'Default/Template',
},
{
Key: 'TestKey',
Value: 'TestValue',
},
],
},
],
});
});

Expand Down

0 comments on commit ac64ec6

Please sign in to comment.