{"id":18037472,"url":"https://github.com/fpgmaas/cloudrun-example-infra","last_synced_at":"2025-03-27T09:31:35.901Z","repository":{"id":36961689,"uuid":"504414223","full_name":"fpgmaas/cloudrun-example-infra","owner":"fpgmaas","description":"Example Terraform project used in the blogpost 'Deploying a Flask API to Google Cloud Run using Terraform'","archived":false,"fork":false,"pushed_at":"2022-08-19T07:13:05.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-03T20:51:44.235Z","etag":null,"topics":["cloudrun","gcp","gcp-cloud-run","google","google-cloud-run","terraform"],"latest_commit_sha":null,"homepage":"https://fpgmaas.com/blog/deploying-a-flask-api-to-cloudrun-2","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fpgmaas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-17T06:08:45.000Z","updated_at":"2022-11-01T19:53:53.000Z","dependencies_parsed_at":"2022-08-18T01:25:07.332Z","dependency_job_id":null,"html_url":"https://github.com/fpgmaas/cloudrun-example-infra","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fcloudrun-example-infra","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fcloudrun-example-infra/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fcloudrun-example-infra/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fpgmaas%2Fcloudrun-example-infra/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fpgmaas","download_url":"https://codeload.github.com/fpgmaas/cloudrun-example-infra/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222226132,"owners_count":16951818,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudrun","gcp","gcp-cloud-run","google","google-cloud-run","terraform"],"created_at":"2024-10-30T13:10:36.368Z","updated_at":"2024-10-30T13:10:37.144Z","avatar_url":"https://github.com/fpgmaas.png","language":"HCL","readme":"# cloudrun-example-infra\n\nThis is a repository that contains the code used to set up the cloud infrastructure for [this blog post](https://fpgmaas.com/blog/deploying-a-flask-api-to-cloudrun-2). The related GitHub repository with the Flask API can be found [here](https://github.com/fpgmaas/cloudrun-example-api).\n\n## 1. Prerequisites\n\n- A GCP Project with a service account that has the following roles:\n    - Editor\n    - Service Usage Admin\n    - Artifact Registry Administrator\n    - Cloud Run Admin\n    - Project IAM Admin\n\n## 2. Deploying a new version of the infrastructure\n\n- If this is the first time deploying the infrastructure, perform the steps in section 3 of the README first. Otherwise, continue with the steps listed below.\n- Use the service account `docker-pusher` to push a Docker image to the artifact repository. See e.g. [here](https://github.com/fpgmaas/cloudrun-example-api).\n- Set `docker_image` in `main/variables.tf` to the name of the Docker image.\n- Create a Pull Request for merging the branch with your desired changes into `main`. A comment will be added with the output of `terraform plan`.\n- Create a new release through the GitHub UI. This will trigger the workflow that \ncalls `terraform apply`.\n\n## 3. Initializing the repository \u0026 architecture\n\n### 3.1 Setting up the Terrafom state bucket\n\n- Download your service account key in the `.json`-format and store it as `infra_service_account.json`.\n- Run `cp .env.template .env` and add the absolute path to your service account in the `.env` file.\n- Create the bucket for the Terraform backend with:\n    - `source .env`\n    - `terraform -chdir=backend init`\n    - `terraform -chdir=backend apply`\n- Find the name of the created GCP bucket in Cloud Storage on GCP, and enter it in `main/backend.tf`\n\n### 3.2 Deploying the initial architecture\n\n- Set the variable `first_time` in `main/variables.tf` to `true`.\n- Create the initial infrastructure with:\n    - `terraform -chdir=main init`\n    - `terraform -chdir=main apply`\n\n### 3.3 Prepare the repository for deploying through CI/CD\n\n- Copy the contents of `infra_service_account.json` and paste them into a repository secret with the name `GOOGLE_CREDENTIALS`\n- Set the variable `first_time` in `main/variables.tf` to `false`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpgmaas%2Fcloudrun-example-infra","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffpgmaas%2Fcloudrun-example-infra","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffpgmaas%2Fcloudrun-example-infra/lists"}