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
This commit is contained in:
parent
397b1ec9e1
commit
89c8ec68ca
29
README.md
29
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 <code>terragrunt</code> to explicitly inject variables between modules.
|
It is also common in the community to use a tool called <code>terragrunt</code> to explicitly inject variables between modules.
|
||||||
</b></details>
|
</b></details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>What is Terraform import?</summary><br><b>
|
||||||
|
|
||||||
|
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.
|
||||||
|
</b></details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>How do you import existing resource using Terraform import?</summary><br><b>
|
||||||
|
|
||||||
|
1. Identify which resource you want to import.
|
||||||
|
2. Write terraform code matching configuration of that resource.
|
||||||
|
3. Run terraform command <code>terraform import RESOURCE ID</code><br>
|
||||||
|
|
||||||
|
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 <code>terraform import aws_instance.tf_aws_instance i-12345678</code>
|
||||||
|
</b></details>
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
### Containers Exercises
|
### Containers Exercises
|
||||||
|
Loading…
Reference in New Issue
Block a user