https://pulumi.com logo
m

millions-furniture-75402

05/27/2020, 1:00 PM
I’m having trouble with stack references, but I can’t understand what I’m doing wrong. The VPC is pre-existing, and the shared-infra stack `pulumi up`s just fine `catmeme/shared-infra/develop`:
Copy code
...

const parameterVpcId = config.require("parameterVpcId");
export const privateSubnetIds: [] = config.requireObject("privateSubnetIds");
export const publicSubnetIds: [] = config.requireObject("publicSubnetIds");

export const vpcId: pulumi.Output<string> = pulumi.output(aws.ssm.getParameter({
  name: parameterVpcId,
})).value;

const vpc = awsx.ec2.Vpc.fromExistingIds(`${appName}-local-vpc`, {
  vpcId,
  privateSubnetIds,
  publicSubnetIds,
});

...
`catmeme/application/develop-test`:
Copy code
...

const stackDevelop = new pulumi.StackReference("catmeme/shared-infra-develop/develop");

const vpc = awsx.ec2.Vpc.fromExistingIds("bvt", {
  vpcId: stackDevelop.getOutput("vpcId"),
  // @ts-ignore
  privateSubnetIds: stackDevelop.getOutput("privateSubnetIds") as pulumi.Output<string[]>,
  // @ts-ignore
  publicSubnetIds: stackDevelop.getOutput("publicSubnetIds") as pulumi.Output<string[]>,
});

...
I get an error:
Copy code
error: Preview failed: resource 'vpc-03489fb5e3c04080d' does not exist
But the VPC with that ID does exist. For all intents and purposes, shared-infra declared the VPC the same way and there isn’t a problem. What am I missing?
🤦 I was using the wrong AWS profile in my application stack
😃 1
b

billowy-army-68599

05/27/2020, 2:42 PM
we've all been there! glad you got it figured out
m

millions-furniture-75402

05/27/2020, 2:45 PM
There was actually a second, sort of interesting reason… that was the complication with my existing ALB. I was redeclaring an ALB, and it didn’t have a vpc specified, so it was outputting the same error.