Skip to content

Commit 0929b55

Browse files
wyardleycesteve
authored andcommitted
compute: added network_id to google_compute_network (GoogleCloudPlatform#12504)
1 parent b669860 commit 0929b55

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

mmv1/products/compute/Network.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,16 @@ properties:
116116
immutable: true
117117
validation:
118118
function: 'verify.ValidateGCEName'
119+
- name: 'networkId'
120+
description: |
121+
The unique identifier for the resource. This identifier is defined by the server.
122+
api_name: id
123+
output: true
119124
- name: 'numericId'
120125
type: String
121126
description: |
122127
The unique identifier for the resource. This identifier is defined by the server.
128+
deprecation_message: '`numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead.'
123129
output: true
124130
- name: 'autoCreateSubnetworks'
125131
type: Boolean

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ 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,
36+
Deprecated: "`numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead.",
3337
},
3438

3539
"gateway_ipv4": {
@@ -100,6 +104,9 @@ func dataSourceGoogleComputeNetworkRead(d *schema.ResourceData, meta interface{}
100104
if err := d.Set("description", network.Description); err != nil {
101105
return fmt.Errorf("Error setting description: %s", err)
102106
}
107+
if err := d.Set("network_id", network.Id); err != nil {
108+
return fmt.Errorf("Error setting network_id: %s", err)
109+
}
103110
if err := d.Set("numeric_id", strconv.Itoa(int(network.Id))); err != nil {
104111
return fmt.Errorf("Error setting numeric_id: %s", err)
105112
}

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. `numeric_id` is deprecated and will be removed in a future major release. Use `network_id` instead.
4042

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

0 commit comments

Comments
 (0)