Terraform code generation tool by Alibaba Cloud Container Service for Kubernetes (ACK).
- This tool will be compatible with all the latest terraform services of Alibaba Cloud.
- The latest provider in terraform-provider-alicloud.
- The github repo in terraform-provider-alicloud.
NOTE:
- It's only for MacOS now.
- GoLang version 1.17+
- Git
- Network with access to GitHub
You could install this tool by git
.
mkdir -p $GOPATH/src/github.com/Pangjiping
cd $GOPATH/src/github.com/Pangjiping
git clone git@github.com:Pangjiping/terrafmtter.git
cd terrafmtter
make install
We will add the executable file to your environment variables during installation.
So you could run terrafmtter
in any directory.
terrafmtter
supports four command line arguments:
resource
: It's required. You could select multiple resources which you want to create, likecs_kubernetes,cs_kubernetes_node_pool
. Please use,
to separate multiple resources.data
: It's required. You could select multiple datasources which you want to query, likecs_kubernetes_version,cs_kubernetes_clusters
. Please use,
to separate multiple datasources.version
: It's optional. You could specify the alicloud-provider version like1.173.0
. It's will belatest
version if not assigned.file
: It's optional. You could specify the location of the output terraform file.
Below is a simple use case for terrafmtter:
terrafmtter --data cs_kubernetes_version \
--version 1.173.0 \
--file main.tf
The auto-generated main.tf
is follows:
# Code generated by Alibaba Cloud Container Service for Kubernetes.
# More in https://www.alibabacloud.com/product/kubernetes
# We would not try to get your accessKey and secretKey for safety.
# PLEASE EDIT TODOs as needed. ^_^
# [TODO] PLEASE EDIT your secret information.
# Details in https://registry.terraform.io/providers/aliyun/alicloud/latest/docs
provider "alicloud" {
access_key = "********"
secret_key = "********"
region = "cn-hangzhou"
}
# [TODO] PLEASE EDIT.
variable "default" {
default = "tf-create"
}
# [TODO] PLEASE EDIT.
# Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version
data "alicloud_cs_kubernetes_version" "default" {
# Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#cluster_type
cluster_type = "TODO"
# Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#version
version = "TODO"
# Details in https://registry.terraform.io/providers/aliyun/alicloud/1.173.0/docs/data-sources/cs_kubernetes_version#profile
profile = "TODO"
}
- auto attach resource and datasource.
- set recommended fields.
- full field enumeration.
- template enhancement.
- setting default value.
- optimize optional and required.
- optimize for ack.