am I doing something wrong with `ec2.get_subnet_id...
# general
s
am I doing something wrong with
ec2.get_subnet_ids()
in Python SDK? I pass
vpc_id=vpc.id
as I do with other resources but get an exception:
Copy code
Exception: invoke of aws:ec2/getSubnetIds:getSubnetIds failed: "vpc_id": required field is not set ()
this is with a simple
ec2.get_subnet_ids(vpc_id=vpc.id)
call
weird, the fargate example makes the exact same call.
vpc.id
is valid and compared the object with its use in other methods
Copy code
File "/Users/scott/.pyenv/versions/infra/lib/python3.8/site-packages/pulumi/runtime/invoke.py", line 111, in do_invoke
        raise Exception(f"invoke of {tok} failed: {resp.failures[0].reason} ({resp.failures[0].property})")
    Exception: invoke of aws:ec2/getSubnetIds:getSubnetIds failed: "vpc_id": required field is not set ()
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

    VPC ID before ec2.InternetGateway: <pulumi.output.Output object at 0x10e577970>
    VPC ID before deriving subnets for ec2.NatGateway: <pulumi.output.Output object at 0x10e577970>
with some diag at the end
g
Can you provide your full code?
s
yeah, one sec
is that enough?
g
Yea - are you sure
self.vpc.id
is set or even that
self.vpc
is set? When I try this it works fine for me.
s
It's used in the prior method
I'll post more when I am back home
https://gist.github.com/ohlol/9b4923804c6de07ca1c5c23dfcd37d60 @gentle-diamond-70147 all of these methods work with the exception of
_manage_natgw
which raises the exception above
nb I tried
self.vpc
in that file on L38 because
self.vpc.id
didn’t work
g
can you provide the code that's calling all those functions?
s
ya one sec
g
Got this working with https://gist.github.com/clstokes/1c42f23a666c183f1353282fa393c82a. Note the `TODO`s that you'll want to change back. There are a few things I changed: - in
_manage_subnets
create a list of subnets and set them to
self
- in
_manage_natgw
use the list of subnets from
self
to create the
NatGateway
resources - removed the
ec2.get_subnet_ids()
call entirely
The reason why it wasn't working is that
self.vpc.id
is an Output (e.g. a "future") and
ec2.get_subnet_ids()
expects a "prompt" string. We have an issue somewhere to allow for the
get_X()
function calls to accept outputs, but unfortunately they don't currently.
More generally though, the
get_X()
functions actually query the AWS APIs to get data and if this is the first time you're running a
preview
or
up
those subnets won't actually exist.
Hope this makes sense, let me know if you have any questions.
s
nice, thank you!
👍 1