big-restaurant-51338
03/23/2020, 12:02 PMcompute.Instance
? I tried this, but I get a KeyError
# 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]))
tall-librarian-49374
03/23/2020, 1:37 PMbig-restaurant-51338
03/23/2020, 1:38 PMpulumi.export("ip", compute.network_interfaces[0]['accessConfigs'][0]['natIp'])
. If the instance was already created (in a previous run) the code works just finepulumi.export("compute_ext_ip", compute.network_interfaces.apply(lambda a: a[0].get('accessConfigs')[0].get('natIp')))
pulumi.export("compute_int_ip", compute.network_interfaces.apply(lambda a: a[0].get('networkIp')))