tfvarser π
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.)
Installation
$ 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
Usage & Examples
Requires some form of authentication to interact with cloud provider's API
Aliyun
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.