Skip to content

Commit 22e98b6

Browse files
authored
1 parent 4aae141 commit 22e98b6

3 files changed

Lines changed: 342 additions & 0 deletions

File tree

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Copyright 2025 Google Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
---
15+
name: MulticastGroupRange
16+
description: Create a multicast group range in the current project.
17+
base_url: projects/{{project}}/locations/{{location}}/multicastGroupRanges
18+
update_mask: true
19+
self_link: projects/{{project}}/locations/{{location}}/multicastGroupRanges/{{multicast_group_range_id}}
20+
create_url: projects/{{project}}/locations/{{location}}/multicastGroupRanges?multicastGroupRangeId={{multicast_group_range_id}}
21+
update_verb: PATCH
22+
id_format: projects/{{project}}/locations/{{location}}/multicastGroupRanges/{{multicast_group_range_id}}
23+
import_format:
24+
- projects/{{project}}/locations/{{location}}/multicastGroupRanges/{{multicast_group_range_id}}
25+
examples:
26+
- name: network_services_multicast_group_range_basic
27+
primary_resource_id: mgr_test
28+
vars:
29+
network_name: test-mgr-network
30+
domain_name: test-mgr-domain
31+
internal_range_name: test-mgr-internal-range
32+
group_range_name: test-mgr-group-range
33+
autogen_async: true
34+
async:
35+
operation:
36+
timeouts:
37+
insert_minutes: 20
38+
update_minutes: 20
39+
delete_minutes: 20
40+
base_url: '{{op_id}}'
41+
actions:
42+
- create
43+
- delete
44+
- update
45+
type: OpAsync
46+
result:
47+
resource_inside_response: true
48+
include_project: false
49+
autogen_status: TXVsdGljYXN0R3JvdXBSYW5nZQ==
50+
parameters:
51+
- name: location
52+
type: String
53+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
54+
immutable: true
55+
url_param_only: true
56+
required: true
57+
- name: multicastGroupRangeId
58+
type: String
59+
description: |-
60+
A unique name for the multicast group range.
61+
The name is restricted to letters, numbers, and hyphen, with the first
62+
character a letter, and the last a letter or a number. The name must not
63+
exceed 48 characters.
64+
immutable: true
65+
url_param_only: true
66+
required: true
67+
properties:
68+
- name: consumerAcceptList
69+
type: Array
70+
description: |-
71+
A list of consumer projects that are allowed to subscribe to the multicast
72+
IP addresses within the range defined by this MulticastGroupRange. The
73+
project can be specified using its project ID or project number. If left
74+
empty, then all consumer projects are allowed (unless
75+
require_explicit_accept is set to true) once they have VPC networks
76+
associated to the multicast domain. The current max length of the accept
77+
list is 100.
78+
item_type:
79+
type: String
80+
- name: createTime
81+
type: String
82+
description: |-
83+
[Output only] The timestamp when the multicast group range was
84+
created.
85+
output: true
86+
- name: description
87+
type: String
88+
description: An optional text description of the multicast group range.
89+
- name: distributionScope
90+
type: String
91+
description: |-
92+
Multicast group range's distribution scope. Intra-zone or intra-region
93+
cross-zone is supported, with default value being intra-region. Cross
94+
region distribution is not supported.
95+
Possible values:
96+
INTRA_ZONE
97+
INTRA_REGION
98+
immutable: true
99+
- name: ipCidrRange
100+
type: String
101+
description: '[Output only] The multicast group IP address range.'
102+
output: true
103+
- name: labels
104+
type: KeyValueLabels
105+
description: Labels as key-value pairs.
106+
- name: logConfig
107+
type: NestedObject
108+
description: The logging configuration.
109+
properties:
110+
- name: enabled
111+
type: Boolean
112+
description: Whether to enable logging or not.
113+
- name: multicastDomain
114+
type: String
115+
description: |-
116+
The resource name of the multicast domain in which to create this
117+
multicast group range.
118+
Use the following format:
119+
`projects/*/locations/global/multicastDomains/*`.
120+
immutable: true
121+
required: true
122+
- name: name
123+
type: String
124+
description: |-
125+
Identifier. The resource name of the multicast group range.
126+
Use the following format:
127+
`projects/*/locations/global/multicastGroupRanges/*`.
128+
output: true
129+
- name: requireExplicitAccept
130+
type: Boolean
131+
description: Whether an empty consumer_accept_list will deny all consumer projects.
132+
- name: reservedInternalRange
133+
type: String
134+
description: |-
135+
The resource name of the internal range reserved for this
136+
multicast group range.
137+
138+
The internal range must be a Class D address (224.0.0.0 to 239.255.255.255)
139+
and have a prefix length >= 23.
140+
141+
Use the following format:
142+
`projects/*/locations/global/internalRanges/*`.
143+
immutable: true
144+
required: true
145+
- name: state
146+
type: NestedObject
147+
description: The multicast resource's state.
148+
output: true
149+
properties:
150+
- name: state
151+
type: String
152+
description: |-
153+
The state of the multicast resource.
154+
Possible values:
155+
CREATING
156+
ACTIVE
157+
DELETING
158+
DELETE_FAILED
159+
UPDATING
160+
UPDATE_FAILED
161+
INACTIVE
162+
output: true
163+
- name: uniqueId
164+
type: String
165+
description: |-
166+
[Output only] The Google-generated UUID for the resource. This value is
167+
unique across all multicast group range resources. If a group
168+
range is deleted and another with the same name is created, the new
169+
group range is assigned a different unique_id.
170+
output: true
171+
- name: updateTime
172+
type: String
173+
description: |-
174+
[Output only] The timestamp when the multicast group range was most
175+
recently updated.
176+
output: true
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "google_compute_network" "network" {
2+
name = "{{index $.Vars "network_name"}}"
3+
auto_create_subnetworks = false
4+
}
5+
6+
resource "google_network_services_multicast_domain" "multicast_domain" {
7+
multicast_domain_id = "{{index $.Vars "domain_name"}}"
8+
location = "global"
9+
admin_network = google_compute_network.network.id
10+
connection_config { connection_type="SAME_VPC"}
11+
depends_on = [google_compute_network.network]
12+
}
13+
14+
resource "google_network_connectivity_internal_range" "internal_range" {
15+
name = "{{index $.Vars "internal_range_name"}}"
16+
network = google_compute_network.network.self_link
17+
usage = "FOR_VPC"
18+
peering = "FOR_SELF"
19+
ip_cidr_range = "224.2.0.2/32"
20+
}
21+
22+
resource "google_network_services_multicast_group_range" {{$.PrimaryResourceId}} {
23+
multicast_group_range_id = "{{index $.Vars "group_range_name"}}"
24+
location = "global"
25+
reserved_internal_range = google_network_connectivity_internal_range.internal_range.id
26+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
27+
distribution_scope = "INTRA_ZONE"
28+
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package networkservices_test
19+
20+
import (
21+
"testing"
22+
23+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
24+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
25+
"github.com/hashicorp/terraform-provider-google/google/acctest"
26+
)
27+
28+
func TestAccNetworkServicesMulticastGroupRange_networkServicesMulticastGroupRangeUpdate(t *testing.T) {
29+
t.Parallel()
30+
31+
context := map[string]interface{}{
32+
"random_suffix": acctest.RandString(t, 10),
33+
}
34+
35+
acctest.VcrTest(t, resource.TestCase{
36+
PreCheck: func() { acctest.AccTestPreCheck(t) },
37+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
38+
CheckDestroy: testAccCheckNetworkServicesMulticastGroupRangeDestroyProducer(t),
39+
Steps: []resource.TestStep{
40+
{
41+
Config: testAccNetworkServicesMulticastGroupRange_networkServicesMulticastGroupRangeBasicExample_full(context),
42+
},
43+
{
44+
ResourceName: "google_network_services_multicast_group_range.mgr_test",
45+
ImportState: true,
46+
ImportStateVerify: true,
47+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_group_range_id", "terraform_labels"},
48+
},
49+
{
50+
Config: testAccNetworkServicesMulticastGroupRange_networkServicesMulticastGroupRangeBasicExample_update(context),
51+
ConfigPlanChecks: resource.ConfigPlanChecks{
52+
PreApply: []plancheck.PlanCheck{
53+
plancheck.ExpectResourceAction("google_network_services_multicast_group_range.mgr_test", plancheck.ResourceActionUpdate),
54+
},
55+
},
56+
},
57+
{
58+
ResourceName: "google_network_services_multicast_group_range.mgr_test",
59+
ImportState: true,
60+
ImportStateVerify: true,
61+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_group_range_id", "terraform_labels"},
62+
},
63+
},
64+
})
65+
}
66+
67+
func testAccNetworkServicesMulticastGroupRange_networkServicesMulticastGroupRangeBasicExample_full(context map[string]interface{}) string {
68+
return acctest.Nprintf(`
69+
resource "google_compute_network" "network" {
70+
name = "tf-test-test-mgr-network%{random_suffix}"
71+
auto_create_subnetworks = false
72+
}
73+
74+
resource "google_network_services_multicast_domain" "multicast_domain" {
75+
multicast_domain_id = "tf-test-test-mgr-domain%{random_suffix}"
76+
location = "global"
77+
admin_network = google_compute_network.network.id
78+
connection_config { connection_type="SAME_VPC"}
79+
depends_on = [google_compute_network.network]
80+
}
81+
82+
resource "google_network_connectivity_internal_range" "internal_range" {
83+
name = "tf-test-test-mgr-internal-range%{random_suffix}"
84+
network = google_compute_network.network.self_link
85+
usage = "FOR_VPC"
86+
peering = "FOR_SELF"
87+
ip_cidr_range = "224.2.0.2/32"
88+
}
89+
90+
resource "google_network_services_multicast_group_range" mgr_test {
91+
multicast_group_range_id = "tf-test-test-mgr-group-range%{random_suffix}"
92+
location = "global"
93+
description = "my description"
94+
labels = {
95+
fake_label = "label123"
96+
}
97+
reserved_internal_range = google_network_connectivity_internal_range.internal_range.id
98+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
99+
}
100+
`, context)
101+
}
102+
103+
func testAccNetworkServicesMulticastGroupRange_networkServicesMulticastGroupRangeBasicExample_update(context map[string]interface{}) string {
104+
return acctest.Nprintf(`
105+
resource "google_compute_network" "network" {
106+
name = "tf-test-test-mgr-network%{random_suffix}"
107+
auto_create_subnetworks = false
108+
}
109+
110+
resource "google_network_services_multicast_domain" "multicast_domain" {
111+
multicast_domain_id = "tf-test-test-mgr-domain%{random_suffix}"
112+
location = "global"
113+
admin_network = google_compute_network.network.id
114+
connection_config { connection_type="SAME_VPC"}
115+
depends_on = [google_compute_network.network]
116+
}
117+
118+
resource "google_network_connectivity_internal_range" "internal_range" {
119+
name = "tf-test-test-mgr-internal-range%{random_suffix}"
120+
network = google_compute_network.network.self_link
121+
usage = "FOR_VPC"
122+
peering = "FOR_SELF"
123+
ip_cidr_range = "224.2.0.2/32"
124+
}
125+
126+
resource "google_network_services_multicast_group_range" mgr_test {
127+
multicast_group_range_id = "tf-test-test-mgr-group-range%{random_suffix}"
128+
location = "global"
129+
reserved_internal_range = google_network_connectivity_internal_range.internal_range.id
130+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
131+
consumer_accept_list = ["fake-project-id"]
132+
require_explicit_accept = true
133+
log_config {
134+
enabled = true
135+
}
136+
}
137+
`, context)
138+
}

0 commit comments

Comments
 (0)