From 8d470b2e7f9883ff0d16a76193d719de31241ea0 Mon Sep 17 00:00:00 2001 From: Daniel Neilson <53624638+ddneilson@users.noreply.github.com> Date: Thu, 16 Jul 2020 13:51:32 -0500 Subject: [PATCH] fix(ec2): Remove validation of availabilityZone from Volume (#9082) 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: https://github.com/aws/aws-cdk/issues/9081 ---- *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-ec2/lib/volume.ts | 4 -- packages/@aws-cdk/aws-ec2/test/volume.test.ts | 41 ------------------- 2 files changed, 45 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/volume.ts b/packages/@aws-cdk/aws-ec2/lib/volume.ts index 5dfd157460484..d379ae6622b1f 100644 --- a/packages/@aws-cdk/aws-ec2/lib/volume.ts +++ b/packages/@aws-cdk/aws-ec2/lib/volume.ts @@ -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`'); } diff --git a/packages/@aws-cdk/aws-ec2/test/volume.test.ts b/packages/@aws-cdk/aws-ec2/test/volume.test.ts index dbe368285fb40..0600d201755a7 100644 --- a/packages/@aws-cdk/aws-ec2/test/volume.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/volume.test.ts @@ -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();