https://pulumi.com logo
#general
Title
# general
c

calm-greece-42329

06/03/2020, 8:28 PM
am i thinking about this wrong, but i thought one could do something like
const subnet = aws.ec2.Subnet.get("some_subnet_name")
to look up an existing subnet or vpc, but apparently i need to also provide the resource id?
g

gentle-diamond-70147

06/03/2020, 8:34 PM
The
<resource>.get()
methods always require an ID. There are lookup functions like
aws.ec2.getSubnet()
that take filter arguments - https://www.pulumi.com/docs/reference/pkg/aws/ec2/getsubnet/#using.
c

calm-greece-42329

06/03/2020, 8:42 PM
so something along the lines of this is in the right direction
Copy code
const vpcName = "dev";
export const vpc = pulumi.output(aws.ec2.getVpc({filters: [{name: "tag:Name", values: [vpcName]}]}));
export const subnets = pulumi.output(aws.ec2.getSubnetIds({tags: {Environment: "dev1"}, vpcId: vpc.apply(x => x.id)}));
g

gentle-diamond-70147

06/03/2020, 8:46 PM
looks roughly correct, yea
c

calm-greece-42329

06/03/2020, 8:51 PM
does the python api suffer the same promise/output types of complexities?
asking for a friend 😄
g

gentle-diamond-70147

06/03/2020, 8:53 PM
Same support and functionality there, yes. 😉