Skip to content

Commit 14361c1

Browse files
authored
Multicast consumer association (#15754)
1 parent a41878d commit 14361c1

File tree

3 files changed

+301
-0
lines changed

3 files changed

+301
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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: MulticastConsumerAssociation
16+
description: Create a multicast consumer association in the specified location
17+
of the current project.
18+
base_url: projects/{{project}}/locations/{{location}}/multicastConsumerAssociations
19+
update_mask: true
20+
self_link: projects/{{project}}/locations/{{location}}/multicastConsumerAssociations/{{multicast_consumer_association_id}}
21+
create_url: projects/{{project}}/locations/{{location}}/multicastConsumerAssociations?multicastConsumerAssociationId={{multicast_consumer_association_id}}
22+
update_verb: PATCH
23+
id_format: projects/{{project}}/locations/{{location}}/multicastConsumerAssociations/{{multicast_consumer_association_id}}
24+
import_format:
25+
- projects/{{project}}/locations/{{location}}/multicastConsumerAssociations/{{multicast_consumer_association_id}}
26+
examples:
27+
- name: network_services_multicast_consumer_association_basic
28+
primary_resource_id: mca_test
29+
vars:
30+
network_name: test-network-mca
31+
domain_name: test-domain-mca
32+
domain_activation_name: test-domain-activation-mca
33+
consumer_association_name: test-consumer-association-mca
34+
autogen_async: true
35+
async:
36+
operation:
37+
timeouts:
38+
insert_minutes: 20
39+
update_minutes: 20
40+
delete_minutes: 20
41+
base_url: '{{op_id}}'
42+
actions:
43+
- create
44+
- delete
45+
- update
46+
type: OpAsync
47+
result:
48+
resource_inside_response: true
49+
include_project: false
50+
autogen_status: TXVsdGljYXN0Q29uc3VtZXJBc3NvY2lhdGlvbg==
51+
parameters:
52+
- name: location
53+
type: String
54+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
55+
immutable: true
56+
url_param_only: true
57+
required: true
58+
- name: multicastConsumerAssociationId
59+
type: String
60+
description: |-
61+
A unique name for the multicast consumer association.
62+
The name is restricted to letters, numbers, and hyphen, with the first
63+
character a letter, and the last a letter or a number. The name must not
64+
exceed 48 characters.
65+
immutable: true
66+
url_param_only: true
67+
required: true
68+
properties:
69+
- name: createTime
70+
type: String
71+
description: |-
72+
[Output only] The timestamp when the multicast consumer association was
73+
created.
74+
output: true
75+
- name: description
76+
type: String
77+
description: An optional text description of the multicast consumer association.
78+
- name: labels
79+
type: KeyValueLabels
80+
description: Labels as key-value pairs
81+
- name: multicastDomainActivation
82+
type: String
83+
description: |-
84+
The resource name of the multicast domain activation that is in the
85+
same zone as this multicast producer association.
86+
Use the following format:
87+
// `projects/*/locations/*/multicastDomainActivations/*`.
88+
immutable: true
89+
required: true
90+
- name: name
91+
type: String
92+
description: |-
93+
Identifier. The resource name of the multicast consumer association.
94+
Use the following format:
95+
`projects/*/locations/*/multicastConsumerAssociations/*`.
96+
output: true
97+
- name: network
98+
type: String
99+
description: |-
100+
The resource name of the multicast consumer VPC network.
101+
Use following format:
102+
`projects/{project}/locations/global/networks/{network}`.
103+
immutable: true
104+
required: true
105+
- name: placementPolicy
106+
type: String
107+
description: |-
108+
[Output only] A Compute Engine (placement
109+
policy)[https://cloud.google.com/compute/docs/instances/placement-policies-overview]
110+
that can be used to place virtual machine (VM) instances as multicast
111+
consumers close to the multicast infrastructure created for this domain,
112+
on a best effort basis.
113+
output: true
114+
- name: state
115+
type: NestedObject
116+
description: The multicast resource's state.
117+
output: true
118+
properties:
119+
- name: state
120+
type: String
121+
description: |-
122+
The state of the multicast resource.
123+
Possible values:
124+
CREATING
125+
ACTIVE
126+
DELETING
127+
DELETE_FAILED
128+
UPDATING
129+
UPDATE_FAILED
130+
INACTIVE
131+
output: true
132+
- name: uniqueId
133+
type: String
134+
description: |-
135+
[Output only] The Google-generated UUID for the resource. This value is
136+
unique across all multicast consumer association resources. If a consumer
137+
association is deleted and another with the same name is created, the new
138+
consumer association is assigned a different unique_id.
139+
output: true
140+
- name: updateTime
141+
type: String
142+
description: |-
143+
[Output only] The timestamp when the Multicast Consumer Association was
144+
most recently updated.
145+
output: true
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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_services_multicast_domain_activation" "multicast_domain_activation" {
15+
multicast_domain_activation_id = "{{index $.Vars "domain_activation_name"}}"
16+
location = "us-central1-b"
17+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
18+
}
19+
20+
resource "google_network_services_multicast_consumer_association" {{$.PrimaryResourceId}} {
21+
multicast_consumer_association_id = "{{index $.Vars "consumer_association_name"}}"
22+
location = "us-central1-b"
23+
network = google_compute_network.network.id
24+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
25+
depends_on = [google_compute_network.network]
26+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
22+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
23+
"github.com/hashicorp/terraform-provider-google/google/acctest"
24+
"testing"
25+
)
26+
27+
func TestAccNetworkServicesMulticastConsumerAssociation_networkServicesMulticastConsumerAssociationUpdateExample(t *testing.T) {
28+
t.Parallel()
29+
30+
context := map[string]interface{}{
31+
"random_suffix": acctest.RandString(t, 10),
32+
}
33+
34+
acctest.VcrTest(t, resource.TestCase{
35+
PreCheck: func() { acctest.AccTestPreCheck(t) },
36+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
37+
CheckDestroy: testAccCheckNetworkServicesMulticastConsumerAssociationDestroyProducer(t),
38+
Steps: []resource.TestStep{
39+
{
40+
Config: testAccNetworkServicesMulticastConsumerAssociation_networkServicesMulticastConsumerAssociationUpdateExample_full(context),
41+
},
42+
{
43+
ResourceName: "google_network_services_multicast_consumer_association.mca_test",
44+
ImportState: true,
45+
ImportStateVerify: true,
46+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_consumer_association_id", "terraform_labels"},
47+
},
48+
{
49+
Config: testAccNetworkServicesMulticastConsumerAssociation_networkServicesMulticastConsumerAssociationUpdateExample_update(context),
50+
ConfigPlanChecks: resource.ConfigPlanChecks{
51+
PreApply: []plancheck.PlanCheck{
52+
plancheck.ExpectResourceAction("google_network_services_multicast_consumer_association.mca_test", plancheck.ResourceActionUpdate),
53+
},
54+
},
55+
},
56+
{
57+
ResourceName: "google_network_services_multicast_consumer_association.mca_test",
58+
ImportState: true,
59+
ImportStateVerify: true,
60+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_consumer_association_id", "terraform_labels"},
61+
},
62+
},
63+
})
64+
}
65+
66+
func testAccNetworkServicesMulticastConsumerAssociation_networkServicesMulticastConsumerAssociationUpdateExample_full(context map[string]interface{}) string {
67+
return acctest.Nprintf(`
68+
resource "google_compute_network" "network" {
69+
name = "tf-test-test-network-mca%{random_suffix}"
70+
auto_create_subnetworks = false
71+
}
72+
73+
resource "google_network_services_multicast_domain" "multicast_domain" {
74+
multicast_domain_id = "tf-test-test-domain-mca%{random_suffix}"
75+
location = "global"
76+
admin_network = google_compute_network.network.id
77+
connection_config { connection_type="SAME_VPC"}
78+
depends_on = [google_compute_network.network]
79+
}
80+
81+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
82+
multicast_domain_activation_id = "tf-test-test-domain-activation-mca%{random_suffix}"
83+
location = "us-central1-b"
84+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
85+
}
86+
87+
resource "google_network_services_multicast_consumer_association" mca_test {
88+
multicast_consumer_association_id = "tf-test-test-consumer-association-mca%{random_suffix}"
89+
location = "us-central1-b"
90+
network = google_compute_network.network.id
91+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
92+
depends_on = [google_compute_network.network]
93+
}
94+
`, context)
95+
}
96+
97+
func testAccNetworkServicesMulticastConsumerAssociation_networkServicesMulticastConsumerAssociationUpdateExample_update(context map[string]interface{}) string {
98+
return acctest.Nprintf(`
99+
resource "google_compute_network" "network" {
100+
name = "tf-test-test-network-mca%{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-mca%{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_services_multicast_domain_activation" "multicast_domain_activation" {
113+
multicast_domain_activation_id = "tf-test-test-domain-activation-mca%{random_suffix}"
114+
location = "us-central1-b"
115+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
116+
}
117+
118+
resource "google_network_services_multicast_consumer_association" mca_test {
119+
multicast_consumer_association_id = "tf-test-test-consumer-association-mca%{random_suffix}"
120+
location = "us-central1-b"
121+
description = "Updated description"
122+
labels = {
123+
fake_label = "label123"
124+
}
125+
network = google_compute_network.network.id
126+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
127+
depends_on = [google_compute_network.network]
128+
}
129+
`, context)
130+
}

0 commit comments

Comments
 (0)