hi! how do I retrieve the internal IP of a newly c...
# google-cloud
b
hi! how do I retrieve the internal IP of a newly created
compute.Instance
? I tried this, but I get a KeyError
Copy code
# actual vm creation
instance = compute.Instance("instance",
        machine_type=config.require('type'),
        boot_disk={
            "initializeParams": {
                "image": config.require('image')
                }
            },
        network_interfaces=[
            {
                "subnetwork": parentStack.get_output('subnet_id'),
                }
            ],
        # metadata={
        #     "startup-script": init_script
        #     },
        zone = config.require('zone'),
        tags = ["mytags"]
        )
# Register the DNS record
dns_name = parentStack.get_output('private_dns_zone').apply(lambda a: f"instance.{a}")
instance_recordset = dns.RecordSet("instance-recordset",
        managed_zone = parentStack.get_output('private_dns_name'),
        name = dns_name,
        rrdatas = [ instance.network_interfaces[0]['networkIp'] ],
        ttl = 3600,
        type = "A",
        opts=pulumi.ResourceOptions(depends_on=[instance]))
w
I expect this is only an issue during the initial preview? I believe it is likely ultimately due to the same issue as https://github.com/pulumi/pulumi-azure/issues/192, and see also https://github.com/pulumi/pulumi/issues/4040. I believe you can workaround that with:
Copy code
rrdatas = [ instance.network_interfaces[0].apply(lambda nic: nic.get('networkIp', 'unknown') ],