Add Source NAT IP parameter

When creating a VPC, CloudStack automatically assigns a source NAT IP
from it's pool. It's handy to have this IP available in Terraform, which
can be used in ACLs for example. This commit adds such support.
pull/3399/head
Hany Fahim 11 years ago
parent 4502c32840
commit 910469ddee

@ -51,6 +51,11 @@ func resourceCloudStackVPC() *schema.Resource {
Required: true,
ForceNew: true,
},
"source_nat_ip": &schema.Schema{
Type: schema.TypeString,
Computed: true,
},
},
}
}
@ -133,6 +138,16 @@ func resourceCloudStackVPCRead(d *schema.ResourceData, meta interface{}) error {
setValueOrUUID(d, "project", v.Project, v.Projectid)
setValueOrUUID(d, "zone", v.Zonename, v.Zoneid)
// Grab the source NAT IP that CloudStack assigned.
p := cs.Address.NewListPublicIpAddressesParams()
p.SetVpcid(d.Id())
p.SetIssourcenat(true)
p.SetProjectid(v.Projectid)
l, e := cs.Address.ListPublicIpAddresses(p)
if (e == nil) && (l.Count == 1) {
d.Set("source_nat_ip", l.PublicIpAddresses[0].Ipaddress)
}
return nil
}

Loading…
Cancel
Save