Skip to content

Commit 7e4826f

Browse files
authored
Multicast group range activation (#15845)
1 parent 2c2d3ac commit 7e4826f

File tree

3 files changed

+346
-0
lines changed

3 files changed

+346
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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: MulticastGroupRangeActivation
16+
description: Create a multicast group range activation in the specified location
17+
of the current project.
18+
references:
19+
guides:
20+
'Create Multicast Producer Association': 'https://docs.cloud.google.com/vpc/docs/multicast/create-group-ranges#activate_the_group_range'
21+
api: 'https://docs.cloud.google.com/vpc/docs/multicast/reference/rest/v1/projects.locations.multicastGroupRangeActivations'
22+
base_url: projects/{{project}}/locations/{{location}}/multicastGroupRangeActivations
23+
update_mask: true
24+
self_link: projects/{{project}}/locations/{{location}}/multicastGroupRangeActivations/{{multicast_group_range_activation_id}}
25+
create_url: projects/{{project}}/locations/{{location}}/multicastGroupRangeActivations?multicastGroupRangeActivationId={{multicast_group_range_activation_id}}
26+
update_verb: PATCH
27+
id_format: projects/{{project}}/locations/{{location}}/multicastGroupRangeActivations/{{multicast_group_range_activation_id}}
28+
import_format:
29+
- projects/{{project}}/locations/{{location}}/multicastGroupRangeActivations/{{multicast_group_range_activation_id}}
30+
examples:
31+
- name: network_services_multicast_group_range_activation_basic
32+
primary_resource_id: mgra_test
33+
vars:
34+
network_name: test-network-mgra
35+
domain_name: test-domain-mgra
36+
domain_activation_name: test-domain-activation-mgra
37+
internal_range_name: test-internal-range-mgra
38+
group_range_name: test-group-range-mgra
39+
group_range_activation_name: test-mgra-mgra
40+
autogen_async: true
41+
async:
42+
operation:
43+
timeouts:
44+
insert_minutes: 20
45+
update_minutes: 20
46+
delete_minutes: 20
47+
base_url: '{{op_id}}'
48+
actions:
49+
- create
50+
- delete
51+
- update
52+
type: OpAsync
53+
result:
54+
resource_inside_response: true
55+
include_project: false
56+
autogen_status: TXVsdGljYXN0R3JvdXBSYW5nZUFjdGl2YXRpb24=
57+
parameters:
58+
- name: location
59+
type: String
60+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
61+
immutable: true
62+
url_param_only: true
63+
required: true
64+
- name: multicastGroupRangeActivationId
65+
type: String
66+
description: |-
67+
A unique name for the multicast group range activation.
68+
The name is restricted to letters, numbers, and hyphen, with the first
69+
character a letter, and the last a letter or a number. The name must not
70+
exceed 48 characters.
71+
immutable: true
72+
url_param_only: true
73+
required: true
74+
properties:
75+
- name: createTime
76+
type: String
77+
description: |-
78+
[Output only] The timestamp when the multicast group range activation was
79+
created.
80+
output: true
81+
- name: description
82+
type: String
83+
description: An optional text description of the multicast group range activation.
84+
- name: ipCidrRange
85+
type: String
86+
description: '[Output only] The multicast group IP address range.'
87+
output: true
88+
- name: labels
89+
type: KeyValueLabels
90+
description: Labels as key-value pairs.
91+
- name: logConfig
92+
type: NestedObject
93+
description: The logging configuration.
94+
properties:
95+
- name: enabled
96+
type: Boolean
97+
description: Whether to enable logging or not.
98+
- name: multicastDomainActivation
99+
type: String
100+
description: |-
101+
The resource name of a multicast domain activation that is in the
102+
same zone as this multicast group.
103+
Use the following format:
104+
`projects/*/locations/*/multicastDomainActivations/*`
105+
immutable: true
106+
required: true
107+
- name: multicastGroupConsumerActivations
108+
type: Array
109+
description: |-
110+
The resource names of associated multicast group consumer activations.
111+
Use the following format:
112+
`projects/*/locations/*/multicastGroupConsumerActivations/*`.
113+
output: true
114+
item_type:
115+
type: String
116+
- name: multicastGroupRange
117+
type: String
118+
description: |-
119+
The resource name of the global multicast group range for the
120+
group. Use the following format:
121+
`projects/*/locations/global/multicastGroupRanges/*`
122+
immutable: true
123+
required: true
124+
- name: name
125+
type: String
126+
description: |-
127+
Identifier. The resource name of the multicast group range activation.
128+
Use the following format:
129+
`projects/*/locations/*/multicastGroupRangeActivations/*`.
130+
output: true
131+
- name: state
132+
type: NestedObject
133+
description: The multicast resource's state.
134+
output: true
135+
properties:
136+
- name: state
137+
type: String
138+
description: |-
139+
The state of the multicast resource.
140+
Possible values:
141+
CREATING
142+
ACTIVE
143+
DELETING
144+
DELETE_FAILED
145+
UPDATING
146+
UPDATE_FAILED
147+
INACTIVE
148+
output: true
149+
- name: uniqueId
150+
type: String
151+
description: |-
152+
[Output only] The Google-generated UUID for the resource. This value is
153+
unique across all multicast group resources. If a group is deleted and
154+
another with the same name is created, the new group is assigned a
155+
different unique_id.
156+
output: true
157+
- name: updateTime
158+
type: String
159+
description: |-
160+
[Output only] The timestamp when the multicast group range activation was
161+
most recently updated.
162+
output: true
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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" "group_range" {
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+
}
28+
29+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
30+
multicast_domain_activation_id = "{{index $.Vars "domain_activation_name"}}"
31+
location = "us-central1-b"
32+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
33+
}
34+
35+
resource "google_network_services_multicast_group_range_activation" {{$.PrimaryResourceId}} {
36+
multicast_group_range_activation_id = "{{index $.Vars "group_range_activation_name"}}"
37+
location = "us-central1-b"
38+
description = "my description"
39+
labels = {
40+
"test-label" = "test-value"
41+
}
42+
multicast_group_range = google_network_services_multicast_group_range.group_range.id
43+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
44+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
package networkservices_test
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
5+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
6+
"github.com/hashicorp/terraform-provider-google/google/acctest"
7+
"testing"
8+
)
9+
10+
func TestAccNetworkServicesMulticastGroupRangeActivation_networkServicesMulticastGroupRangeActivationUpdateExample(t *testing.T) {
11+
t.Parallel()
12+
13+
context := map[string]interface{}{
14+
"random_suffix": acctest.RandString(t, 10),
15+
}
16+
17+
acctest.VcrTest(t, resource.TestCase{
18+
PreCheck: func() { acctest.AccTestPreCheck(t) },
19+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
20+
CheckDestroy: testAccCheckNetworkServicesMulticastGroupRangeActivationDestroyProducer(t),
21+
Steps: []resource.TestStep{
22+
{
23+
Config: testAccNetworkServicesMulticastGroupRangeActivation_networkServicesMulticastGroupRangeActivationUpdateExample_full(context),
24+
},
25+
{
26+
ResourceName: "google_network_services_multicast_group_range_activation.mgra_test",
27+
ImportState: true,
28+
ImportStateVerify: true,
29+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_group_range_activation_id", "terraform_labels"},
30+
},
31+
{
32+
Config: testAccNetworkServicesMulticastGroupRangeActivation_networkServicesMulticastGroupRangeActivationUpdateExample_diff(context),
33+
ConfigPlanChecks: resource.ConfigPlanChecks{
34+
PreApply: []plancheck.PlanCheck{
35+
plancheck.ExpectResourceAction("google_network_services_multicast_group_range_activation.mgra_test", plancheck.ResourceActionUpdate),
36+
},
37+
},
38+
},
39+
{
40+
ResourceName: "google_network_services_multicast_group_range_activation.mgra_test",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_group_range_activation_id", "terraform_labels"},
44+
},
45+
},
46+
})
47+
}
48+
49+
func testAccNetworkServicesMulticastGroupRangeActivation_networkServicesMulticastGroupRangeActivationUpdateExample_full(context map[string]interface{}) string {
50+
return acctest.Nprintf(`
51+
resource "google_compute_network" "network" {
52+
name = "tf-test-test-network-mgra%{random_suffix}"
53+
auto_create_subnetworks = false
54+
}
55+
56+
resource "google_network_services_multicast_domain" "multicast_domain" {
57+
multicast_domain_id = "tf-test-test-domain-mgra%{random_suffix}"
58+
location = "global"
59+
admin_network = google_compute_network.network.id
60+
connection_config { connection_type="SAME_VPC"}
61+
depends_on = [google_compute_network.network]
62+
}
63+
64+
resource "google_network_connectivity_internal_range" "internal_range" {
65+
name = "tf-test-test-internal-range-mgra%{random_suffix}"
66+
network = google_compute_network.network.self_link
67+
usage = "FOR_VPC"
68+
peering = "FOR_SELF"
69+
ip_cidr_range = "224.2.0.2/32"
70+
}
71+
72+
resource "google_network_services_multicast_group_range" "group_range" {
73+
multicast_group_range_id = "tf-test-test-group-range-mgra%{random_suffix}"
74+
location = "global"
75+
reserved_internal_range = google_network_connectivity_internal_range.internal_range.id
76+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
77+
}
78+
79+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
80+
multicast_domain_activation_id = "tf-test-test-domain-activation-mgra%{random_suffix}"
81+
location = "us-central1-b"
82+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
83+
}
84+
85+
resource "google_network_services_multicast_group_range_activation" mgra_test {
86+
multicast_group_range_activation_id = "tf-test-test-mgra-mgra%{random_suffix}"
87+
location = "us-central1-b"
88+
multicast_group_range = google_network_services_multicast_group_range.group_range.id
89+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
90+
log_config {
91+
enabled = true
92+
}
93+
}
94+
`, context)
95+
}
96+
97+
func testAccNetworkServicesMulticastGroupRangeActivation_networkServicesMulticastGroupRangeActivationUpdateExample_diff(context map[string]interface{}) string {
98+
return acctest.Nprintf(`
99+
resource "google_compute_network" "network" {
100+
name = "tf-test-test-network-mgra%{random_suffix}"
101+
auto_create_subnetworks = false
102+
}
103+
104+
resource "google_network_services_multicast_domain" "multicast_domain" {
105+
multicast_domain_id = "tf-test-test-domain-mgra%{random_suffix}"
106+
location = "global"
107+
admin_network = google_compute_network.network.id
108+
connection_config { connection_type="SAME_VPC"}
109+
depends_on = [google_compute_network.network]
110+
}
111+
112+
resource "google_network_connectivity_internal_range" "internal_range" {
113+
name = "tf-test-test-internal-range-mgra%{random_suffix}"
114+
network = google_compute_network.network.self_link
115+
usage = "FOR_VPC"
116+
peering = "FOR_SELF"
117+
ip_cidr_range = "224.2.0.2/32"
118+
}
119+
120+
resource "google_network_services_multicast_group_range" "group_range" {
121+
multicast_group_range_id = "tf-test-test-group-range-mgra%{random_suffix}"
122+
location = "global"
123+
reserved_internal_range = google_network_connectivity_internal_range.internal_range.id
124+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
125+
}
126+
127+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
128+
multicast_domain_activation_id = "tf-test-test-domain-activation-mgra%{random_suffix}"
129+
location = "us-central1-b"
130+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
131+
}
132+
133+
resource "google_network_services_multicast_group_range_activation" mgra_test {
134+
multicast_group_range_activation_id = "tf-test-test-mgra-mgra%{random_suffix}"
135+
location = "us-central1-b"
136+
multicast_group_range = google_network_services_multicast_group_range.group_range.id
137+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
138+
}
139+
`, context)
140+
}

0 commit comments

Comments
 (0)