Generate tfvars file by mapping live cloud resources (query via SDK) to a tfvars template
A quick hack to reduce toils in importing hundreds of scaling groups by hand
Disclaimer: the templates are curated to specific needs and not really for general use, at least for now as this is only a quick hack to help current task. So keeping the source close by will come in handy every now and then (modifying, rebuilding, etc.)
$ make go-build
will build the tfvarser
binary in ./bin/tfvarser
according to your machine's OS and arch.
You can also build it yourself using simple gotools
Requires some form of authentication to interact with cloud provider's API
export ALICLOUD_ACCESS_KEY=
export ALICLOUD_SECRET_KEY=
export ALICLOUD_REGION_ID=ap-southeast-1 # default
# example generate by names
$ tfvarser -provider ali -obj ess -limit-names testapp,node-qwertyapp,go-asdfapp
# or just import by ID
$ tfvarser -provider ali -obj ess -limit-ids asdf1234
# or just import one at a time
$ tfvarser -provider ali -obj ess -limit-names testapp
Command above will generate the following structure:
βββ testapp
β βββ autoscale
β β βββ ess-alarms
β β β βββ go-testapp-downscale
β β β β βββ terraform.tfvars
β β β βββ go-testapp-upscale
β β β βββ terraform.tfvars
β β βββ ess-lifecycle-hooks
β β β βββ autoscaledown-event-mns-queue
β β β β βββ terraform.tfvars
β β β βββ autoscaleup-event-mns-queue
β β β βββ terraform.tfvars
β β βββ ess-scaling-configurations
β β β βββ go-testapp-1c-1gb
β β β β βββ terraform.tfvars
β β β βββ go-testapp-1c-500mb
β β β βββ terraform.tfvars
β β βββ ess-scaling-group
β β β βββ terraform.tfvars
β β βββ ess-scaling-rules
β β βββ auto-downscale
β β β βββ terraform.tfvars
β β βββ auto-upscale
β β βββ terraform.tfvars
Every provider objects e.g. ESS
or ECS
in Aliyun may decide what limit-names
and limit-ids
correspond to.
For example, in Aliyun ESS object limit-names
and limit-ids
will limit by scaling group's name and ID.