diff --git a/builtin/providers/packet/resource_packet_device.go b/builtin/providers/packet/resource_packet_device.go index 6bee26cf9..c7cd777a2 100644 --- a/builtin/providers/packet/resource_packet_device.go +++ b/builtin/providers/packet/resource_packet_device.go @@ -184,7 +184,7 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error { d.Set("billing_cycle", device.BillingCycle) d.Set("locked", device.Locked) d.Set("created", device.Created) - d.Set("udpated", device.Updated) + d.Set("updated", device.Updated) tags := make([]string, 0) for _, tag := range device.Tags { @@ -192,6 +192,8 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error { } d.Set("tags", tags) + provisionerAddress := "" + networks := make([]map[string]interface{}, 0, 1) for _, ip := range device.Network { network := make(map[string]interface{}) @@ -201,9 +203,21 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error { network["cidr"] = ip.Cidr network["public"] = ip.Public networks = append(networks, network) + if ip.Family == 4 && ip.Public == true { + provisionerAddress = ip.Address + } } d.Set("network", networks) + log.Printf("[DEBUG] Provisioner Address set to %v", provisionerAddress) + + if provisionerAddress != "" { + d.SetConnInfo(map[string]string{ + "type": "ssh", + "host": provisionerAddress, + }) + } + return nil }