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

billions-ocean-88595

07/09/2023, 9:40 AM
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

billowy-army-68599

07/09/2023, 4:19 PM
@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

billions-ocean-88595

07/10/2023, 7:48 AM
ooh - i'll check that out. thank you!