-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implemented a tutorial and documentation and terraform in repos…
…itory
- Loading branch information
0 parents
commit 2c4141e
Showing
23 changed files
with
1,103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/infra/.terraform | ||
/infra/.terraform.lock.hcl | ||
/infra/terraform.tfstate | ||
/infra/terraform.tfstate.backup |
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,112 @@ | ||
## O que é o Terraform | ||
|
||
O Terraform é uma ferramenta de infraestrutura como código (IaC) que permite aos desenvolvedores e administradores de sistemas definir, provisionar e gerenciar recursos de infraestrutura de uma maneira declarativa e eficiente. | ||
|
||
**Código localizado na pasta infra do projeto** | ||
|
||
## Passo a Passo de como utilizar | ||
|
||
### Instalar a CLI do Terraform | ||
|
||
[Install | Terraform | HashiCorp Developer](https://developer.hashicorp.com/terraform/install) | ||
|
||
**Verificar se deu tudo certo na instalação, executar o código abaixo no terminal do computador:** | ||
|
||
```bash | ||
terraform version | ||
# outinput: Terraform vX.XX.x | ||
``` | ||
|
||
<br> | ||
|
||
### Instalar a CLI da AWS | ||
|
||
[Install or update to the latest version of the AWS CLI - AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) | ||
|
||
**Verificar se deu tudo certo na instalação, executar o código abaixo no terminal do computador:** | ||
|
||
```bash | ||
aws --version | ||
# outinput: aws-cli/2.15.45 Python/3.11.8 ... | ||
``` | ||
|
||
<br> | ||
|
||
**Após instalar a CLI da AWS, é necessário colocar as credências da conta da AWS com o seguintes comandos abaixo, também vai estar a lista das credênciais:** | ||
|
||
- aws_access_key_id | ||
- aws_secret_access_key | ||
- aws_session_token | ||
|
||
```bash | ||
aws configure | ||
``` | ||
|
||
 | ||
|
||
```bash | ||
aws configure set aws_session_token SESSIONTOKENHERE | ||
``` | ||
<br> | ||
|
||
### Executando código do Terraform | ||
|
||
**Após realizar todas as configurações acima, você deve acessar a pasta infra do projeto e logo em seguida executar os seguintes comandos no terminal:** | ||
|
||
<p><span style="color: purple;">terraform init</span>: Este comando é usado para inicializar um diretório de trabalho do Terraform. Ele é geralmente executado no início de um novo projeto ou quando o diretório do projeto é atualizado com novos plugins ou módulos. Durante a inicialização, o Terraform baixa os plugins necessários para a configuração do provedor (por exemplo, AWS, Azure, Google Cloud, etc.) e estabelece uma conexão com o backend de armazenamento de estado, se aplicável.</p> | ||
|
||
```bash | ||
terraform init | ||
``` | ||
|
||
<br> | ||
|
||
<p><span style="color: purple;">terraform fmt</span>: Este comando é usado para formatar o código do Terraform de acordo com as convenções de estilo recomendadas pelo Terraform. Ele ajusta a indentação, espaçamento e formatação geral do código para torná-lo mais legível e consistente. Executar terraform fmt ajuda a manter um estilo de código uniforme em um projeto e facilita a colaboração entre membros da equipe. | ||
|
||
```bash | ||
terraform fmt | ||
``` | ||
<br> | ||
|
||
|
||
<p><span style="color: purple;">terraform validate</span>: Este comando é usado para validar a sintaxe e a semântica do código do Terraform. Ele verifica se o código está correto em termos de estrutura e configuração. Durante a validação, o Terraform analisa os arquivos de configuração e identifica quaisquer erros ou avisos, como referências a recursos inexistentes ou configurações inválidas. | ||
|
||
```bash | ||
terraform validate | ||
``` | ||
|
||
<br> | ||
|
||
<p><span style="color: purple;">terraform plan</span>: Este comando é usado para criar um plano de execução do Terraform. Ele examina o código do Terraform e determina quais mudanças serão feitas na infraestrutura quando o comando terraform apply for executado. O plano mostra uma visão geral das adições, atualizações e remoções de recursos que ocorrerão, permitindo que você revise e confirme as mudanças antes que sejam aplicadas. | ||
|
||
```bash | ||
terraform plan | ||
``` | ||
|
||
<br> | ||
|
||
|
||
<p><span style="color: purple;">terraform apply</span>: Este comando é usado para aplicar as mudanças planejadas à infraestrutura. Quando executado, o Terraform verifica o plano de execução gerado pelo comando terraform plan e solicita confirmação para aplicar as mudanças. Depois de confirmado, o Terraform faz as alterações na infraestrutura de acordo com o plano e atualiza o estado do projeto para refletir as mudanças realizadas. | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
<br> | ||
|
||
### Evidencias da execução do código | ||
|
||
 | ||
 | ||
 | ||
|
||
<br> | ||
|
||
 | ||
 | ||
 | ||
 | ||
 | ||
|
||
<br> | ||
|
||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,58 @@ | ||
## Passo a Passo das configurações ⛷️ | ||
|
||
Aqui você escontrara links e comandos para verificar se as instalações na maquina foram instalados de forma correta. | ||
|
||
Para facilitar a sua vida como desenvolvedor e pessoa, recomendo a utilização do WSL, utilizando o linux para instalar a cli do terraform e da aws, onde você também vai executar os comandos pelo WSL. | ||
|
||
Sistemas recomendados: | ||
<li>Linux 🐧</li> | ||
<li>MacOs 🍎</li> | ||
|
||
### Instalar a CLI do Terraform | ||
|
||
[Install | Terraform | HashiCorp Developer](https://developer.hashicorp.com/terraform/install) | ||
|
||
**Verificar se deu tudo certo na instalação, executar o código abaixo no terminal do computador:** | ||
|
||
```bash | ||
terraform version | ||
# outinput: Terraform vX.XX.x | ||
``` | ||
|
||
<br> | ||
|
||
### Instalar a CLI da AWS | ||
|
||
[Install or update to the latest version of the AWS CLI - AWS Command Line Interface](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) | ||
|
||
**Verificar se deu tudo certo na instalação, executar o código abaixo no terminal do computador:** | ||
|
||
```bash | ||
aws --version | ||
# outinput: aws-cli/2.15.45 Python/3.11.8 ... | ||
``` | ||
|
||
<br> | ||
|
||
# Configurar as credências da sua conta da AWS ⚒️ | ||
|
||
**Após instalar a CLI da AWS, é necessário colocar as credências da conta da AWS com o seguintes comandos abaixo, também vai estar a lista das credênciais:** | ||
|
||
- aws_access_key_id | ||
- aws_secret_access_key | ||
- aws_session_token | ||
|
||
```bash | ||
aws configure | ||
``` | ||
|
||
 | ||
|
||
```bash | ||
aws configure set aws_session_token SESSIONTOKENHERE | ||
``` | ||
<br> | ||
|
||
Agora você pode navegar pela parte dos comandos do terraform, tendo a explicação de cada um deles 🟪 | ||
|
||
[Comandos do terraform e seus objetivos](./terraform.md) |
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 @@ | ||
O Terraform é uma ferramenta de infraestrutura como código (IaC) que permite aos desenvolvedores e administradores de sistemas definir, provisionar e gerenciar recursos de infraestrutura de uma maneira declarativa e eficiente. | ||
|
||
**Código localizado na pasta infra do projeto** | ||
|
||
Pode seguir com a parte de configuração para rodar o terraforme na máquina 😁 | ||
|
||
|
||
[Configuração na maquina](./config.md) | ||
|
||
 |
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,25 @@ | ||
## Evidencias da execução do código 🦆 | ||
|
||
<br> | ||
|
||
### Configurando as credências da aws academy 😶 | ||
|
||
 | ||
 | ||
 | ||
|
||
<br> | ||
|
||
### Executando coandos do terraform 😶 | ||
|
||
 | ||
 | ||
 | ||
 | ||
 | ||
|
||
<br> | ||
|
||
### Dashboard da aws com a ec2 criada pelo 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,58 @@ | ||
## Passo a passo da ponderada | ||
|
||
Para deixar tudo de uma forma unificada passo a passo de como utilizar o terraform para subir uma EC2 na sua AWS Academy 💪 | ||
|
||
### 1ª Instalar a CLI do terraform e da AWS | ||
|
||
Primeiro você deve seguir o tutorial de instalação das duas CLI's, segue os links abaixo: | ||
|
||
[Como instalar a CLI do terraform](config.md/#instalar-a-cli-do-terraform) | ||
|
||
[Como instalar a CLI da AWS](config.md/#instalar-a-cli-da-aws) | ||
|
||
### 2ª Configurar as credências da AWS na CLI | ||
|
||
Você vai precisar ter as credências da sua AWS academy, segue o tutotial a baixo | ||
|
||
[Video de como pegar as credências](./assets/tutorial_crede.mp4) | ||
|
||
Após isso você pode seguir o tutorial de inserir na CLI da AWS as credências aqui: | ||
|
||
[Colocando credências pela CLI da AWS](config.md/#configurar-as-credencias-da-sua-conta-da-aws) | ||
|
||
### 3ª Entrar na pasta da Infra do projeto e executar os comandos do terraform | ||
|
||
```bash | ||
# entrar na pasta com o codigo do terraform | ||
cd infra | ||
``` | ||
|
||
Após isso você deve executar os comandos do terraform abaixo: | ||
|
||
```bash | ||
terraform init | ||
``` | ||
|
||
```bash | ||
terraform fmt | ||
``` | ||
|
||
```bash | ||
terraform validate | ||
``` | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
|
||
```bash | ||
terraform plan | ||
``` | ||
|
||
a explicação de cada comando está no link abaixo | ||
|
||
[terraform comandos](./terraform.md) | ||
|
||
### 4ª Sucesso !!! | ||
|
||
Caso queira ver s edeu tudo certo pode acessar os logs nesse [link](./logs.md) para validar se os seus retornos também foram esses. |
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,58 @@ | ||
## Comandos do terraform 💻 | ||
|
||
Aqui você vai visualizar os comandos basicos que foi utilizado nessa ponderada, e suas explicações. | ||
|
||
Assim podendo ser revisado futuramente, caso você esqueça de como utilizar o terraform no terminal | ||
|
||
### Executando código do Terraform | ||
|
||
**Após realizar todas as configurações acima, você deve acessar a pasta infra do projeto e logo em seguida executar os seguintes comandos no terminal:** | ||
|
||
|
||
|
||
<p><span style="color: purple;">terraform init</span>: Este comando é usado para inicializar um diretório de trabalho do Terraform. Ele é geralmente executado no início de um novo projeto ou quando o diretório do projeto é atualizado com novos plugins ou módulos. Durante a inicialização, o Terraform baixa os plugins necessários para a configuração do provedor (por exemplo, AWS, Azure, Google Cloud, etc.) e estabelece uma conexão com o backend de armazenamento de estado, se aplicável.</p> | ||
|
||
```bash | ||
terraform init | ||
``` | ||
|
||
|
||
|
||
<br> | ||
|
||
<p><span style="color: purple;">terraform fmt</span>: Este comando é usado para formatar o código do Terraform de acordo com as convenções de estilo recomendadas pelo Terraform. Ele ajusta a indentação, espaçamento e formatação geral do código para torná-lo mais legível e consistente. Executar terraform fmt ajuda a manter um estilo de código uniforme em um projeto e facilita a colaboração entre membros da equipe.</p> | ||
|
||
```bash | ||
terraform fmt | ||
``` | ||
|
||
<br> | ||
|
||
|
||
<p><span style="color: purple;">terraform validate</span>: Este comando é usado para validar a sintaxe e a semântica do código do Terraform. Ele verifica se o código está correto em termos de estrutura e configuração. Durante a validação, o Terraform analisa os arquivos de configuração e identifica quaisquer erros ou avisos, como referências a recursos inexistentes ou configurações inválidas.</p> | ||
|
||
```bash | ||
terraform validate | ||
``` | ||
|
||
<br> | ||
|
||
<p><span style="color: purple;">terraform plan</span>: Este comando é usado para criar um plano de execução do Terraform. Ele examina o código do Terraform e determina quais mudanças serão feitas na infraestrutura quando o comando terraform apply for executado. O plano mostra uma visão geral das adições, atualizações e remoções de recursos que ocorrerão, permitindo que você revise e confirme as mudanças antes que sejam aplicadas.</p> | ||
|
||
```bash | ||
terraform plan | ||
``` | ||
|
||
<br> | ||
|
||
|
||
<p><span style="color: purple;">terraform apply</span>: Este comando é usado para aplicar as mudanças planejadas à infraestrutura. Quando executado, o Terraform verifica o plano de execução gerado pelo comando terraform plan e solicita confirmação para aplicar as mudanças. Depois de confirmado, o Terraform faz as alterações na infraestrutura de acordo com o plano e atualiza o estado do projeto para refletir as mudanças realizadas.</p> | ||
|
||
```bash | ||
terraform apply | ||
``` | ||
<br> | ||
|
||
Após essa mini aulinha dos comandos que eu executei, vou mostrar os logs e as evidências desse processo como um todo | ||
|
||
[Evidências da ponderada](logs.md) |
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,23 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 4.16" | ||
} | ||
} | ||
|
||
required_version = ">= 1.2.0" | ||
} | ||
|
||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
|
||
resource "aws_instance" "app_server" { | ||
ami = "ami-0fc5d935ebf8bc3bc" | ||
instance_type = "t3.medium" | ||
|
||
tags = { | ||
Name = "ExampleAppServerInstance" | ||
} | ||
} |
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 @@ | ||
site_name: "Ponderada de programação semana 9 - M10" | ||
theme: | ||
name: "material" | ||
nav: | ||
- Passo a passo 🐣: passo.md | ||
- O que é terraform 🤔: index.md | ||
- Configuração na sua maquina 🤖: config.md | ||
- Terraform 🟪: terraform.md | ||
- Logs 📗: logs.md |
Oops, something went wrong.