forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
artifactregistry: implement upstream credentials (GoogleCloudPlatform…
…#9439) * implemented remote auth * add IAM settings to test
- Loading branch information
1 parent
979b65f
commit 4debe64
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
mmv1/templates/terraform/examples/artifact_registry_repository_remote_custom.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
data "google_project" "project" {} | ||
|
||
resource "google_secret_manager_secret" "<%= ctx[:vars]['secret_resource_id'] %>" { | ||
secret_id = "<%= ctx[:vars]['secret_id'] %>" | ||
replication { | ||
auto {} | ||
} | ||
} | ||
|
||
resource "google_secret_manager_secret_version" "<%= ctx[:vars]['secret_resource_id'] %>_version" { | ||
secret = google_secret_manager_secret.<%= ctx[:vars]['secret_resource_id'] %>.id | ||
secret_data = "<%= ctx[:vars]['secret_data'] %>" | ||
} | ||
|
||
resource "google_secret_manager_secret_iam_member" "secret-access" { | ||
secret_id = google_secret_manager_secret.<%= ctx[:vars]['secret_resource_id'] %>.id | ||
role = "roles/secretmanager.secretAccessor" | ||
member = "serviceAccount:service-${data.google_project.project.number}@gcp-sa-artifactregistry.iam.gserviceaccount.com" | ||
} | ||
|
||
resource "google_artifact_registry_repository" "<%= ctx[:primary_resource_id] %>" { | ||
location = "us-central1" | ||
repository_id = "<%= ctx[:vars]['repository_id'] %>" | ||
description = "<%= ctx[:vars]['description'] %>" | ||
format = "DOCKER" | ||
mode = "REMOTE_REPOSITORY" | ||
remote_repository_config { | ||
description = "docker hub with custom credentials" | ||
docker_repository { | ||
public_repository = "DOCKER_HUB" | ||
} | ||
upstream_credentials { | ||
username_password_credentials { | ||
username = "<%= ctx[:vars]['username'] %>" | ||
password_secret_version = google_secret_manager_secret_version.<%= ctx[:vars]['secret_resource_id'] %>_version.name | ||
} | ||
} | ||
} | ||
} |