{"id":22353572,"url":"https://github.com/dp6/gcp-terraform-template","last_synced_at":"2025-07-30T08:34:13.868Z","repository":{"id":54723213,"uuid":"522633570","full_name":"DP6/gcp-terraform-template","owner":"DP6","description":"Template de Terraform para Google Cloud Platform","archived":false,"fork":false,"pushed_at":"2023-08-24T20:56:06.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-03-26T08:33:30.548Z","etag":null,"topics":["gcp","google-cloud","google-cloud-platform","terraform"],"latest_commit_sha":null,"homepage":"","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/DP6.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-08-08T16:51:13.000Z","updated_at":"2024-03-26T08:33:30.549Z","dependencies_parsed_at":"2022-08-14T00:50:32.447Z","dependency_job_id":null,"html_url":"https://github.com/DP6/gcp-terraform-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DP6%2Fgcp-terraform-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DP6%2Fgcp-terraform-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DP6%2Fgcp-terraform-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DP6%2Fgcp-terraform-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DP6","download_url":"https://codeload.github.com/DP6/gcp-terraform-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228114906,"owners_count":17871742,"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":["gcp","google-cloud","google-cloud-platform","terraform"],"created_at":"2024-12-04T13:09:02.606Z","updated_at":"2024-12-04T13:09:03.269Z","avatar_url":"https://github.com/DP6.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# What is Terraform and where do you use it\n\nTerraform is infraestructure as code, deploying from this repository to the cloud with it's configurations on `.tf` files.\n\nYou can use this template for any Google Cloud Platform project, especially when talking about Cloud Functions. With git we keep track of changes made to the Cloud Functions codes and can even rollback if something went wrong.\n\n## What you will need\n\n- Basic git knowledge\n- GCP project permissions\n  - Cloud Functions\n  - Cloud Storage\n  - Source Repositories\n  - Cloud Build \n\nYou can host the repository on GitHub or GitLab then link with Source Repositories or create directly on your GCP project with Source Repositories.\n\n# Setup\n\nChange the variables on `environments/main/terraform.tfvars` and `environments/main/backend.tf` to match your project.\n\n\u003e Obs.: Apply the same variables on `environments/pre_main/terraform.tfvars`\n\n## Setup the Cloud Build\n\nAfter configuring the project on **Google Source Repositories**, create a trigger for every push on the repository.\n\nThe `cloudbuild.yaml` configuration file will handle the build and deploy. \n\n# Create a Cloud Function\n\n1. Copy one folder from `templates/functions/http` for http trigger functions or `templates/functions/pubsub` for pubsub trigger functions into `src/functions`\n2. Rename the folder you copied to the name of your function\n3. Edit `{http|pubsub}_config.json` to fit your Cloud Function\n\nAs the only required field is `topic_name` for PubSub Functions, if you have an empty json it'll be applied the default values:\n\n```jsonc\n{\n  \"topic_name\": \"daily_at_5\",     /* Required for PubSub Functions, not necessary for http functions */\n  // \"is_typescript\": false,      /* Optional */\n  // \"description\": \"\",           /* Optional */\n  // \"entry_point\": \"main\",       /* Optional */\n  // \"runtime\": \"nodejs16\",       /* Optional */\n  // \"timeout\": 60,               /* Optional */\n  // \"available_memory_mb\": 128,  /* Optional */\n  // \"environment_variables\": {}  /* Optional */\n}\n```\n\n\u003e Warning: the JSON file can't have comments, so remove them before pushing to the repository\n\n# Authenticating\n\nTo use or make any changes on GCP resources, you'll need to authenticate. Most apps will use the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, that should have the path to your service account json file. More details on [Authenticating as a service account](https://cloud.google.com/docs/authentication/production).\n\n```sh\n$ export GOOGLE_APPLICATION_CREDENTIALS=\"path/to/serviceaccount.json\"\n```\n\nOr you can use [`gcloud auth application-default`](https://cloud.google.com/sdk/gcloud/reference/auth/application-default) command to authenticate using your Google Account directly:\n```sh\n$ gcloud auth application-default login --project=\"\u003cgcp-project-id\u003e\"\n```\n\nSee https://cloud.google.com/sdk/docs/install for installing gcloud cli.\n\n\n# Terraform\n\nTo apply the changes locally:\n\n```sh\n# The deploy of pre_main is only necessary on the first time\n$ cd environments/pre_main\n$ terraform init\n$ terraform apply -auto-approve\n\n$ cd ../main\n$ terraform init\n$ terraform apply -auto-approve\n```\n\n\u003e **Altough, we recommend pushing your changes to the repository to run the CI on Cloud Build.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdp6%2Fgcp-terraform-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdp6%2Fgcp-terraform-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdp6%2Fgcp-terraform-template/lists"}