File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111# Terraform state and providers
1212/.terraform /
13+ .terraform /
1314
1415# Ignore all content inside environments directories...
1516** /environments /*
Original file line number Diff line number Diff line change 1515
1616set -e
1717
18+ # --- Argument Parsing ---
19+ TARGET_VERSION=" latest"
20+ while [[ " $# " -gt 0 ]]; do
21+ case $1 in
22+ -v|--version) TARGET_VERSION=" $2 " ; shift ;;
23+ * ) warn " Unknown parameter: $1 " ; echo " Usage: ./deploy.sh [--version v1.2.0]" ; exit 1 ;;
24+ esac
25+ shift
26+ done
27+
28+ info " Target Release Version: ${C_YELLOW}${TARGET_VERSION}${C_RESET} "
29+
1830# --- Configuration ---
19- REQUIRED_TERRAFORM_VERSION=" 1.15.1 "
31+ REQUIRED_TERRAFORM_VERSION=" 1.15.5 "
2032UPSTREAM_REPO_URL=" https://github.com/GoogleCloudPlatform/gcc-creative-studio"
2133TEMPLATE_ENV_DIR=" environments/example"
2234DEFAULT_ENV_NAME=" dev"
@@ -312,6 +324,13 @@ configure_environment() {
312324 info " Configuring terraform.tfvars..."
313325 sed -i.bak " s|^[#[:space:]]*project_id[[:space:]]*=.*|project_id = \" $GCP_PROJECT_ID \" |g" " $TFVARS_FILE_PATH "
314326 sed -i.bak " s|^[#[:space:]]*environment[[:space:]]*=.*|environment = \" $ENV_NAME \" |g" " $TFVARS_FILE_PATH "
327+
328+ # Ensure the target version is passed to Terraform
329+ if grep -q " app_version" " $TFVARS_FILE_PATH " ; then
330+ sed -i.bak " s|^[#[:space:]]*app_version[[:space:]]*=.*|app_version = \" $TARGET_VERSION \" |g" " $TFVARS_FILE_PATH " && rm -f " ${TFVARS_FILE_PATH} .bak"
331+ else
332+ echo -e " \napp_version = \" $TARGET_VERSION \" " >> " $TFVARS_FILE_PATH "
333+ fi
315334
316335 prompt_and_update_tfvar " Region to deploy resources into" " us-central1" " region" " DEPLOY_REGION"
317336 prompt_and_update_tfvar " Resource naming prefix" " cs" " resource_prefix" " RES_PREFIX"
Original file line number Diff line number Diff line change @@ -16,12 +16,17 @@ module "compute" {
1616 region = var. region
1717 resource_prefix = var. resource_prefix
1818 environment = var. environment
19+
20+ # The deployment script dynamically sets this value (e.g., "latest" or "v1.2.0")
21+ app_version = var. app_version
1922
2023 # Direct VPC routing configurations
2124 vpc_subnet_name = module. network . cloud_run_subnet_name
2225 database_ip = module. database . private_ip_address
23- image_url = " ${ module . artifact . repository_url } /${ var . backend_image_name } :${ var . backend_image_tag } "
26+
27+ # Dynamically construct the image URL using the injected app_version
28+ image_url = " ${ module . artifact . repository_url } /${ var . backend_image_name } :${ var . app_version } "
2429
2530 # References the list keys to configure secret environment block mappings
26- secret_ids = var. application_secrets
27- }
31+ secret_ids = var. application_secrets
32+ }
Original file line number Diff line number Diff line change 11# infra/modules/artifact-registry/main.tf
22
3- resource "google_artifact_registry_repository" "ghcr_proxy " {
3+ resource "google_artifact_registry_repository" "cstudio_repo " {
44 location = var. region
55 repository_id = " ${ var . resource_prefix } -${ var . environment } -${ var . repository_id } "
6- description = " Regional proxy for GHCR with vulnerability scanning"
6+ description = " Local private registry for Creative Studio with vulnerability scanning"
77 format = " DOCKER"
88
9- # Remote Repository Mode
10- mode = " REMOTE_REPOSITORY"
11-
12- remote_repository_config {
13- description = " Proxy for GitHub Container Registry"
14- docker_repository {
15- custom_repository {
16- uri = var. remote_uri
17- }
18- }
19- }
20-
219 # Explicitly enable vulnerability scanning
2210 # Note: This requires 'containerscanning.googleapis.com' to be enabled in the project
2311 # Ensure the mirror scans every image it caches
@@ -35,7 +23,7 @@ resource "google_artifact_registry_repository" "ghcr_proxy" {
3523 }
3624
3725 labels = merge (var. labels , {
38- component = " security-mirror "
26+ component = " artifact-registry "
3927 region = var.region
4028 })
4129}
Original file line number Diff line number Diff line change 11output "repository_id" {
22 description = " The ID of the Artifact Registry repository."
3- value = google_artifact_registry_repository. ghcr_proxy . repository_id
3+ value = google_artifact_registry_repository. cstudio_repo . repository_id
44}
55
66output "repository_name" {
77 description = " The fully qualified name of the repository."
8- value = google_artifact_registry_repository. ghcr_proxy . name
8+ value = google_artifact_registry_repository. cstudio_repo . name
99}
1010
11+
1112output "repository_url" {
12- description = " The URL of the repository (without image name)."
13- value = " ${ var . region } -docker.pkg.dev/${ var . project_id } /${ google_artifact_registry_repository . ghcr_proxy . repository_id } "
13+ description = " The fully qualified URL to the local Docker repository."
14+ # Format: us-central1-docker.pkg.dev/project-id/cs-dev-repo
15+ value = " ${ google_artifact_registry_repository . cstudio_repo . location } -docker.pkg.dev/${ google_artifact_registry_repository . cstudio_repo . project } /${ google_artifact_registry_repository . cstudio_repo . repository_id } "
1416}
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ locals {
4242
4343resource "google_cloud_run_v2_service" "backend" {
4444 name = var. service_name
45- location = var. gcp_region
45+ location = var. region
4646 custom_audiences = var. custom_audiences
4747 deletion_protection = false
4848
Original file line number Diff line number Diff line change @@ -138,3 +138,9 @@ variable "run_sa_project_roles" {
138138 " roles/secretmanager.secretAccessor" ,
139139 ]
140140}
141+
142+ variable "app_version" {
143+ type = string
144+ description = " version of the creative studio app we're deploying"
145+ default = " latest"
146+ }
File renamed without changes.
Original file line number Diff line number Diff line change @@ -82,4 +82,8 @@ variable "labels" {
8282 default = {}
8383}
8484
85-
85+ variable "app_version" {
86+ type = string
87+ description = " version of the creative studio app we're deploying"
88+ default = " latest"
89+ }
You can’t perform that action at this time.
0 commit comments