Repository: pulumi/pulumi-awsx (ts)

Issue:
Validation when asking for a single NAT Gateway
```
const vpc = new awsx.ec2.Vpc("custom", {
    natGateways: {
        strategy: awsx.ec2.NatGatewayStrategy.Single,
    }
});
```

produces

```
    Error: Exactly one Elastic IP may be specified when NAT Gateway strategy is 'Single'.: Error: Exactly one Elastic IP may be specified when NAT Gateway strategy is 'Single'.
        at validateEips (/Users/stack72/.pulumi/plugins/ec2/vpc.ts:300:23)
        at Vpc.initialize (/Users/stack72/.pulumi/plugins/ec2/vpc.ts:79:9)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)

    error: Error: Exactly one Elastic IP may be specified when NAT Gateway strategy is 'Single'.
        at validateEips (/Users/stack72/.pulumi/plugins/ec2/vpc.ts:300:23)
        at Vpc.initialize (/Users/stack72/.pulumi/plugins/ec2/vpc.ts:79:9)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    error: Running program '/Users/stack72/code/awsx/ts-scratch-pad' failed with an unhandled exception:
    Error: failed to register new resource custom [awsx:ec2:Vpc]: 2 UNKNOWN: Exactly one Elastic IP may be specified when NAT Gateway strategy is 'Single'.
        at Object.registerResource (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/@pulumi/runtime/resource.ts:295:27)
        at new Resource (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/@pulumi/resource.ts:393:13)
        at new ComponentResource (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/@pulumi/resource.ts:881:9)
        at new Vpc (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/@pulumi/ec2/vpc.ts:117:9)
        at Object.<anonymous> (/Users/stack72/code/awsx/ts-scratch-pad/index.ts:3:13)
        at Module._compile (internal/modules/cjs/loader.js:1068:30)
        at Module.m._compile (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/ts-node/src/index.ts:439:23)
        at Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
        at Object.require.extensions.<computed> [as .ts] (/Users/stack72/code/awsx/ts-scratch-pad/node_modules/ts-node/src/index.ts:442:12)
        at Module.load (internal/modules/cjs/loader.js:933:32)
```

Pull request description:
Fix validation when NAT Gateway strategy is Single and no EIPs are su…
…pplied.

Fixes #809 

Patch:
diff --git a/awsx/ec2/vpc.ts b/awsx/ec2/vpc.ts
index 9a2ef31e..62f2812c 100644
--- a/awsx/ec2/vpc.ts
+++ b/awsx/ec2/vpc.ts
@@ -299,7 +299,7 @@ export function validateEips(
             }
             break;
         case "Single":
-            if (eips && eips.length !== 1) {
+            if (eips && eips.length > 1) {
                 throw new Error(
                     `Exactly one Elastic IP may be specified when NAT Gateway strategy is '${natGatewayStrategy}'.`,
                 );
@@ -428,9 +428,8 @@ export function validateSubnets(
         let msg =
             "The following subnets overlap with at least one other subnet. Make the CIDR for the VPC larger, reduce the size of the subnets per AZ, or use less Availability Zones:\n\n";
         for (let i = 0; i < overlappingSubnets.length; i++) {
-            msg += `${i + 1}. ${overlappingSubnets[i].subnetName}: ${
-                overlappingSubnets[i].cidrBlock
-            }\n`;
+            msg += `${i + 1}. ${overlappingSubnets[i].subnetName}: ${overlappingSubnets[i].cidrBlock
+                }\n`;
         }
 
         throw new Error(msg);


Test patch:
diff --git a/awsx/ec2/vpc.test.ts b/awsx/ec2/vpc.test.ts
index 49f98065..f7ca5003 100644
--- a/awsx/ec2/vpc.test.ts
+++ b/awsx/ec2/vpc.test.ts
@@ -25,6 +25,10 @@ import {
 } from "./vpc";
 
 describe("validateEips", () => {
+    it("should not throw an exception if NAT Gateway strategy is Single and no EIPs are supplied", () => {
+        expect(() => validateEips("Single", [])).not.toThrowError();
+    });
+
     it("should throw an exception if NAT Gateway strategy is None and EIPs are supplied", () => {
         expect(() => validateEips("None", ["abc123"])).toThrowError(
             "cannot be specified",