March 16, 2021
terraform leadership
Practical Cloud Migration
Google’s Tech Infrastructure team (think SRE) released Practical Guide to Cloud Migration.
“75% of the application development team realized that they now had valuable new skills, and they didn’t feel like Company A provided a supportive environment. They took their newfound skills and found profitable work elsewhere.Company A had transformed its technological stack without transforming its company culture, and the employees that did the work and made the change weren’t given a voice.”
“But it didn’t have to happen like that. What if Company A had proactively maintained a positive and supportive culture while undergoing its cloud transformation? With planning, resources, and empathy, it is possible to achieve a cloud transformation while maintaining both your team and your company’s momentum. An empowered work‐ place culture that values psychological safety can supercharge any organization.” (p.16, Chapter 2: Celebrating (and Tweaking) Your Culture)
Exporting GCP infra to terraform
Since I just got on the Terrafrom bandwagon as a user vs. a reader, this piqued my interest:
Did you create resources in @GoogleCloudTech via gcloud or the console but want to turn it into Terraform?
— Vic Iglesias (@vicnastea) March 12, 2021
Export the config with:
gcloud alpha resource-config bulk-export --resource-format=terraform
Feedback welcome! Let us know how we can make this better. pic.twitter.com/eynwHL6rpi
Getting the resource-config
API running took a couple of tries, but here’s what worked on a project called traintrack that I set up using Terraform:
The first time I tried this, the
gcloud
component installer got the alpha component installed.The second time I tried it needed to install a binary dependency called
config-connector
, so once again I let it install and update.Third time’s a charm:
Note: this assumes that you’ve got a JSON-formatting key file and the correct
GOOGLE_APPLICATION_CREDENTIALS
set for a service account in that project.1 2 3 4 5 6
$ gcloud services enable cloudasset.googleapis.com --project=exp-traintrack-tf Operation "operations/acf.p2-157509977548-33c2ba20-e3c7-465a-8fd3-63653de9b9ab" finished successfully. $ gcloud alpha resource-config bulk-export \ --resource-format=terraform --project=exp-traintrack-tf --path=tmp/ Exporting resource configurations to [tmp/]...done. Exported 30 resource configuration(s) to [tmp/].
Results
Sure enough I get YAML-formatted TF files:
|
|
And it appears to be a faithful reproduction of my initial configuration, albeit it annoyingly split up.
For example, here’s my backend service:
|
|