Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add google_eventarc_enrollment resource #13284

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
6e909d9
Add MessageBus to mmv1
tommyreddad Jan 30, 2025
b6bd7ab
Re-add the message_bus_id
tommyreddad Jan 30, 2025
01a189c
Fix message_bus_id and tests
tommyreddad Jan 30, 2025
126c6b1
More changes
tommyreddad Jan 30, 2025
7d1da67
Add Pipeline
tommyreddad Jan 30, 2025
1817187
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 6, 2025
a9b7287
Add update test. Add cmek docs
tommyreddad Feb 6, 2025
069c283
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 6, 2025
f650841
Bootstrap network attachment in tests; Use region env var
tommyreddad Feb 6, 2025
827ff61
Add test coverage
tommyreddad Feb 6, 2025
127ef9b
Remove env-var region and add avro test
tommyreddad Feb 6, 2025
99b1359
Add cmek test and attempt update test
tommyreddad Feb 7, 2025
9ebc776
Adjust update test
tommyreddad Feb 7, 2025
a3f6147
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 11, 2025
68d8294
Fix yamllint
tommyreddad Feb 11, 2025
483c10a
Add labels annotations and display name
tommyreddad Feb 11, 2025
dc7370b
Test labels and annotations
tommyreddad Feb 11, 2025
2d35ce6
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 11, 2025
aa647cf
Annotations, labels, formatting
tommyreddad Feb 11, 2025
0783dd1
Simplify updated pipeline
tommyreddad Feb 12, 2025
7c71012
Use region env var and waits in update test
tommyreddad Feb 12, 2025
2170cc7
Enrollment yaml initial commit
tommyreddad Feb 12, 2025
2db9caa
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 21, 2025
3ad38b8
Merge branch 'messagebus' into enrollment
tommyreddad Feb 21, 2025
b5632d6
Merge branch 'pipeline' into enrollment
tommyreddad Feb 21, 2025
eed7f9a
Add Enrollment update test
tommyreddad Feb 24, 2025
d8d069e
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 24, 2025
3ffbb0b
Merge branch 'messagebus' into pipeline
tommyreddad Feb 24, 2025
b3016fb
Add coverage for message_bus destination in pipeline
tommyreddad Feb 24, 2025
1c98502
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 25, 2025
6a42143
Fix pipeline log config
tommyreddad Feb 25, 2025
723b8d8
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 26, 2025
816ce74
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 26, 2025
acd6266
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Feb 28, 2025
5a6a531
Bootstrap IAM in pipeline tests
tommyreddad Mar 3, 2025
03db782
Renama tests and make update test more comprehensive
tommyreddad Mar 3, 2025
c990e5e
force replace
tommyreddad Mar 5, 2025
c58c3da
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Mar 5, 2025
d98c394
Fix yamllint
tommyreddad Mar 5, 2025
67d4543
Remove required log severity
tommyreddad Mar 5, 2025
b8ca9c4
Fix descriptions
tommyreddad Mar 5, 2025
8e603c2
Support mutable pipeline
tommyreddad Mar 6, 2025
4a04c57
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Mar 6, 2025
7de30d7
Remove diff suppress
tommyreddad Mar 6, 2025
ef1ada6
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Mar 6, 2025
286512e
Merge branch 'pipeline' into enrollment
tommyreddad Mar 6, 2025
41b461c
Initial attempt at enrollment update test
tommyreddad Mar 6, 2025
5145ab7
Remove enrollment update from message bus tests
tommyreddad Mar 6, 2025
13aab46
Use pub/sub pipeline and wait for network attachment
tommyreddad Mar 7, 2025
ae6c7e3
Merge branch 'main' of github.com:GoogleCloudPlatform/magic-modules i…
tommyreddad Mar 11, 2025
17c1cc8
Clean
tommyreddad Mar 11, 2025
e53d3e9
use project_id
tommyreddad Mar 11, 2025
34b844f
Add TODO for pipeline update
tommyreddad Mar 11, 2025
73d24bf
try to trigger GitHub actions
tommyreddad Mar 11, 2025
1a43533
Keep original message bus alive during update
tommyreddad Mar 11, 2025
1cf54ce
Mark message_bus as immutable and adjust tests accordingly
tommyreddad Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions mmv1/products/eventarc/Enrollment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright 2025 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: Enrollment
description: |
The Eventarc Enrollment resource
base_url: projects/{{project}}/locations/{{location}}/enrollments
update_mask: true
self_link: projects/{{project}}/locations/{{location}}/enrollments/{{enrollment_id}}
create_url: projects/{{project}}/locations/{{location}}/enrollments?enrollmentId={{enrollment_id}}
update_verb: PATCH
id_format: projects/{{project}}/locations/{{location}}/enrollments/{{enrollment_id}}
import_format:
- projects/{{project}}/locations/{{location}}/enrollments/{{enrollment_id}}
autogen_async: true
async:
actions: ['create', 'update', 'delete']
operation:
timeouts:
insert_minutes: 20
update_minutes: 20
delete_minutes: 20
base_url: '{{op_id}}'
type: OpAsync
result:
resource_inside_response: true
examples:
- name: eventarc_enrollment_with_pipeline_destination
primary_resource_id: primary
vars:
enrollment_id: some-enrollment
pipeline_id: some-pipeline
message_bus_id: some-message-bus
network_attachment_name: some-network-attachment
test_env_vars:
project_id: 'PROJECT_NAME'
exclude_test: true
parameters:
- name: location
type: String
description: Resource ID segment making up resource `name`. It identifies the resource within its parent collection as described in https://google.aip.dev/122.
immutable: true
url_param_only: true
required: true
- name: enrollmentId
type: String
description: |-
The user-provided ID to be assigned to the Enrollment. It should match the
format `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.
immutable: true
url_param_only: true
required: true
properties:
- name: displayName
type: String
description: Resource display name.
- name: messageBus
type: String
description: |-
Resource name of the message bus identifying the source of the messages. It
matches the form
projects/{project}/locations/{location}/messageBuses/{messageBus}.
required: true
immutable: true
- name: name
type: String
description: |-
Resource name of the form
projects/{project}/locations/{location}/enrollments/{enrollment}
output: true
- name: etag
type: String
description: |-
This checksum is computed by the server based on the value of other
fields, and might be sent only on update and delete requests to ensure that
the client has an up-to-date value before proceeding.
output: true
- name: createTime
type: String
description: The creation time.
output: true
- name: updateTime
type: String
description: The last-modified time.
output: true
- name: labels
type: KeyValueLabels
description: Resource labels.
- name: celMatch
type: String
description: A CEL expression identifying which messages this enrollment applies to.
required: true
- name: destination
type: String
description: |-
Destination is the Pipeline that the Enrollment is delivering to. It must
point to the full resource name of a Pipeline. Format:
"projects/{PROJECT_ID}/locations/{region}/pipelines/{PIPELINE_ID)"
required: true
- name: uid
type: String
description: |-
Server assigned unique identifier for the channel. The value is a UUID4
string and guaranteed to remain unchanged until the resource is deleted.
output: true
- name: annotations
type: KeyValueAnnotations
description: Resource annotations.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "google_eventarc_enrollment" "{{$.PrimaryResourceId}}" {
location = "us-central1"
enrollment_id = "{{index $.Vars "enrollment_id"}}"
message_bus = google_eventarc_message_bus.primary.id
destination = google_eventarc_pipeline.pipeline.id
cel_match = "message.type == 'google.cloud.dataflow.job.v1beta3.statusChanged'"
}

resource "google_eventarc_pipeline" "pipeline" {
location = "us-central1"
pipeline_id = "{{index $.Vars "pipeline_id"}}"
destinations {
http_endpoint {
uri = "https://10.77.0.0:80/route"
}
network_config {
network_attachment = "projects/{{index $.TestEnvVars "project_id"}}/regions/us-central1/networkAttachments/{{index $.Vars "network_attachment_name"}}"
}
}
}

resource "google_eventarc_message_bus" "message_bus" {
location = "us-central1"
message_bus_id = "{{index $.Vars "message_bus_id"}}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package eventarc_test

import (
"fmt"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
)

func testAccCheckEventarcEnrollmentDestroyProducer(t *testing.T) func(s *terraform.State) error {
return func(s *terraform.State) error {
for name, rs := range s.RootModule().Resources {
if rs.Type != "google_eventarc_enrollment" {
continue
}
if strings.HasPrefix(name, "data.") {
continue
}

config := acctest.GoogleProviderConfig(t)

url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{EventarcBasePath}}projects/{{project}}/locations/{{location}}/enrollments/{{name}}")
if err != nil {
return err
}

billingProject := ""

if config.BillingProject != "" {
billingProject = config.BillingProject
}

_, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Config: config,
Method: "GET",
Project: billingProject,
RawURL: url,
UserAgent: config.UserAgent,
})
if err == nil {
return fmt.Errorf("EventarcEnrollment still exists at %s", url)
}
}

return nil
}
}
Loading
Loading