Hi - I am just getting started with Pulumi Python ...
# getting-started
b
Hi - I am just getting started with Pulumi Python - Seems really nice to have a real programming language, rather than programming in templates or yaml. As my first learning task, after running a couple of the examples, I'm trying to deploy an ECS Fargate task into a new cluster, which will run inside some existing private subnets, in an existing vpc, and link to an existing load balancer. I think I have got most of the things working, but I can't find a way to go from the VPC ID to get the private subnets and security groups. I think I need this to supply to the
ServiceNetworkConfigurationArgs
Copy code
dev_vpc = aws.ec2.get_vpc(id=VPC_ID)

vpc_subnets = aws.ec2.get_subnets(
    filters=[aws.ec2.GetSubnetsFilterArgs(name='vpc-id', values=[dev_vpc.id]), ]
)

private_subnets = ???
... then how to filter them, so I can give to
Copy code
network_configuration=aws.ecs.ServiceNetworkConfigurationArgs(
                              assign_public_ip=False,
                              subnets=private_subnets.ids,
                              security_groups=[group.id],
                          )
I tried to just use:
Copy code
private_subnets = [ aws.ec2.get_subnet(id=it.id) for it in vpc_subnets]   # then further filter
but things are not of the right type.Thanks for any suggestions!
b
@billions-ocean-88595 you’ll likely need to narrow down your subnet filters. Are the subnets tagged with their type? If not, you can filter them down by using the
map-public-ip-on-launch
filter:
Copy code
aws.ec2.GetSubnetsFilterArgs(name='map-public-ip-on-launch', values=["false"])
b
ooh - i'll check that out. thank you!