https://github.com/dmilan77/gcp-terraform-startup
gcp terrafrom impersonation service account demo
https://github.com/dmilan77/gcp-terraform-startup
Last synced: 5 months ago
JSON representation
gcp terrafrom impersonation service account demo
- Host: GitHub
- URL: https://github.com/dmilan77/gcp-terraform-startup
- Owner: dmilan77
- Created: 2021-09-23T16:55:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-09-23T19:17:31.000Z (over 3 years ago)
- Last Synced: 2024-08-03T22:19:31.187Z (9 months ago)
- Language: HCL
- Size: 16.7 MB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - dmilan77/gcp-terraform-startup - gcp terrafrom impersonation service account demo (HCL)
README
# use impersonate service account
```
gcloud auth list
export TFSA="terraform-sa@data-protection-01.iam.gserviceaccount.com"gcloud auth login --no-launch-browser
# gcloud auth application-default login --no-launch-browser
```# Terraform create
```
export GOOGLE_OAUTH_ACCESS_TOKEN=$(gcloud --impersonate-service-account=${TFSA} auth print-access-token)terraform init
terraform plan -out ".tfout"
terraform apply ".tfout"
terraform destroy --auto-approve
```# Destroy
```
rm -rf ".tfout"; rm -rf .terraform;rm -rf .terraform.lock.hcl ;rm -rf ~/.config
unset GOOGLE_OAUTH_ACCESS_TOKEN```