Hello everyone, I'm starting to use inputs/ouputs...
# python
b
Hello everyone, I'm starting to use inputs/ouputs with pulumi, I've read the documentation here : https://www.pulumi.com/docs/concepts/inputs-outputs/apply/#accessing-nested-output-values I'm struggling a bit to feed an output of a function to an input of another. The idea is simple, get the public IP of the NAT Gateways to register a Route53 record of type A. This is the way I'm creating the resources.
Copy code
vpc = 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.
Copy code
+ 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 :
Copy code
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 :
Copy code
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 !
d
Try
[0].public_ip
b
Well, I was pretty sure i've tried this one, but it looks like I didn't ! Thanks 🙂