terraform import
Jump to navigation
Jump to search
↑ https://www.terraform.io/docs/cli/import/index.html
Before using terraform import
(doc) you must manually write a resource configuration block for the resource.
Contents
Examples
terraform import --help
terraform import aws_instance.my_foo i-abcd1234
[1]terraform import aws_default_subnet.public_subnet subnet-9d4a7b6c
terraform import aws_default_vpc.default vpc-a01106c2
terraform import aws identitystore user.testimport "d-123456789/c12343345-1234-4321-12334-c121212121a"
terraform import aws_cloudfront_distribution.distribution E74FTE3EXAMPLE
Errors
aws_identitystore_user.testimport: Importing from ID "testimport"... aws_identitystore_user.testimport: Import prepared! Prepared aws_identitystore_user for import aws_identitystore_user.testimport: Refreshing state... [id=testimport] ╷ │ Error: reading AWS SSO Identity Store User (testimport): expected a resource id in the form: identity-store-id/user-id │ │ ╵
terraform import aws_identitystore_user.testimport d-9a672d8036/testimport aws_identitystore_user.testimport: Importing from ID "d-123456789/testimport"... aws_identitystore_user.testimport: Import prepared! Prepared aws_identitystore_user for import aws_identitystore_user.testimport: Refreshing state... [id=d-123456789/testimport] ╷ │ Error: reading AWS SSO Identity Store User (d-123456789/testimport): operation error identitystore: DescribeUser, https response error StatusCode: 400, RequestID: 362370f8-3b16-4d14-9e28-64265f76e1a4, ValidationException: │ │ ╵
Errors
terraform import aws_key_pair.MyNewKeyInTerraform YourExistingKeyName
terraform import aws key pair.MyNewKeyInTerraform YourExistingKeyName2
Error: Reference to undeclared resource
Related terms
- Terraform modules
- Terraform resources:
resource
terraform.tfstate
- Terraform activities
terraform apply -refresh-only
- Cloudformation:
--resources-to-import
terraform state rm
import block allows import operations to be defined in code
See also
terraform import
- Terraform configuration files, Terraform state files:
.tf
,.tfvars
,main.tf, outputs.tf
,variables.tf
,.terraform.d/
,terraform init
,providers.tf
,.terraform/
,terraform.tfstate
,.terraform.lock.hcl
,terraform.tfstate.d, override.tf, versions.tf
Advertising: