Skip to content

Commit d68d3c2

Browse files
modular-magiciannat-henderson
authored andcommitted
Allowing GlobalAddress.address to be settable (#2618)
<!-- This change is generated by MagicModules. --> /cc @chrisst
1 parent 4b7b850 commit d68d3c2

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

google/resource_compute_global_address.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func resourceComputeGlobalAddress() *schema.Resource {
4646
Required: true,
4747
ForceNew: true,
4848
},
49+
"address": {
50+
Type: schema.TypeString,
51+
Computed: true,
52+
Optional: true,
53+
ForceNew: true,
54+
},
4955
"address_type": {
5056
Type: schema.TypeString,
5157
Optional: true,
@@ -66,10 +72,6 @@ func resourceComputeGlobalAddress() *schema.Resource {
6672
ValidateFunc: validation.StringInSlice([]string{"IPV4", "IPV6", ""}, false),
6773
DiffSuppressFunc: emptyOrDefaultStringSuppress("IPV4"),
6874
},
69-
"address": {
70-
Type: schema.TypeString,
71-
Computed: true,
72-
},
7375
"creation_timestamp": {
7476
Type: schema.TypeString,
7577
Computed: true,
@@ -92,6 +94,12 @@ func resourceComputeGlobalAddressCreate(d *schema.ResourceData, meta interface{}
9294
config := meta.(*Config)
9395

9496
obj := make(map[string]interface{})
97+
addressProp, err := expandComputeGlobalAddressAddress(d.Get("address"), d, config)
98+
if err != nil {
99+
return err
100+
} else if v, ok := d.GetOkExists("address"); !isEmptyValue(reflect.ValueOf(addressProp)) && (ok || !reflect.DeepEqual(v, addressProp)) {
101+
obj["address"] = addressProp
102+
}
95103
descriptionProp, err := expandComputeGlobalAddressDescription(d.Get("description"), d, config)
96104
if err != nil {
97105
return err
@@ -281,6 +289,10 @@ func flattenComputeGlobalAddressAddressType(v interface{}, d *schema.ResourceDat
281289
return v
282290
}
283291

292+
func expandComputeGlobalAddressAddress(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
293+
return v, nil
294+
}
295+
284296
func expandComputeGlobalAddressDescription(v interface{}, d *schema.ResourceData, config *Config) (interface{}, error) {
285297
return v, nil
286298
}

website/docs/r/compute_global_address.html.markdown

+4-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ The following arguments are supported:
6464
- - -
6565

6666

67+
* `address` -
68+
(Optional)
69+
The static external IP address represented by this resource.
70+
6771
* `description` -
6872
(Optional)
6973
An optional description of this resource.
@@ -88,9 +92,6 @@ The following arguments are supported:
8892
In addition to the arguments listed above, the following computed attributes are exported:
8993

9094

91-
* `address` -
92-
The static external IP address represented by this resource.
93-
9495
* `creation_timestamp` -
9596
Creation timestamp in RFC3339 text format.
9697
* `self_link` - The URI of the created resource.

0 commit comments

Comments
 (0)