- Setup a .tf file
# main.tf
provider "aws" {
region = "us-east-1"
}
resource "aws_s3_bucket" "bucket" {}
- From command line run:
terraform import aws_s3_bucket.bucket hashi-implementation-svc-tools
- Run
terraform show
# aws_s3_bucket.bucket:
resource "aws_s3_bucket" "bucket" {
arn = "arn:aws:s3:::hashi-implementation-svc-tools"
bucket = "hashi-implementation-svc-tools"
bucket_domain_name = "hashi-implementation-svc-tools.s3.amazonaws.com"
...
- Copy and paste the output from terraform show into the .tf file and run
terraform plan
terraform plan
Error: Computed attributes cannot be set
on test.tf line 9, in resource "aws_s3_bucket" "bucket":
9: bucket_domain_name = "hashi-implementation-svc-tools.s3.amazonaws.com"
Computed attributes cannot be set, but a value was set for
"bucket_domain_name".
Error: Computed attributes cannot be set
on test.tf line 10, in resource "aws_s3_bucket" "bucket":
10: bucket_regional_domain_name = "hashi-implementation-svc-tools.s3.amazonaws.com"
Computed attributes cannot be set, but a value was set for
"bucket_regional_domain_name".
Error: Invalid or unknown key
on test.tf line 12, in resource "aws_s3_bucket" "bucket":
12: id = "hashi-implementation-svc-tools"
- Modify the terraform code until the plan passes