Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/makukha/terraform-gcp-setup
Terraform module to setup Google Cloud Platform service account and backend bucket
https://github.com/makukha/terraform-gcp-setup
google google-cloud terraform terraform-module
Last synced: 6 days ago
JSON representation
Terraform module to setup Google Cloud Platform service account and backend bucket
- Host: GitHub
- URL: https://github.com/makukha/terraform-gcp-setup
- Owner: makukha
- License: apache-2.0
- Created: 2023-09-22T19:29:20.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-23T22:22:00.000Z (over 1 year ago)
- Last Synced: 2025-01-07T01:53:01.522Z (18 days ago)
- Topics: google, google-cloud, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-gcp-setup
Terraform module to setup Google Cloud Platform service account and backend bucket.
This module requires:
1. Existing Google Cloud project with billing enabled.
2. Google account that has owner permissions to this project.
3. IAM group that will be granted permissions to impersonate service account.This module:
1. Creates service account with minimal permissions.
2. Creates storage bucket with admin permissions granted to both new service account and project owner account.
3. Grants permissions to impersonate srvice account to IAM group.
4. Enables Google Cloud services necessary to run steps above.## Simple usage
See also `examples/full`.
1. [Install Google Cloud CLI](https://cloud.google.com/sdk/docs/install-sdk)
2. Authenticate to Google Cloud and create application default credentials:
```bash
gcloud auth login
gcloud auth application-default login
```3. Create sample project:
```bash
gcloud projects create --name="Sample project"
```Note the generated project id, it will be referenced as `${PROJECT_ID}` below.
4. [Enable billing](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project) for the project `${PROJECT_ID}`
5. Create IAM group and add yourself to the group. Note the group name, it will be referenced below as `${PROJECT_DEVOPS_GROUP}`.
6. Create root module files:
* `main.tf`
```hcl-terraform
provider "google" {}terraform {
backend "local" {}
}module "setup" {
source = "github.com/makukha/terraform-gcp-setup"
project_id = "${PROJECT_ID}"
project_devops_group = "${PROJECT_DEVOPS_GROUP}"
state_bucket_location = "europe-west1"
state_bucket_name = "${PROJECT_ID}-tfstate"
}
```* `outputs.tf`
```hcl-terraform
output "all" {
value = module.setup
}
```7. Init, check, apply, see outputs:
```bash
terraform init
terraform plan
terraform apply
```