bored-kite-38588
05/07/2024, 9:20 AMvpc = awsx.ec2.Vpc("my-vpc",
cidr_block="X.X.X.X/16",
tags={
"Name": "my-vpc"
})
AWSX is creating all the resources including NatGateways, they look like this when you export the object.
+ nat_gateways : [
+ [0]: {
+ allocation_id : "eipalloc-xxx"
+ association_id : "eipassoc-xxx"
+ connectivity_type : "public"
+ id : "nat-xxx"
+ network_interface_id : "eni-xxx"
+ private_ip : "X.X.X.X"
+ public_ip : "X.X.X.X"
+ secondary_allocation_ids : []
+ secondary_private_ip_address_count: 0
+ secondary_private_ip_addresses : []
+ subnet_id : "subnet-xxx"
+ tags : {
+ Name: "xxx"
}
+ tags_all : [secret]
+ urn : "urn:pulumi:xxx::xxx::awsx:ec2:Vpc$aws:ec2/vpc:Vpc$aws:ec2/subnet:Subnet$aws:ec2/natGateway:NatGateway::xxx"
}
So following the documentation and the object vpc
, I tried to create my R53 A record this way :
aws.route53.Record("mail",
zone_id=domain_zone.id,
name=f"{Config.mail-fqdn}",
type=aws.route53.RecordType.A,
ttl=300,
records=[
vpc.nat_gateways.apply(lambda nat_gateways: nat_gateways[0]['public_ip']),
]
)
This i where the things are breaking up, I'm ending with the following error :
File "/Users/xxx/project/main.py", line 322, in <lambda>
vpc.nat_gateways.apply(lambda nat_gateways: nat_gateways[0]['public_ip']),
~~~~~~~~~~~~~~~^^^^^^^^^^^^^
TypeError: 'NatGateway' object is not subscriptable
I feel like I'm doing the same as in the documentation, but I guess I'm missing the point here. Did someone already achieved such configuration ? Thanks in advance if you have any advice or path I might follow !dry-keyboard-94795
05/07/2024, 12:19 PM[0].public_ip
bored-kite-38588
05/07/2024, 2:25 PM