https://pulumi.com logo
Title
b

broad-holiday-50009

01/26/2023, 7:24 PM
another subnetting question using aws-python. I don't see anywhere in the documentation how to differentiate between a public subnet and a private one when I'm creating them. Is there a way to do this?
l

little-cartoon-10569

01/26/2023, 7:25 PM
A private subnet is a public subnet without a route to the IGW, but with an NAT server. If you're creating subnets manually, then you have to look after this yourself.
b

broad-holiday-50009

01/26/2023, 7:27 PM
ok
b

billowy-army-68599

01/26/2023, 7:28 PM
@broad-holiday-50009 are you using crosswalk?
b

broad-holiday-50009

01/26/2023, 7:28 PM
no
b

billowy-army-68599

01/26/2023, 7:28 PM
that’ll make your life a whole bunch easier
b

broad-holiday-50009

01/26/2023, 7:28 PM
I tried to use it at first but it made it much more complicated for someone who doesn't understand pulumi fully
b

billowy-army-68599

01/26/2023, 7:29 PM
if you want to create the entire VPC manually, there is some prior art to follow here: https://github.com/jen20/pulumi-aws-vpc/tree/master/python
b

broad-holiday-50009

01/26/2023, 7:29 PM
thank you
but creating a VPC with awsx is as simple as:
import pulumi
import pulumi_awsx as awsx
import pulumi_aws as aws

config = pulumi.Config()
cidr_block = config.require("cidr_block")
stack_name = pulumi.get_stack()

vpc = awsx.ec2.Vpc(
    f"vpc-{stack_name}",
    cidr_block=cidr_block,
    subnet_specs=[
        awsx.ec2.SubnetSpecArgs(
            type="public",
        ),
        awsx.ec2.SubnetSpecArgs(
            type="private",
        ),
    ],
    number_of_availability_zones=2
    nat_gateways=awsx.ec2.NatGatewayConfigurationArgs(strategy="SINGLE":),
)

pulumi.export("vpc_id", vpc.vpc_id)
pulumi.export("public_subnet_ids", vpc.public_subnet_ids)
pulumi.export("private_subnet_ids", vpc.private_subnet_ids)
b

broad-holiday-50009

01/26/2023, 7:31 PM
ok that's perfect, I didn't know about SubnetSpecArgs
like I'm looking at the ec2 subnet documentation and that's not even in there. Am I just having issues understanding the layout of the documentation? I haven't found anything I needed in there yet
b

billowy-army-68599

01/26/2023, 7:33 PM
unfortunately the awsx documentation isn’t great right now 😞 we’re aware of it
you’re using an IDE like vscode?
b

broad-holiday-50009

01/26/2023, 7:34 PM
I can, I have it but so far i've just been coding in terminal
b

billowy-army-68599

01/26/2023, 7:34 PM
okay, vscode is going to make your life much easier
are you completely new to Pulumi and writing pythin?
b

broad-holiday-50009

01/26/2023, 7:34 PM
yes I'm pretty fresh to devops in general but this is by far the most complex undertaking I've tried yet
b

billowy-army-68599

01/26/2023, 7:35 PM
if you want to hop on a zoom, download vscode and install it and I can take you through some tips to make your life easier. I’m free for the next 90 minutes
b

broad-holiday-50009

01/26/2023, 7:36 PM
I have vscode on this computer already but I work in a library so I can't really do a zoom call at the moment
b

billowy-army-68599

01/26/2023, 7:37 PM
no problem, if you install vscode and configure it correctly, you can right click on most resources and select “Go to definition” and you’ll see all the inpits and outputs you can configure
b

broad-holiday-50009

01/26/2023, 7:37 PM
oh man that's fantastic the one thing pulumi seems to do really well is name things in a way that they make sense so that should really help