So i've tried the simplest setup ever, VPC, Subnet...
# general
b
So i've tried the simplest setup ever, VPC, Subnets, ECS with a single nginx service (most of this is from the AWSX WalkThrough) and yet it just doesn't seem to work. https://github.com/lsportsltd/main-infrastructure everything is in this repository. the ALB is losing it, if I don't put the public subnets explicitly in the code itself for the ALB it just doesn't work. Any help is appreciated!
b
@big-pizza-47421 this repo is private, so I can't see the code
b
@billowy-army-68599 check now
b
b
Copy code
import * as awsx from "@pulumi/awsx";
import { getStack } from "@pulumi/pulumi";

const baseTags = {
  ManagedBy: "Pulumi",
  PulumiStack: getStack(),
};

// Allocate a new VPC that uses all of the current region's availability zones:
const vpc = new awsx.ec2.Vpc(`lsports-${getStack()}`, {
  numberOfAvailabilityZones: "all",
  subnets: [
    { type: "public" },
    { type: "private" },
    { type: "isolated", name: "db" },
    { type: "isolated", name: "redis" },
  ],
  tags: baseTags,
});

// Export a few resulting fields to make them easy to use:
export const vpcId = vpc.id;
export const vpcPrivateSubnetIds = vpc.privateSubnetIds.then((x) => x);
export const vpcPublicSubnetIds = vpc.publicSubnetIds.then((x) => x);
export const vpcIsolatedIds = vpc.isolatedSubnetIds.then((x) => x);
similar to this or should I wrap the entire thing?
b
that should work, give it a try
b
Copy code
aws:lb:LoadBalancer (web-traffic):
    error: 1 error occurred:
        * error creating application Load Balancer: ValidationError: At least two subnets in two different Availability Zones must be specified
        status code: 400, request id: 65207448-409e-46c2-ba34-179f77d6cf98
Copy code
// Get all stack references
const network = new StackReference(config.require("networkingStack"));

const vpc = awsx.ec2.Vpc.fromExistingIds(`lsports-${getStack()}`, {
  vpcId: network.getOutput("vpcId"),
});

// Create a load balancer on port 80 and spin up two instances of Nginx.
const alb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer(
  "web-traffic",
  {
    vpc: vpc,
    tags: baseTags,
    subnets: output(vpc.publicSubnetIds),
  }
);
same issue
b
okay, can you show me your subnets in the console?
b
the output from the network stack
or debug and print it?
b
like, in the console.
b
Copy code
Diagnostics:
  pulumi:pulumi:Stack (ecs-dev):
    OutputImpl {
      __pulumiOutput: true,
      resources: [Function (anonymous)],
      allResources: [Function (anonymous)],
      isKnown: Promise { <pending> },
      isSecret: Promise { <pending> },
      promise: [Function (anonymous)],
      toString: [Function (anonymous)],
      toJSON: [Function (anonymous)]
    }
console.log(output(vpc.publicSubnetIds));
b
sorry, in the AWS console
b
and this is the outputs from the networking
Copy code
Outputs:
    vpcId              : "vpc-0de25ff80c4f18e36"
    vpcIsolatedIds     : [
        [0]: "subnet-03cb4892906fed6fa"
        [1]: "subnet-027da6b5bfb36fe83"
        [2]: "subnet-003b026a11a47d95b"
        [3]: "subnet-035c959ae50ef8795"
        [4]: "subnet-0efc0b8e24baa8dfc"
        [5]: "subnet-02d22c7521da6a133"
    ]
    vpcPrivateSubnetIds: [
        [0]: "subnet-0b55769ef38f6d70e"
        [1]: "subnet-071bceef2f5441848"
        [2]: "subnet-0fded38c0f6abd37d"
    ]
    vpcPublicSubnetIds : [
        [0]: "subnet-058d8455bdd57f0d0"
        [1]: "subnet-0af4ffeb0b8b784c8"
        [2]: "subnet-02ae9c8e80671ff76"
    ]
b
okay, can you verify the subnets are actually in different AZs for me
b
they are
if I put them hardcoded it's working
b
thanks, looks like a bug then. would you mind opening an issue for it
b
I wonder if that's an issue in the awsx module
or the way it's exported