xxxxxxxxxx
if (import.meta.url === new URL(import.meta.url).href) {
console.log('called directly');
} else {
console.log('imported as a module');
}
xxxxxxxxxx
# Write the provider Block
provider "aws" {
region = "us-east-1"
}
# Write the import block
import {
to = aws_instance.example
id = "i-abcd1234"
}
# On CLI,
terraform plan -generate-config-out=henerated-resource.tf
# Create main.tf file and copy the resource block in the generated-resource.tf file
# On the CLI, run terraform import aws_instance.example resource-id