https://pulumi.com logo
#getting-started
Title
# getting-started
s

some-airplane-33254

05/31/2023, 9:29 PM
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?
l

little-cartoon-10569

05/31/2023, 10:03 PM
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.
s

some-airplane-33254

05/31/2023, 10:24 PM
There isn't a call to getVpc() in the template / generated code. That's getting called, I assume, from each resource.
b

billowy-army-68599

05/31/2023, 10:47 PM
awsx (which is used in this template) used the default vpc, it looks like you don’t have any default vpc?
m

miniature-musician-31262

05/31/2023, 11:24 PM
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! 👋 )
b

brainy-church-78120

06/01/2023, 3:57 PM
hi from me too! 💜
s

some-airplane-33254

06/01/2023, 6:56 PM
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.
l

little-cartoon-10569

06/01/2023, 8:34 PM
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.
s

some-airplane-33254

06/01/2023, 10:08 PM
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'.
l

little-cartoon-10569

06/01/2023, 10:25 PM
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.
s

some-airplane-33254

06/01/2023, 10:34 PM
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.
m

miniature-musician-31262

06/02/2023, 12:51 AM
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
awsx
, which recently went 1.0 (and unfortunately changed a few APIs). Those APIs are still there, but they're available under the
classic
namespace -- so when you run into this, you can generally switch your references from
awsx.module.ResourceName
to
awsx.classic.module.ResourceName
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!)
s

some-airplane-33254

06/02/2023, 12:59 AM
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,
});
m

miniature-musician-31262

06/02/2023, 1:14 AM
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
DOCKER
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!
s

some-airplane-33254

06/02/2023, 1:33 AM
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.
3 Views