-
-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77fd595
commit ba2dde9
Showing
31 changed files
with
1,102 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"label": "DevSecOps", | ||
"position": 18 | ||
"position": 19 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 19 | ||
sidebar_position: 20 | ||
description: Questions and answers about DevOps | ||
title: Q&A | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"label": "Terraform", | ||
"position": 18 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
--- | ||
sidebar_position: 3 | ||
title: Terraform Commands | ||
description: Terraform commands and their usage | ||
tags: ["Terraform", "Infrastructure as Code", "HashiCorp"] | ||
keywords: ["Terraform", "Infrastructure as Code", "HashiCorp"] | ||
slug: "/terraform/commands" | ||
--- | ||
|
||
1. Terraform Init | ||
|
||
It is used to initialize a working directory containing Terraform configuration files. | ||
|
||
```bash | ||
terraform init | ||
``` | ||
|
||
2. Terraform Plan | ||
|
||
It is used to create an execution plan. It shows what Terraform will do when you call apply. | ||
|
||
```bash | ||
terraform plan | ||
``` | ||
|
||
3. Terraform Apply | ||
|
||
It is used to apply the changes required to reach the desired state of the configuration. | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
|
||
4. Terraform Validate | ||
|
||
We can run this command before applying the changes to check whether the configuration is syntactically valid and internally consistent. | ||
|
||
```bash | ||
terraform validate | ||
``` | ||
|
||
It will print the exact in the console if there is any error in the configuration file. | ||
|
||
5. Terraform Format | ||
|
||
It is used to rewrite Terraform configuration files to canonical format and style. | ||
|
||
```bash | ||
terraform fmt | ||
``` | ||
|
||
6. Terraform Show | ||
|
||
It is used to provide human-readable output of current state of the resources. | ||
|
||
```bash | ||
terraform show | ||
``` | ||
|
||
We can also output the state in JSON format by using the following command: | ||
|
||
```bash | ||
terraform show -json | ||
``` | ||
|
||
7. Terraform Providers | ||
|
||
To know the list of providers used in the configuration file, we can use the following command: | ||
|
||
```bash | ||
terraform providers | ||
``` | ||
|
||
To mirror the provider configurations from the configuration file, we can use the following command: | ||
|
||
```bash | ||
terraform providers mirror ./path/to/new_local_file | ||
``` | ||
|
||
8. Terraform Output | ||
|
||
It is used to extract the output variables from the state file. | ||
|
||
```bash | ||
terraform output | ||
``` | ||
|
||
9. Terraform Refresh | ||
|
||
It is used to update the state file according to the real-world infrastructure. | ||
|
||
```bash | ||
terraform plan | ||
``` | ||
|
||
or | ||
|
||
```bash | ||
terraform apply -refresh-only | ||
``` | ||
|
||
10. Terraform Graph | ||
|
||
It is used to generate a visual representation of the configuration and state file. | ||
|
||
```bash | ||
terraform graph | ||
``` | ||
|
||
11. Terraform Destroy | ||
|
||
It is used to destroy the Terraform-managed infrastructure. | ||
|
||
```bash | ||
terraform destroy | ||
``` |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "local_file" "pet" { | ||
count = length(var.pet_filenames) | ||
filename = var.pet_filenames[count.index] | ||
content = "This is a file named ${var.pet_filenames[count.index]}" | ||
} | ||
|
||
output "pets" { | ||
value = local_file.pet | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
variable "pet_filenames" { | ||
default = [ | ||
"./cats.txt", | ||
"./dogs.txt", | ||
"./fish.txt", | ||
"./birds.txt", | ||
] | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/terraform/files/dependencies-type/explicit/explicit.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource local_file "my-file" { | ||
content = "I love Pets" | ||
filename = "/tmp/my-file.txt" | ||
depends_on = [random_pet.my-pet] | ||
} | ||
resource random_pet "my-pet" { | ||
prefix = "Mrs" | ||
separator = "." | ||
length = "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource local_file "my-file" { | ||
content = "My pet is ${random_pet.my-pet.id}" | ||
filename = "/tmp/my-file.txt" | ||
} | ||
resource random_pet "my-pet" { | ||
prefix = "Mrs" | ||
separator = "." | ||
length = "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "local_file" hello{ | ||
filename = "./hello.txt" | ||
content = var.say_hello | ||
file_permission = "0700" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Helloo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variable "say_hello" { | ||
description = "The message to write to the file" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "local_file" "pet" { | ||
filename = "./pets.txt" | ||
content = "We love pets!" | ||
file_permission = "0700" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
resource "local_file" "pet" { | ||
filename = "./pets.txt" | ||
content = "We love pets!" | ||
} | ||
|
||
resource "random_pet" "my-pet" { | ||
prefix = "Mrs" | ||
separator = "." | ||
length = "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "random_pet" "my-pet" { | ||
prefix = "Mrs" | ||
separator = "." | ||
length = "1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "pet_name" { | ||
value = random_pet.my-pet.id # The random pet name from main.tf | ||
description = "The random pet name generated by Terraform" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
resource "local_file" hello{ | ||
filename = "./hello.txt" | ||
content = var.say_hello | ||
file_permission = "0700" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
say_hello = "Hello World" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
variable "say_hello" { | ||
description = "The message to write to the file" | ||
type = string | ||
} |
Oops, something went wrong.