Skip to content

Commit c2b3e87

Browse files
authored
Multicast producer association (#15753)
1 parent 0960a94 commit c2b3e87

File tree

3 files changed

+273
-0
lines changed

3 files changed

+273
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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: MulticastProducerAssociation
16+
description: Create a multicast producer association 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/enable-producer-network#create-producer'
21+
api: 'https://docs.cloud.google.com/vpc/docs/multicast/reference/rest/v1/projects.locations.multicastProducerAssociations'
22+
base_url: projects/{{project}}/locations/{{location}}/multicastProducerAssociations
23+
update_mask: true
24+
self_link: projects/{{project}}/locations/{{location}}/multicastProducerAssociations/{{multicast_producer_association_id}}
25+
create_url: projects/{{project}}/locations/{{location}}/multicastProducerAssociations?multicastProducerAssociationId={{multicast_producer_association_id}}
26+
update_verb: PATCH
27+
id_format: projects/{{project}}/locations/{{location}}/multicastProducerAssociations/{{multicast_producer_association_id}}
28+
import_format:
29+
- projects/{{project}}/locations/{{location}}/multicastProducerAssociations/{{multicast_producer_association_id}}
30+
examples:
31+
- name: network_services_multicast_producer_association_basic
32+
primary_resource_id: mpa_test
33+
vars:
34+
network_name: test-network-mpa
35+
domain_name: test-domain-mpa
36+
domain_activation_name: test-domain-activation-mpa
37+
producer_association_name: test-producer-association-mpa
38+
autogen_async: true
39+
async:
40+
operation:
41+
timeouts:
42+
insert_minutes: 20
43+
update_minutes: 20
44+
delete_minutes: 20
45+
base_url: '{{op_id}}'
46+
actions:
47+
- create
48+
- delete
49+
- update
50+
type: OpAsync
51+
result:
52+
resource_inside_response: true
53+
include_project: false
54+
autogen_status: TXVsdGljYXN0UHJvZHVjZXJBc3NvY2lhdGlvbg==
55+
parameters:
56+
- name: location
57+
type: String
58+
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
59+
immutable: true
60+
url_param_only: true
61+
required: true
62+
- name: multicastProducerAssociationId
63+
type: String
64+
description: |-
65+
A unique name for the multicast producer association.
66+
The name is restricted to letters, numbers, and hyphen, with the first
67+
character a letter, and the last a letter or a number. The name must not
68+
exceed 48 characters.
69+
immutable: true
70+
url_param_only: true
71+
required: true
72+
properties:
73+
- name: createTime
74+
type: String
75+
description: |-
76+
[Output only] The timestamp when the multicast producer association was
77+
created.
78+
output: true
79+
- name: description
80+
type: String
81+
description: An optional text description of the multicast producer association.
82+
- name: labels
83+
type: KeyValueLabels
84+
description: Labels as key-value pairs
85+
- name: multicastDomainActivation
86+
type: String
87+
description: |-
88+
The resource name of the multicast domain activation that is in the
89+
same zone as this multicast producer association.
90+
Use the following format:
91+
// `projects/*/locations/*/multicastDomainActivations/*`.
92+
immutable: true
93+
required: true
94+
- name: name
95+
type: String
96+
description: |-
97+
Identifier. The resource name of the multicast producer association.
98+
Use the following format:
99+
`projects/*/locations/*/multicastProducerAssociations/*`.
100+
output: true
101+
- name: network
102+
type: String
103+
description: |-
104+
The resource name of the multicast producer VPC network.
105+
Use following format:
106+
`projects/{project}/locations/global/networks/{network}`.
107+
immutable: true
108+
required: true
109+
- name: state
110+
type: NestedObject
111+
description: The multicast resource's state.
112+
output: true
113+
properties:
114+
- name: state
115+
type: String
116+
description: |-
117+
The state of the multicast resource.
118+
Possible values:
119+
CREATING
120+
ACTIVE
121+
DELETING
122+
DELETE_FAILED
123+
UPDATING
124+
UPDATE_FAILED
125+
INACTIVE
126+
output: true
127+
- name: uniqueId
128+
type: String
129+
description: |-
130+
[Output only] The Google-generated UUID for the resource. This value is
131+
unique across all multicast producer association resources. If a producer
132+
association is deleted and another with the same name is created, the new
133+
producer association is assigned a different unique_id.
134+
output: true
135+
- name: updateTime
136+
type: String
137+
description: |-
138+
[Output only] The timestamp when the Multicast Producer Association was
139+
most recently updated.
140+
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_producer_association" {{$.PrimaryResourceId}} {
21+
multicast_producer_association_id = "{{index $.Vars "producer_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: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 TestAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample(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: testAccCheckNetworkServicesMulticastProducerAssociationDestroyProducer(t),
21+
Steps: []resource.TestStep{
22+
{
23+
Config: testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_full(context),
24+
},
25+
{
26+
ResourceName: "google_network_services_multicast_producer_association.mpa_test",
27+
ImportState: true,
28+
ImportStateVerify: true,
29+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_producer_association_id", "terraform_labels"},
30+
},
31+
{
32+
Config: testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_update(context),
33+
ConfigPlanChecks: resource.ConfigPlanChecks{
34+
PreApply: []plancheck.PlanCheck{
35+
plancheck.ExpectResourceAction("google_network_services_multicast_producer_association.mpa_test", plancheck.ResourceActionUpdate),
36+
},
37+
},
38+
},
39+
{
40+
ResourceName: "google_network_services_multicast_producer_association.mpa_test",
41+
ImportState: true,
42+
ImportStateVerify: true,
43+
ImportStateVerifyIgnore: []string{"labels", "location", "multicast_producer_association_id", "terraform_labels"},
44+
},
45+
},
46+
})
47+
}
48+
49+
func testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_full(context map[string]interface{}) string {
50+
return acctest.Nprintf(`
51+
resource "google_compute_network" "network" {
52+
name = "tf-test-test-network-mpa%{random_suffix}"
53+
auto_create_subnetworks = false
54+
}
55+
resource "google_network_services_multicast_domain" "multicast_domain" {
56+
multicast_domain_id = "tf-test-test-domain-mpa%{random_suffix}"
57+
location = "global"
58+
admin_network = google_compute_network.network.id
59+
connection_config { connection_type="SAME_VPC"}
60+
depends_on = [google_compute_network.network]
61+
}
62+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
63+
multicast_domain_activation_id = "tf-test-test-domain-activation-mpa%{random_suffix}"
64+
location = "us-central1-b"
65+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
66+
}
67+
resource "google_network_services_multicast_producer_association" mpa_test {
68+
multicast_producer_association_id = "tf-test-test-producer-association-mpa%{random_suffix}"
69+
location = "us-central1-b"
70+
network = google_compute_network.network.id
71+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
72+
depends_on = [google_compute_network.network]
73+
}
74+
`, context)
75+
}
76+
77+
func testAccNetworkServicesMulticastProducerAssociation_networkServicesMulticastProducerAssociationUpdateExample_update(context map[string]interface{}) string {
78+
return acctest.Nprintf(`
79+
resource "google_compute_network" "network" {
80+
name = "tf-test-test-network-mpa%{random_suffix}"
81+
auto_create_subnetworks = false
82+
}
83+
resource "google_network_services_multicast_domain" "multicast_domain" {
84+
multicast_domain_id = "tf-test-test-domain-mpa%{random_suffix}"
85+
location = "global"
86+
admin_network = google_compute_network.network.id
87+
connection_config { connection_type="SAME_VPC"}
88+
depends_on = [google_compute_network.network]
89+
}
90+
resource "google_network_services_multicast_domain_activation" "multicast_domain_activation" {
91+
multicast_domain_activation_id = "tf-test-test-domain-activation-mpa%{random_suffix}"
92+
location = "us-central1-b"
93+
multicast_domain = google_network_services_multicast_domain.multicast_domain.id
94+
}
95+
resource "google_network_services_multicast_producer_association" mpa_test {
96+
multicast_producer_association_id = "tf-test-test-producer-association-mpa%{random_suffix}"
97+
location = "us-central1-b"
98+
description = "Updated description"
99+
labels = {
100+
fake_label = "label123"
101+
}
102+
network = google_compute_network.network.id
103+
multicast_domain_activation = google_network_services_multicast_domain_activation.multicast_domain_activation.id
104+
depends_on = [google_compute_network.network]
105+
}
106+
`, context)
107+
}

0 commit comments

Comments
 (0)