Skip to content

Commit

Permalink
fix(ec2): volumename doesn't set name of volume (aws#15832)
Browse files Browse the repository at this point in the history
fixes: aws#15831

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
peterwoodworth authored and hollanddd committed Aug 26, 2021
1 parent e113a8f commit 7147280
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-ec2/lib/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ export class Volume extends VolumeBase {
});
resource.applyRemovalPolicy(props.removalPolicy);

if (props.volumeName) Tags.of(resource).add('Name', props.volumeName);

this.volumeId = resource.ref;
this.availabilityZone = props.availabilityZone;
this.encryptionKey = props.encryptionKey;
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/volume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('volume', () => {
new Volume(stack, 'Volume', {
availabilityZone: 'us-east-1a',
size: cdk.Size.gibibytes(8),
volumeName: 'MyVolume',
});

// THEN
Expand All @@ -40,6 +41,12 @@ describe('volume', () => {
MultiAttachEnabled: false,
Size: 8,
VolumeType: 'gp2',
Tags: [
{
Key: 'Name',
Value: 'MyVolume',
},
],
}, ResourcePart.Properties));

cdkExpect(stack).to(haveResource('AWS::EC2::Volume', {
Expand Down

0 comments on commit 7147280

Please sign in to comment.