[英]Terraform Import aws security group resources created using terraform-aws-modules/security-group/aws//modules/web
I have created a aws security group using the terraform provided aws module which is terraform-aws-modules/security-group/aws//modules/web.我使用 terraform 提供的 aws 模块创建了一个 aws 安全组,该模块为 terraform-aws-modules/security-group/aws//modules/web。 Below is the snippet of code used.下面是使用的代码片段。 Resource created properly资源创建正确
module "app_security_group" {
source = "terraform-aws-modules/security-group/aws//modules/web"
version = "3.17.0"
name = "web-server-sg"
description = "Security group for web-servers with HTTP ports open within VPC"
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = module.vpc.public_subnets_cidr_blocks
}
But not able to import using below command但无法使用以下命令导入
terraform import -var aws_region=us-east-1 -state-out=us-east-1-recover.terraform.tfstate module.app_security_group.aws_security_group.web-server-sg sg-01c3b636f23c07ed0
getting error出错
Error: resource address "module.app_security_group.aws_security_group.this" does not exist in the configuration.
Before importing this resource, please create its configuration in module.app_security_group. For example:
resource "aws_security_group" "web-server-sg" {
# (resource arguments)
}
Try this command试试这个命令
terraform import -var aws_region=us-east-1 -state-out=us-east-1-recover.terraform.tfstate
module.app_security_group.web-server-sg
sg-01c3b636f23c07ed0 terraform import -var aws_region=us-east-1 -state-out=us-east-1-module.app_security_group.web-server-sg
sg-01c3b636f23c07ed0
Also note that when you created the resource then it should have already added to the statefile另请注意,当您创建资源时,它应该已经添加到状态文件中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.