I think this might be a bug or something else? Try...
# general
h
I think this might be a bug or something else? Trying to use
get_subnet_ids
like so:
Copy code
import pulumi
import pulumi_aws as aws
from pulumi_aws.ec2.get_subnet_ids import get_subnet_ids


vpc = aws.ec2.DefaultVpc(f'default-vpc')

get_subnet_ids(vpc_id=vpc.id)
It returns:
Copy code
Exception: invoke of aws:ec2/getSubnetIds:getSubnetIds failed: Missing required argument: The argument "vpc_id" is required, but no definition was found. ()
All I want to do is get the subnets associated with the default VPC
f
Hi Paul (Bonjour?). Have you tried to call ?
Copy code
vpc = aws.ec2.get_vpc(default=True)
print(vpc.arn)
...
h
yes, that works fine
are you suggesting i pass the arn as the id?
huh OK that’s wierd
so the
vpc = aws.ec2.get_vpc(default=True)
works when
vpc = aws.ec2.DefaultVpc(f'default-vpc')
does not
def seems like a bug then?
f
No using vpc.arn was just a way to show it was actually retrieving the default vpc correctly.
Re: DefaultVpc(), bear in mind this is an "advanced" resource. If you need to manipulate or use your vpc, either create a new (non-default) one, or get the default vpc as I showed above.
The doc says about DefaultVpc() https://www.pulumi.com/docs/reference/pkg/aws/ec2/defaultvpc/
Copy code
This is an advanced resource, and has special caveats to be aware of when using it. Please read this document in its entirety before using this resource.
From reading your code above, I would say you should be able to achieve the same with the regular Vpc class.
Running this:
Copy code
import pulumi_aws as aws

vpc = aws.ec2.get_vpc(default=True)
subnet_ids = aws.ec2.get_subnet_ids(vpc_id=vpc.id)
print(subnet_ids.ids)
should output something similar to this:
Copy code
['subnet-204bcd78', 'subnet-f66a7d91', 'subnet-22b1b06b']
h
OK, thanks