Skip to content

Commit

Permalink
fix(ec2): Remove validation of availabilityZone from Volume (aws#9082)
Browse files Browse the repository at this point in the history
This fixes an erroneous validation failure of the `availabilityZone` property of the `Volume` construct that occurs during the first run of a fresh application.

Fixes: aws#9081
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
ddneilson authored Jul 16, 2020
1 parent 17b690b commit 8d470b2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
4 changes: 0 additions & 4 deletions packages/@aws-cdk/aws-ec2/lib/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,6 @@ export class Volume extends VolumeBase {
}

protected validateProps(props: VolumeProps) {
if (!Token.isUnresolved(props.availabilityZone) && !/^[a-z]{2}-[a-z]+-[1-9]+[a-z]$/.test(props.availabilityZone)) {
throw new Error('`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token');
}

if (!(props.size || props.snapshotId)) {
throw new Error('Must provide at least one of `size` or `snapshotId`');
}
Expand Down
41 changes: 0 additions & 41 deletions packages/@aws-cdk/aws-ec2/test/volume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,47 +1251,6 @@ nodeunitShim({
test.done();
},

'validation availabilityZone'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const volume = new Volume(stack, 'ForToken', {
availabilityZone: 'us-east-1a',
size: cdk.Size.gibibytes(8),
});
let idx: number = 0;

// THEN
test.doesNotThrow(() => {
// Should not throw if we provide a token for the AZ
new Volume(stack, `Volume${idx++}`, {
availabilityZone: volume.volumeId,
size: cdk.Size.gibibytes(8),
});
});
test.throws(() => {
new Volume(stack, `Volume${idx++}`, {
availabilityZone: 'us-east-1',
});
}, '`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token');
test.throws(() => {
new Volume(stack, `Volume${idx++}`, {
availabilityZone: 'Virginia',
});
}, '`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token');
test.throws(() => {
new Volume(stack, `Volume${idx++}`, {
availabilityZone: ' us-east-1a', // leading character(s)
});
}, '`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token');
test.throws(() => {
new Volume(stack, `Volume${idx++}`, {
availabilityZone: 'us-east-1a ', // trailing character(s)
});
}, '`availabilityZone` is a region followed by a letter (ex: `us-east-1a`), or a token');

test.done();
},

'validation snapshotId'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit 8d470b2

Please sign in to comment.