Skip to content

Commit 961479b

Browse files
committed
compute: add network_id to google_compute_network
Add `network_id` to `google_compute_network`. It's an integer, not a string, and follows the expected convention for naming. This adds a note deprecating `numeric_id` (to be potentially removed at some later date), which will have the same value, but as a string. Part of terraform-provider-google#20530
1 parent 94d5485 commit 961479b

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

mmv1/products/compute/Network.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,16 @@ properties:
123123
immutable: true
124124
validation:
125125
function: 'verify.ValidateGCEName'
126+
- name: 'networkId'
127+
description: |
128+
The unique identifier for the resource. This identifier is defined by the server.
129+
api_name: id
130+
output: true
126131
- name: 'numericId'
127132
type: String
128133
description: |
129-
The unique identifier for the resource. This identifier is defined by the server.
134+
(Deprecated) The unique identifier for the resource. This identifier is defined by the server.
135+
Use `network_id` instead.
130136
output: true
131137
- name: 'autoCreateSubnetworks'
132138
type: Boolean

mmv1/third_party/terraform/services/compute/data_source_google_compute_network.go.tmpl

+9-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ func DataSourceGoogleComputeNetwork() *schema.Resource {
2424
Computed: true,
2525
},
2626

27-
// TODO: this should eventually be TypeInt, but leaving as
28-
// string for now to match the resource and to avoid a
29-
// breaking change.
27+
"network_id": {
28+
Type: schema.TypeInt,
29+
Computed: true,
30+
},
31+
32+
// Deprecated in favor of network_id
3033
"numeric_id": {
3134
Type: schema.TypeString,
3235
Computed: true,
@@ -104,6 +107,9 @@ func dataSourceGoogleComputeNetworkRead(d *schema.ResourceData, meta interface{}
104107
if err := d.Set("description", network.Description); err != nil {
105108
return fmt.Errorf("Error setting description: %s", err)
106109
}
110+
if err := d.Set("network_id", network.Id); err != nil {
111+
return fmt.Errorf("Error setting network_id: %s", err)
112+
}
107113
if err := d.Set("numeric_id", strconv.Itoa(int(network.Id))); err != nil {
108114
return fmt.Errorf("Error setting numeric_id: %s", err)
109115
}

mmv1/third_party/terraform/services/compute/data_source_google_compute_network_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func testAccDataSourceGoogleNetworkCheck(data_source_name string, resource_name
4545
network_attrs_to_test := []string{
4646
"id",
4747
"name",
48+
"network_id",
4849
"numeric_id",
4950
"description",
5051
"internal_ipv6_range",

mmv1/third_party/terraform/services/compute/resource_compute_network_test.go.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ func TestAccComputeNetwork_numericId(t *testing.T) {
262262
{
263263
Config: testAccComputeNetwork_basic(networkName),
264264
Check: resource.ComposeTestCheckFunc(
265+
resource.TestMatchResourceAttr("google_compute_network.bar", "network_id",regexp.MustCompile("^\\d{16,48}$")),
265266
resource.TestMatchResourceAttr("google_compute_network.bar", "numeric_id",regexp.MustCompile("^\\d{16,48}$")),
266267
resource.TestCheckResourceAttr("google_compute_network.bar", "id", networkId),
267268
),

mmv1/third_party/terraform/website/docs/d/compute_network.html.markdown

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ In addition to the arguments listed above, the following attributes are exported
3636

3737
* `description` - Description of this network.
3838

39-
* `numeric_id` - The numeric unique identifier for the resource.
39+
* `network_id` - The numeric unique identifier for the resource.
40+
41+
* `numeric_id` - (Deprecated) The numeric unique identifier for the resource. Use `network_id` instead.
4042

4143
* `gateway_ipv4` - The IP address of the gateway.
4244

0 commit comments

Comments
 (0)