Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Using Existing Services with Terraform

Expand
titleCommenting Existing Resource Blocks

To avoid recreating existing resources, comment out the corresponding resource block in the Terraform configuration. Example:

Code Block
#resource "aws_ecs_cluster" "PSKnowHOW-Cluster" {
#  name = var.ecs_cluster_name
#}
Expand
titleImporting Existing Resources

Import existing resources into the Terraform state:

Code Block
terraform import aws_vpc.example_vpc example-vpc
Expand
titleUsing Outputs

Define outputs in output.tf to share resource information:

Code Block
output "imported_VPC_id" {
  value = aws_vpc.example_vpc.id
}

Summary

  • Comment existing resource blocks in Terraform.

  • Use terraform import to manage existing resources.

  • Define outputs for sharing resource details.

...