steep-lamp-20408
09/27/2022, 6:17 AMfrom pulumi_awsx import ec2
vpc = ec2.Vpc(resource_name="my-vpc")
print(vpc.id)
... outputs None
.
Any idea?boundless-tomato-68419
09/27/2022, 6:31 AMname_of_your_resource.id
Also note that if you want to make a reference to another resource it have to be created already!steep-lamp-20408
09/27/2022, 6:32 AMvpc.id
However it outputs None
. Hence my questionvpc = ec2.Vpc(resource_name="my-vpc")
print(vpc.id)
boundless-tomato-68419
09/27/2022, 6:36 AMsteep-lamp-20408
09/27/2022, 6:36 AMvpc = ec2.Vpc(resource_name="my-vpc")
boundless-tomato-68419
09/27/2022, 6:37 AMsteep-lamp-20408
09/27/2022, 6:37 AMboundless-tomato-68419
09/27/2022, 6:44 AMexports.bucketName = siteBucket.id;
Did you tried it?steep-lamp-20408
09/27/2022, 6:46 AMvpc.id
seems to be null whether it’s printed or not.vpc = ec2.Vpc(resource_name="my-vpc")
public_subnet = aws.ec2.Subnet("my-subnet",
vpc_id=vpc.id,
cidr_block="10.0.1.0/24",
tags={
"Name": "Main",
},
)
....would throw an error when creating the public_subnet
resource, saying the vpc_id
cannot be null
.boundless-tomato-68419
09/27/2022, 6:51 AMvpc = ec2.Vpc(resource_name="my-vpc")
But why is it ec2.vpc?steep-lamp-20408
09/27/2022, 6:53 AMec2
from the pulumi_awsx
package (from pulumi_awsx import ec2
).
Anyway the creation of the VPC is totally working, my point is about getting its id
afterwardslittle-cartoon-10569
09/27/2022, 7:20 AMvpc.vpc.id
if you like: the awsx VPC wraps the aws VPC. They should have the same ID (they do in TS/JS.. maybe not in Python?).steep-lamp-20408
09/27/2022, 7:29 AMvpc_id
outputs a promise/output. Maybe I should use that.pulumi_awsx.ec2.vpc
is better/simpler than AWS classic’s pulumi_aws.ec2.Vpc
, so I’m switching to pulumi_aws
. I get also a promise with .id
from this. It should work.little-cartoon-10569
09/27/2022, 7:47 AMsteep-lamp-20408
09/27/2022, 7:48 AMlittle-cartoon-10569
09/27/2022, 7:49 AM