From 51013b80a1066b090cc045e4376d15b2025ebd23 Mon Sep 17 00:00:00 2001 From: Steve McGhee Date: Fri, 8 Aug 2025 17:52:30 +0000 Subject: [PATCH 1/3] fixes to build via instructions on empty project. --- .../cloud_deploy_flow/README.md | 7 ++++++- .../cloud_deploy_flow/functions.tf | 16 +++++++++++----- .../cloud_deploy_flow/variables.tf | 3 ++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/reference-architectures/cloud_deploy_flow/README.md b/reference-architectures/cloud_deploy_flow/README.md index 2592f346..933749d9 100644 --- a/reference-architectures/cloud_deploy_flow/README.md +++ b/reference-architectures/cloud_deploy_flow/README.md @@ -106,12 +106,13 @@ demo: event-driven functions. - `eventarc.googleapis.com`: Enables Eventarc for routing events from sources to targets. +- `artifactregistry.googleapis.com`: Allows for image hosting for CI/CD. ## Getting Started To run this demo, follow these steps: -1. **Fork and Clone the Repository**: Start by forking this repository to your +1. **Fork and Clone the Repository**: Start by forking *this* repository to your GitHub account (So you can connect GCP to this repository), then clone it to your local environment. After cloning, change your directory to the deployment demo: @@ -120,12 +121,16 @@ To run this demo, follow these steps: cd platform-engineering/reference-architectures/cloud_deploy_flow ``` + *Note:* you can't use a repo inside an Organization, just use your personal account for this demo. + 2. **Set Up Environment Variables or Variables File**: You can set the necessary variables either by exporting them as environment variables or by creating a `terraform.tfvars` file. Refer to `variables.tf` for more details on each variable. Ensure the values match your Google Cloud project and GitHub configuration. + For the repo-name and repo-owner here, use the repo you just cloned above. + - **Option 1**: Set environment variables manually in your shell: ```bash diff --git a/reference-architectures/cloud_deploy_flow/functions.tf b/reference-architectures/cloud_deploy_flow/functions.tf index 8dd4d3f7..d417f424 100644 --- a/reference-architectures/cloud_deploy_flow/functions.tf +++ b/reference-architectures/cloud_deploy_flow/functions.tf @@ -30,21 +30,26 @@ resource "google_storage_bucket_object" "functions" { } # Cloud Functions configuration map + locals { cloud_functions = { - "create-release" = { + "createRelease" = { + name = "create-release" entry_point = "deployTrigger" pubsub_topic = google_pubsub_topic.topics["cloud-builds"].id } - "cloud-deploy-interactions" = { + "cloudDeployInteractions" = { + name = "cloud-deploy-interactions" entry_point = "cloudDeployInteractions" pubsub_topic = google_pubsub_topic.topics["deploy-commands"].id } - "cloud-deploy-operations" = { + "cloudDeployOperations" = { + name = "cloud-deploy-operations" entry_point = "cloudDeployOperations" pubsub_topic = google_pubsub_topic.topics["clouddeploy-operations"].id } - "cloud-deploy-approvals" = { + "cloudDeployApprovals" = { + name = "cloud-deploy-approvals" entry_point = "cloudDeployApprovals" pubsub_topic = google_pubsub_topic.topics["clouddeploy-approvals"].id } @@ -53,9 +58,10 @@ locals { # Create Cloud Functions using for_each resource "google_cloudfunctions2_function" "functions" { + #for_each = local.cloud_functions for_each = local.cloud_functions - name = each.key + name = each.value.name project = data.google_project.project.project_id location = var.region diff --git a/reference-architectures/cloud_deploy_flow/variables.tf b/reference-architectures/cloud_deploy_flow/variables.tf index c08dd984..d1fb949d 100644 --- a/reference-architectures/cloud_deploy_flow/variables.tf +++ b/reference-architectures/cloud_deploy_flow/variables.tf @@ -35,7 +35,8 @@ locals { "cloudresourcemanager.googleapis.com", "run.googleapis.com", "cloudfunctions.googleapis.com", - "eventarc.googleapis.com" + "eventarc.googleapis.com", + "artifactregistry.googleapis.com" ] # List of roles for Cloud Build SA sa_roles_list = [ From ad597c9025197abc0412adcf10d17b2ba8646226 Mon Sep 17 00:00:00 2001 From: Steve McGhee Date: Fri, 8 Aug 2025 12:11:08 -0700 Subject: [PATCH 2/3] Update README.md for linter --- .../cloud_deploy_flow/README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/reference-architectures/cloud_deploy_flow/README.md b/reference-architectures/cloud_deploy_flow/README.md index 933749d9..4b3d570c 100644 --- a/reference-architectures/cloud_deploy_flow/README.md +++ b/reference-architectures/cloud_deploy_flow/README.md @@ -121,9 +121,10 @@ To run this demo, follow these steps: cd platform-engineering/reference-architectures/cloud_deploy_flow ``` - *Note:* you can't use a repo inside an Organization, just use your personal account for this demo. + Note: you can't use a repo inside an Organization, just use your personal + account for this demo. -2. **Set Up Environment Variables or Variables File**: You can set the +3. **Set Up Environment Variables or Variables File**: You can set the necessary variables either by exporting them as environment variables or by creating a `terraform.tfvars` file. Refer to `variables.tf` for more details on each variable. Ensure the values match your Google Cloud project and @@ -150,7 +151,7 @@ To run this demo, follow these steps: github_repo = "your-github-repo-name" ``` -3. **Initialize and Apply Terraform**: With the environment variables set, +4. **Initialize and Apply Terraform**: With the environment variables set, initialize and apply the Terraform configuration: ```bash @@ -161,7 +162,7 @@ To run this demo, follow these steps: _Note_: Applying Terraform may take a few minutes as it creates the necessary resources. -4. **Connect GitHub Repository to Cloud Build**: Due to occasional issues with +5. **Connect GitHub Repository to Cloud Build**: Due to occasional issues with automatic connections, you may need to manually attach your GitHub repository to Cloud Build in the Google Cloud Console. @@ -175,14 +176,14 @@ To run this demo, follow these steps: Re-run step 3 to ensure all resources are deployed -5. **Navigate to the Demo site**: Once the Terraform setup is complete, switch +6. **Navigate to the Demo site**: Once the Terraform setup is complete, switch to the Demo site directory: ```bash cd platform-engineering/reference-architectures/cloud-deploy-flow/WebsiteDemo ``` -6. **Authenticate and Run the Demo site**: +7. **Authenticate and Run the Demo site**: - Ensure you are running these commands on a **local machine** or a machine with **GUI/web browser access**, as Cloud Shell may not fully support @@ -210,7 +211,7 @@ To run this demo, follow these steps: - Open `http://localhost:8080` in your browser to observe the demo site in action. -7. **Trigger a Build in Cloud Build**: +8. **Trigger a Build in Cloud Build**: - Initiate a build in Cloud Build. As the build progresses, messages will display on the demo site, allowing you to follow each step in the @@ -218,7 +219,7 @@ To run this demo, follow these steps: - You can also monitor the deployment rollout on [Google Cloud Console](https://console.cloud.google.com). -8. **Approve the Rollout**: When an approval message is received, you’ll need +9. **Approve the Rollout**: When an approval message is received, you’ll need to send a response to complete the deployment. Use the message data provided and add a `ManualApproval` field: @@ -236,7 +237,7 @@ To run this demo, follow these steps: } ``` -9. **Verify the Deployment**: Once the approval is processed, the deployment +10. **Verify the Deployment**: Once the approval is processed, the deployment should finish rolling out. Check the Cloud Deploy dashboard in the Google Cloud Console to confirm the deployment status. From 02f365c1fc118e7e0847aa4f527e32feb560a322 Mon Sep 17 00:00:00 2001 From: Benjamin Good Date: Fri, 8 Aug 2025 20:40:14 +0000 Subject: [PATCH 3/3] Fixing linter errors. --- .../cloud_deploy_flow/README.md | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/reference-architectures/cloud_deploy_flow/README.md b/reference-architectures/cloud_deploy_flow/README.md index 4b3d570c..48043535 100644 --- a/reference-architectures/cloud_deploy_flow/README.md +++ b/reference-architectures/cloud_deploy_flow/README.md @@ -112,25 +112,26 @@ demo: To run this demo, follow these steps: -1. **Fork and Clone the Repository**: Start by forking *this* repository to your - GitHub account (So you can connect GCP to this repository), then clone it to - your local environment. After cloning, change your directory to the +1. **Fork and Clone the Repository**: Start by forking _this_ repository to + your GitHub account (So you can connect GCP to this repository), then clone + it to your local environment. After cloning, change your directory to the deployment demo: ```bash cd platform-engineering/reference-architectures/cloud_deploy_flow ``` - Note: you can't use a repo inside an Organization, just use your personal - account for this demo. + Note: you can't use a repository inside an Organization, just use your + personal account for this demo. -3. **Set Up Environment Variables or Variables File**: You can set the +2. **Set Up Environment Variables or Variables File**: You can set the necessary variables either by exporting them as environment variables or by creating a `terraform.tfvars` file. Refer to `variables.tf` for more details on each variable. Ensure the values match your Google Cloud project and GitHub configuration. - For the repo-name and repo-owner here, use the repo you just cloned above. + For the repo-name and repo-owner here, use the repository you just cloned + above. - **Option 1**: Set environment variables manually in your shell: @@ -151,7 +152,7 @@ To run this demo, follow these steps: github_repo = "your-github-repo-name" ``` -4. **Initialize and Apply Terraform**: With the environment variables set, +3. **Initialize and Apply Terraform**: With the environment variables set, initialize and apply the Terraform configuration: ```bash @@ -162,7 +163,7 @@ To run this demo, follow these steps: _Note_: Applying Terraform may take a few minutes as it creates the necessary resources. -5. **Connect GitHub Repository to Cloud Build**: Due to occasional issues with +4. **Connect GitHub Repository to Cloud Build**: Due to occasional issues with automatic connections, you may need to manually attach your GitHub repository to Cloud Build in the Google Cloud Console. @@ -176,14 +177,14 @@ To run this demo, follow these steps: Re-run step 3 to ensure all resources are deployed -6. **Navigate to the Demo site**: Once the Terraform setup is complete, switch +5. **Navigate to the Demo site**: Once the Terraform setup is complete, switch to the Demo site directory: ```bash cd platform-engineering/reference-architectures/cloud-deploy-flow/WebsiteDemo ``` -7. **Authenticate and Run the Demo site**: +6. **Authenticate and Run the Demo site**: - Ensure you are running these commands on a **local machine** or a machine with **GUI/web browser access**, as Cloud Shell may not fully support @@ -211,7 +212,7 @@ To run this demo, follow these steps: - Open `http://localhost:8080` in your browser to observe the demo site in action. -8. **Trigger a Build in Cloud Build**: +7. **Trigger a Build in Cloud Build**: - Initiate a build in Cloud Build. As the build progresses, messages will display on the demo site, allowing you to follow each step in the @@ -219,7 +220,7 @@ To run this demo, follow these steps: - You can also monitor the deployment rollout on [Google Cloud Console](https://console.cloud.google.com). -9. **Approve the Rollout**: When an approval message is received, you’ll need +8. **Approve the Rollout**: When an approval message is received, you’ll need to send a response to complete the deployment. Use the message data provided and add a `ManualApproval` field: @@ -237,7 +238,7 @@ To run this demo, follow these steps: } ``` -10. **Verify the Deployment**: Once the approval is processed, the deployment +9. **Verify the Deployment**: Once the approval is processed, the deployment should finish rolling out. Check the Cloud Deploy dashboard in the Google Cloud Console to confirm the deployment status.