From 89c8ec68cac960729fb6755294e205bee63449a8 Mon Sep 17 00:00:00 2001 From: Udhav Date: Wed, 15 Sep 2021 03:48:31 -0700 Subject: [PATCH] Devops exercises : Adding 2 Terraform questions on import (#149) * Add terraform import question * Add how to use terraform import question * Add example on how to use terraform import question --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 95d887e..31b8048 100644 --- a/README.md +++ b/README.md @@ -5583,6 +5583,35 @@ The Terraform Registry provides a centralized location for official and communit It is also common in the community to use a tool called terragrunt to explicitly inject variables between modules. +
+What is Terraform import?
+ +Terraform import is used to import existing infrastucture. It allows you to bring resources created by some other means (eg. manually launched cloud resources) and bring it under Terraform management. +
+ +
+How do you import existing resource using Terraform import?
+ +1. Identify which resource you want to import. +2. Write terraform code matching configuration of that resource. +3. Run terraform command terraform import RESOURCE ID
+ +eg. Let's say you want to import an aws instance. Then you'll perform following: +1. Identify that aws instance in console +2. Refer to it's configuration and write Terraform code which will look something like: +``` +resource "aws_instance" "tf_aws_instance" { + ami = data.aws_ami.ubuntu.id + instance_type = "t3.micro" + + tags = { + Name = "import-me" + } +} +``` +3. Run terraform command terraform import aws_instance.tf_aws_instance i-12345678 +
+ ## Containers ### Containers Exercises