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

Moved Cloud Run secret support to ga #5410

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions mmv1/products/cloudrun/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ objects:
Defaults to "".
- !ruby/object:Api::Type::NestedObject
name: valueFrom
min_version: beta
description: |-
Source for the environment variable's value. Only supports secret_key_ref.
properties:
Expand Down Expand Up @@ -589,7 +588,6 @@ objects:
https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go
- !ruby/object:Api::Type::Array
name: volumeMounts
min_version: beta
description: |-
Volume to mount into the container's filesystem.
Only supports SecretVolumeSources.
Expand Down Expand Up @@ -629,7 +627,6 @@ objects:
will use the project's default service account.
- !ruby/object:Api::Type::Array
name: volumes
min_version: beta
description: |-
Volume represents a named volume in a container.
item_type: !ruby/object:Api::Type::NestedObject
Expand Down
2 changes: 0 additions & 2 deletions mmv1/products/cloudrun/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
project: :PROJECT_NAME
- !ruby/object:Provider::Terraform::Examples
name: "cloud_run_service_secret_environment_variables"
min_version: beta
primary_resource_id: "default"
primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-srv%s\", context[\"random_suffix\"])"
vars:
Expand All @@ -144,7 +143,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
- "autogenerate_revision_name"
- !ruby/object:Provider::Terraform::Examples
name: "cloud_run_service_secret_volumes"
min_version: beta
primary_resource_id: "default"
primary_resource_name: "fmt.Sprintf(\"tf-test-cloudrun-srv%s\", context[\"random_suffix\"])"
vars:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
data "google_project" "project" {
provider = google-beta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're still going to want this empty block, I bet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Trying to run the tests on my local machine for ga and beta.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests ran successfully both for ga and beta.

for ga:

=== RUN TestAccCloudRunService_secretEnvironmentVariable
=== PAUSE TestAccCloudRunService_secretEnvironmentVariable
=== CONT TestAccCloudRunService_secretEnvironmentVariable
--- PASS: TestAccCloudRunService_secretEnvironmentVariable (76.99s)
PASS

=== RUN TestAccCloudRunService_secretVolume
=== PAUSE TestAccCloudRunService_secretVolume
=== CONT TestAccCloudRunService_secretVolume
--- PASS: TestAccCloudRunService_secretVolume (74.17s)
PASS

for beta:

=== RUN TestAccCloudRunService_secretEnvironmentVariable
=== PAUSE TestAccCloudRunService_secretEnvironmentVariable
=== CONT TestAccCloudRunService_secretEnvironmentVariable
--- PASS: TestAccCloudRunService_secretEnvironmentVariable (78.51s)
PASS

=== RUN TestAccCloudRunService_secretVolume
=== PAUSE TestAccCloudRunService_secretVolume
=== CONT TestAccCloudRunService_secretVolume
--- PASS: TestAccCloudRunService_secretVolume (85.45s)
PASS

}

resource "google_secret_manager_secret" "secret" {
provider = google-beta

secret_id = "<%= ctx[:vars]['secret_id'] %>"
replication {
automatic = true
}
}

resource "google_secret_manager_secret_version" "secret-version-data" {
provider = google-beta

secret = google_secret_manager_secret.secret.name
secret_data = "secret-data"
}

resource "google_secret_manager_secret_iam_member" "secret-access" {
provider = google-beta

secret_id = google_secret_manager_secret.secret.id
role = "roles/secretmanager.secretAccessor"
member = "serviceAccount:${data.google_project.project.number}-compute@developer.gserviceaccount.com"
depends_on = [google_secret_manager_secret.secret]
}

resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta

name = "<%= ctx[:vars]['cloud_run_service_name'] %>"
location = "us-central1"

Expand All @@ -53,7 +44,6 @@ resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" {
metadata {
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
data "google_project" "project" {
provider = google-beta
}

resource "google_secret_manager_secret" "secret" {
provider = google-beta

secret_id = "<%= ctx[:vars]['secret_id'] %>"
replication {
automatic = true
}
}

resource "google_secret_manager_secret_version" "secret-version-data" {
provider = google-beta

secret = google_secret_manager_secret.secret.name
secret_data = "secret-data"
}

resource "google_secret_manager_secret_iam_member" "secret-access" {
provider = google-beta

secret_id = google_secret_manager_secret.secret.id
role = "roles/secretmanager.secretAccessor"
member = "serviceAccount:${data.google_project.project.number}-compute@developer.gserviceaccount.com"
depends_on = [google_secret_manager_secret.secret]
}

resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" {
provider = google-beta

name = "<%= ctx[:vars]['cloud_run_service_name'] %>"
location = "us-central1"

Expand Down Expand Up @@ -58,7 +49,6 @@ resource "google_cloud_run_service" "<%= ctx[:primary_resource_id] %>" {
metadata {
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ resource "google_cloud_run_service" "default" {
`, name, project, concurrency, timeoutSeconds)
}

<% unless version == 'ga' %>
func TestAccCloudRunService_secretVolume(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -223,7 +222,6 @@ resource "google_cloud_run_service" "default" {
namespace = "%s"
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

Expand Down Expand Up @@ -343,7 +341,6 @@ resource "google_cloud_run_service" "default" {
namespace = "%s"
annotations = {
generated-by = "magic-modules"
"run.googleapis.com/launch-stage" = "BETA"
}
}

Expand All @@ -362,4 +359,3 @@ resource "google_cloud_run_service" "default" {
}
`, secretName1, secretName2, name, secretRef, project)
}
<% end -%>