Import an existing resource

Put an existing S3 bucket under Terraform control

terraform import 'aws_s3_bucket.mybucket' my-existing-bucket

tool
terraform43 commands
tags
terraform

More terraform commands

  • terraform taint 'aws_instance.web[0]'

    Mark a resource to be destroyed and created again on the next apply

  • terraform state rm 'aws_instance.legacy'

    Remove a resource from state without destroying it in the cloud

  • terraform output -json | jq 'to_entries[] | {(.key): .value.value}'

    Print each output as a short {name: value} JSON object

  • terraform destroy -target='aws_instance.web' -auto-approve

    Destroy one resource without a full plan and without confirmation (-auto-approve)

  • terraform force-unlock <lock-id>

    Release a stuck state lock after a failed apply

all 43 terraform commands