@@ -34,6 +34,12 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
34
34
spot := d .Get ("spot" ).(bool )
35
35
spotPrice := d .Get ("spot_price" ).(float64 )
36
36
37
+ metadata := map [string ]* string {}
38
+ for key , value := range d .Get ("metadata" ).(map [string ]interface {}) {
39
+ stringValue := value .(string )
40
+ metadata [key ] = & stringValue
41
+ }
42
+
37
43
image := d .Get ("image" ).(string )
38
44
if image == "" {
39
45
image = "Canonical:UbuntuServer:18.04-LTS:latest"
@@ -61,6 +67,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
61
67
gpName ,
62
68
resources.Group {
63
69
Location : to .StringPtr (region ),
70
+ Tags : metadata ,
64
71
})
65
72
if err != nil {
66
73
return err
@@ -73,6 +80,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
73
80
gpName ,
74
81
nsgName ,
75
82
network.SecurityGroup {
83
+ Tags : metadata ,
76
84
Location : to .StringPtr (region ),
77
85
SecurityGroupPropertiesFormat : & network.SecurityGroupPropertiesFormat {
78
86
SecurityRules : & []network.SecurityRule {
@@ -106,6 +114,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
106
114
gpName ,
107
115
ipName ,
108
116
network.PublicIPAddress {
117
+ Tags : metadata ,
109
118
Name : to .StringPtr (ipName ),
110
119
Location : to .StringPtr (region ),
111
120
PublicIPAddressPropertiesFormat : & network.PublicIPAddressPropertiesFormat {
@@ -126,6 +135,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
126
135
gpName ,
127
136
vnetName ,
128
137
network.VirtualNetwork {
138
+ Tags : metadata ,
129
139
Location : to .StringPtr (region ),
130
140
VirtualNetworkPropertiesFormat : & network.VirtualNetworkPropertiesFormat {
131
141
AddressSpace : & network.AddressSpace {
@@ -163,6 +173,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
163
173
164
174
nicClient , _ := getNicClient (subscriptionID )
165
175
nicParams := network.Interface {
176
+ Tags : metadata ,
166
177
Name : to .StringPtr (nicName ),
167
178
Location : to .StringPtr (region ),
168
179
InterfacePropertiesFormat : & network.InterfacePropertiesFormat {
@@ -188,6 +199,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
188
199
189
200
vmClient , _ := getVMClient (subscriptionID )
190
201
vmSettings := compute.VirtualMachine {
202
+ Tags : metadata ,
191
203
Location : to .StringPtr (region ),
192
204
VirtualMachineProperties : & compute.VirtualMachineProperties {
193
205
HardwareProfile : & compute.HardwareProfile {
0 commit comments