Terraform Import

Terraform can import existing infrastructure resources. This functionality lets you bring existing resources under Terraform management.

Warning: Terraform expects that each remote object is bound to only one resource address. You should import each remote object to only one Terraform resource address. If you import the same object multiple times, Terraform may exhibit unwanted behavior. Refer to State for more details.

State Only

Terraform import can only import resources into the state. Importing does not generate configuration.

Before you run terraform import you must manually write a resource configuration block for the resource. The resource block describes where Terraform should map the imported object.

terraform state list | grep aws_volume_attachment

terraform state show aws_volume_attachment.this

terraform state rm aws_volume_attachment.this

terraform import –var-file=conf/uat-eu-west-1.conf aws_volume_attachment.this /dev/sdf:vol-0bxxxxx:i-01201xxxxxx

terraform import –var-file=conf/uat-eu-west-1.conf aws_instance.xxxx_server i-01201fxxxxx