Hey there, getting started and I tried using the c...
# getting-started
Hey there, getting started and I tried using the container-aws-typescript template. When I run
pulumi up
I get an error from aws:ec2/getVpc "no matching EC2 VPC found". Should I expect the template to yield a deployable starting point?
According to the docs at https://www.pulumi.com/templates/container-service/aws/, you should:
When it’s done, you’ll have a complete Pulumi project that’s ready to deploy and configured with the most common settings.
What are the parameters to getVpc()? It seems an odd thing for a template to include. Either it would use DefaultVpc, or it would create (a non-default) one.
There isn't a call to getVpc() in the template / generated code. That's getting called, I assume, from each resource.
awsx (which is used in this template) used the default vpc, it looks like you don’t have any default vpc?
Should I expect the template to yield a deployable starting point?
Definitely should, yeah, and sounds like this may be because of a missing default VPC. I haven't tried this myself, but you should be able to make a few tweaks to the template to create a new VPC and then use it by following the example here: https://www.pulumi.com/docs/clouds/aws/guides/ecs/#creating-an-ecs-cluster-in-a-vpc
(Also, hi! 👋 )
hi from me too! 💜
Update: Confirmed with a colleague that the default VPC had previously been deleted from the region I was running in. I proceeded using vanilla the aws provider in the meantime.
The DefaultVpc resource is quite good for this. It will create a new default VPC or adopt the existing default VPC, no special code required. It's in the aws.ec2 package.
I think I want to start with creating my own as that's what I'll need later, but good to know there's such an option to get or create a default!
Meanwhile... following the docs here, I tried adding a custom vpc when creating a load balancer with awsx.lb.ApplicationLoadBalancer. However, I get:
TSError: ⨯ Unable to compile TypeScript:
index.ts(33,66): error TS2345: Argument of type '{ vpc: awsx.ec2.Vpc; }' is not assignable to parameter of type 'ApplicationLoadBalancerArgs'.
Object literal may only specify known properties, and 'vpc' does not exist in type 'ApplicationLoadBalancerArgs'.
Use the vpc property of your vpc object; that's the aws.ec2 Vpc.
The awsx.ec2.Vpc is composed of the awx.ec2 Vpc, plus other resources like subnets, NATs, IGNs, route tables, routes etc.
Hmm, I'm not sure if I follow. However, the following "compiles"
const alb = new <http://awsx.lb|awsx.lb>.ApplicationLoadBalancer("web-traffic", vpc, {});
Passing vpc as an arg rather than in the options. That is not what the doc shows. It seems this isn't the only doc discrepancy as later the guide proposes:
const listener = alb.createListener("web-listener", { port: 80 });
But that method doesn't exist.
Argh, looks like this doc is outdated, yeah. I'll see if I can dig up a working example that does what you need here. FWIW, this doc corresponds with the beta version of
, which recently went 1.0 (and unfortunately changed a few APIs). Those APIs are still there, but they're available under the
namespace -- so when you run into this, you can generally switch your references from
to use them, if that helps. Meantime though, I'll see if I can find something that does all this with the 1.0 SDK. (And file to get that doc updated!)
Thanks! Looking at it more I don't understand why passing vpc as second argument (as above) works. That second arg should be an ApplicationLoadBalancerArgs interface 🙃 I think I found a work around for creating the lb in the custom vpc by specifying subnets to use:
const alb = new <http://awsx.lb|awsx.lb>.ApplicationLoadBalancer(rname("web-traffic"), {
subnetIds: vpc.publicSubnetIds,
Yep, that looks right. I have something working that I can share -- at least it's working for me 🙂 https://gist.github.com/cnunciato/812531c537ccf9a0e94674d11cd62ef7 I'm on an M2, hence that
env var (without that, the images I build locally don't run when they make it to AWS), and you'll probably want to adjust the subnet group (as it allows everything right now), but hopefully this'll help ya.
Headed out to run a kid to a thing, but I'll check back in later. Hope it helps and sorry for the rough edges!
Thanks so much! Using your example, I tweaked what I had and finally got to a reachable nginx stub. I need to stop for the day, but thanks again for the help.