Skip to content

Commit

Permalink
Add Terraform cheatsheet
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Oct 30, 2022
1 parent c9cfbf9 commit 82d1bbe
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ Name | Comments

## Blogs & News

DevOps & Software Engineering related blogs
My top picks:

Name | Description
:------|:------:
[Codefresh Blog](https://codefresh.io/blog) | Probably best GitOps content out there

Other DevOps & Software Engineering related blogs

Name | Description
:------|:------:
Expand Down Expand Up @@ -405,6 +411,7 @@ Note: "Provisioning" tools can be used to perform configuration management to so

## More Infra & DevOps projects

<p align="center"><a href="https://github.com/bregman-arie/sre-checklist"><img width="500px" src="images/sre_checklist.png"/></a></p>
<p align="center"><a href="https://github.com/bregman-arie/howtheydevops"><img src="images/how_they_devops.png"/></a></p>
<p align="center"><a href="https://github.com/bregman-arie/devops-exercises"><img src="images/devops_exercises.png"/></a></p>
<p align="center"><a href="https://github.com/bregman-arie/infraverse"><img src="images/infraverse.png"/></a></p>
Expand Down
Binary file added images/sre_checklist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/argocd.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ argocd app create {APP NAME} \
* sync app: `argocd app sync <APP NAME>`
* app history: `argocd app history <APP NAME>`
* delete app: `argocd app delete <APP NAME>`

* Add cluster: `argocd cluster add CLUSTER`
* List clusters: `argocd cluster list`
* Remove cluster: `argocd cluster rm CLUSTER
9 changes: 9 additions & 0 deletions resources/chaos_engineering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Chaos Engineering

## Platforms and Services

* https://www.gremlin.com

## Resources

* Diagram for tracking Chaos Engineering state: http://coggle.it/diagram/WiKceGDAwgABrmyv/0a2d4968c94723e48e1256e67df51d0f4217027143924b23517832f53c536e62
20 changes: 20 additions & 0 deletions resources/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,23 @@ krmgf nginx-8jk71 # kill pod nginx-8jk71 using grace period 0 and force
### Monitoring

* Install metrics-server using Minikube: `minikube addons enable metrics-server`

### Secrets

* Install Bitnami Sealed secrets controller

```
helm repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets
helm repo update
helm install sealed-secrets-controller sealed-secrets/sealed-secrets
```

* sealed-secrets binary: `https://github.com/bitnami-labs/sealed-secrets/releases`

* encrypt secret in yaml or json format: `kubeseal -n my-namespace <.db-creds.yml> db-creds.json`
* apply secret on the cluser: `kubectl apply -f db-creds.json -n my-namespace`

### Kustomize

* Generate customized YAML file(s): `kustomize build name_of_application`
* Apply generated customized YAML file(s) to the cluster: `kustomize build name_of_application`
44 changes: 43 additions & 1 deletion resources/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
https://project-awesome.org/shuaibiyy/awesome-terraform
[Terraform Script Builder](https://terraparty.com) | export valid Terraform scripts using UI

## Cloud
## Projects

Name | Comments
:------|:------:
[terraformer](https://github.com/GoogleCloudPlatform/terraformer) | "A CLI tool that generates tf/json and tfstate files based on existing infrastructure (reverse Terraform)."
[terraforming](https://github.com/dtan4/terraforming) | "Export existing AWS resources to Terraform style (tf, tfstate)"
[terrascan](https://github.com/tenable/terrascan) | "Detect compliance and security violations across Infrastructure as Code to mitigate risk before provisioning cloud native infrastructure"

### Best Practices

Expand All @@ -21,3 +22,44 @@ Name | Comments
* Backup it regularly so you can roll-back easily when needed
* Store it in remote shared storage. This is especially needed when working in a team and the state can be updated by any of the team members
* Enabled versioning if the storage where you store the state file, supports it. Versioning is great for backups and roll-backs in case of an issue.

### Cheat Sheet

* Initialize terraform: `terraform init`
* See what Terraform will execute if running apply: `terraform plan`
* Apply Terraform configuration/code: `terraform apply`
* Cleanup, remove Terraform generated resources: `terraform destroy`

* Dependency graph: `terraform graph`

#### State

* Show state: `terraform show`
* List resources from the state: `terraform state list`
* Rename resource: `terraform state mv`
* Import existing infrastructure into state: `terraform import`

#### Variables

* Pass var: `terraform -var`
* Pass vars file: `terraform -var-file`

* List all outputs: `terraform output`
* Get specific output: `terraform output <OUTPUT_VAR>`

#### Data sources

* Get data: `data.<PROVIDER_AND_TYPE>.<NAME>.<ATTRBIUTE>`

#### Backends

* Use variables in a remote backend: `terraform init -backend-config=some_backend_partial_conf.hcl`

#### Workspaces

* Create a new workspace: `terraform workspace new <WORKSPACE_NAME>`
* Show current workspace: `terraform workspace show`

#### Productivity

* Console: `terraform console`

0 comments on commit 82d1bbe

Please sign in to comment.