浏览量 3158
2021/02/18 19:55
Teraform反向导出
Teraform Reverse Export
先上一个流程图
Let's start with a flow chart
terraform 从已经创建的资源导出 terraform格式文件
terraform Export terraform format files from already created resources
terraform import aws_db_instance.mysql db-id-rdsdemo
aws_db_instance.mysql: Importing from ID "db-id-rdsdemo"...
aws_db_instance.mysql: Import prepared!
Prepared aws_db_instance for import
aws_db_instance.mysql: Refreshing state... [id=db-id-rdsdemo]
Import successful!
The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.
aws_db_instance.mysql
<provider>_<type>.<name>
provider是供应商名称;
type是该供应商中创建资源的类型;
name是一个标识符。
db-id-rdsdemo
是在aws控制台看到的 DB identifier
is the DB identifier seen in the aws console
terraform show
terraform show
# aws_db_instance.mysql:
resource "aws_db_instance" "mysql" {
address = "..."
..........
timeouts {}
}
将上述显示的 terraform写入对应的tf文件 做相应修改,之后就是plan apply了。
The terraform shown above is written to the corresponding tf file and modified accordingly, followed by plan apply.
上一篇 搜索 下一篇