https://github.com/ryu1kn/sandbox--terraform
https://github.com/ryu1kn/sandbox--terraform
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ryu1kn/sandbox--terraform
- Owner: ryu1kn
- Created: 2019-07-29T12:28:45.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-31T13:20:26.000Z (almost 7 years ago)
- Last Synced: 2026-01-19T21:10:01.463Z (5 months ago)
- Language: HCL
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform Sandbox
## Update resources in Google Cloud Platform
Terraform config for GCP is under `gcp` directory.
Environment variable `GOOGLE_CLOUD_KEYFILE_JSON` must be set to point to the key file.
```sh
$ terraform apply \
-var "gce_ssh_pub_key_file=$HOME/.ssh/google_compute_engine.pub" \
-var "gce_ssh_user=$(whoami)" \
gcp
...
Outputs:
ip1 = 35.189.20.142
ip2 = 35.244.104.96
```
Two VMs are in different VPCs that are VPC peered. You can access from one VM to the other.
```sh
$ ssh -A -i ~/.ssh/google_compute_engine 35.189.20.142
ryuichi@terraform-instance-1:~$ ssh 35.244.104.96
ryuichi@terraform-instance-2:~$ # <-- Login successful
```
## Refs
* [Google Cloud Platform for AWS Professionals: Networking](https://cloud.google.com/docs/compare/aws/networking)
* [Google Cloud Platform Provider](https://www.terraform.io/docs/providers/google/index.html)
* [Getting started with Terraform on Google Cloud Platform](https://cloud.google.com/community/tutorials/getting-started-on-gcp-with-terraform)