简体   繁体   English

Terraform 导入使用 terraform-aws-modules/security-group/aws//modules/web 创建的 aws 安全组资源

[英]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.

相关问题 terraform-aws-modules/eks/aws 中的 cluster_primary_security_group_id 和 cluster_security_group_id 有什么区别? - What's the difference between cluster_primary_security_group_id and cluster_security_group_id in terraform-aws-modules/eks/aws? 无法使用 Terraform 0.12 获取 aws 安全组 output 数据 - Unable to get aws security-group output data using Terraform 0.12 使用 terraform 在 AWS 中创建安全组时如何为源选择安全组 ID - how to select a security-group id for the source when creating a security group in AWS with terraform AWS Load Balancer Terraform 模块(https://github.com/terraform-aws-modules/terraform-aws-alb):target_group_index = 0,是什么? - AWS Load Balancer Terraform module (https://github.com/terraform-aws-modules/terraform-aws-alb): target_group_index = 0, what is it? Terraform使用AWS中的Terraform模块导入 - Terraform Import using Terraform modules in AWS 如何将安全组附加到 terraform 中的 aws 实例 - How to attach a security group to aws instance in terraform Aws eks 集群安全组,terraform - Aws eks cluster security group, terraform Terraform AWS 安全组自参考 - Terraform AWS Security group self reference Terraform AWS EKS 安全组问题 - Terraform AWS EKS security group issue terraform aws:创建安全组时的协议不正确 - terraform aws: Incorrect protocol in creating a security group
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM