cycloidio / terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
MIT License
2.19k stars 163 forks source link

error importing aws_instance with ebs_volume #337

Closed tparvu closed 1 year ago

tparvu commented 1 year ago

General information:

Archlinux

v0.8.1

Built from source, but docker image will error as well.

Describe the bug:

When importing a aws_instance resource that has an attached EBS volume Terracognita writes;

tags { instead of tags = {

Running a Terraform plan on results....
Using region = us-east-2
,╷
│ Error: Unsupported block type
│ 
│   on ec2_elastic_compute_cloud.tf line 37, in resource "aws_instance" "testbed":
│   37:     tags {
│ 
│ Blocks of type "tags" are not expected here. Did you mean to define argument "tags"? If so, use the equals sign to assign it a value.
╵
➜  terracognita git:(update-provider) ✗ 

Additional context

Original HCL;

resource "aws_instance" "testbed" {
  ami                         = data.aws_ami.debian.id
  instance_type               = var.instance_type
  subnet_id                   = aws_subnet.testbed_subnet.id
  associate_public_ip_address = true
  key_name                    = var.key_name
  vpc_security_group_ids      = [aws_security_group.allow_tests.id]

  tags = {
    Name        = var.instance_name
    Project     = var.project
    Desc        = var.description
    Contact     = var.contact
    Environment = var.environment
  }

  # root disk
  root_block_device {
    volume_size           = "16"
    volume_type           = "gp2"
    encrypted             = true
    delete_on_termination = true

    tags = {
      Name = "root disk"
      Desc = "Root disk for testbed"
    }
  }

  # data disk
  ebs_block_device {
    volume_size = "64"
    volume_type = "gp2"
    encrypted   = true
    device_name = "/dev/sdf"

    tags = {
      Name   = "testbed data disk"
      Desc   = "Inspire11 DevOps testbed data disk"
      Backup = "false"
    }
  }

}

Add any other context about the problem here.

Other maps are working fine, no idea what the issue is the ebs_block_device map.

xescugc commented 1 year ago

This has been solved in #373 :) Thanks for the report