-
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.
- Loading branch information
1 parent
59ca0e2
commit 8c31883
Showing
6 changed files
with
182 additions
and
1 deletion.
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 |
---|---|---|
@@ -1 +1,18 @@ | ||
# fast-food-net | ||
# Nome do Projeto | ||
> Breve descrição do projeto e seu propósito. ## Índice | ||
. [Descrição](#descrição) | ||
. [Pré-requisitos](#pré-requisitos) | ||
. [Instalação](#instalação) | ||
. [Uso](#uso) | ||
. [Contribuição](#contribuição) | ||
. [Licença](#licença) ## Descrição | ||
Descreva o que o projeto faz, seus principais recursos e o problema que ele resolve. ## Pré-requisitos | ||
Liste os pré-requisitos necessários para rodar o projeto. Exemplo: | ||
- [Node.js](https://nodejs.org/) >= 14.x | ||
- [Python](https://www.python.org/) >= 3.8 | ||
- Dependências específicas do sistema operacional, se houver. ## Instalação | ||
Explique como instalar o projeto. Exemplo: ```bash | ||
# Clone o repositório | ||
git clone https://github.com/usuario/projeto.git # Acesse o diretório do projeto | ||
cd projeto # Instale as dependências | ||
npm install |
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,36 @@ | ||
# Criar a VPC | ||
resource "aws_vpc" "main" { | ||
description = "VPC para os serviços da aplicação fastfodd" | ||
cidr_block = var.vpc_cidr | ||
tags = { | ||
Name = "fastfood-vpc" | ||
} | ||
} | ||
|
||
# Criar as Subnets | ||
resource "aws_subnet" "subnet_1" { | ||
vpc_id = aws_vpc.main.id | ||
cidr_block = var.subnet_1_cidr | ||
availability_zone = var.availability_zone_1 | ||
tags = { | ||
Name = "subnet-1" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "subnet_2" { | ||
vpc_id = aws_vpc.main.id | ||
cidr_block = var.subnet_2_cidr | ||
availability_zone = var.availability_zone_2 | ||
tags = { | ||
Name = "subnet-2" | ||
} | ||
} | ||
|
||
resource "aws_subnet" "subnet_3" { | ||
vpc_id = aws_vpc.main.id | ||
cidr_block = var.subnet_3_cidr | ||
availability_zone = var.availability_zone_3 | ||
tags = { | ||
Name = "subnet-3" | ||
} | ||
} |
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,19 @@ | ||
output "vpc_id" { | ||
description = "ID da VPC" | ||
value = aws_vpc.main.id | ||
} | ||
|
||
output "subnet_1_id" { | ||
description = "ID da primeira Subnet" | ||
value = aws_subnet.subnet_1.id | ||
} | ||
|
||
output "subnet_2_id" { | ||
description = "ID da segunda Subnet" | ||
value = aws_subnet.subnet_2.id | ||
} | ||
|
||
output "subnet_3_id" { | ||
description = "ID da terceira Subnet" | ||
value = aws_subnet.subnet_3.id | ||
} |
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 @@ | ||
# Armazenar o ID da VPC no Parameter Store | ||
resource "aws_ssm_parameter" "vpc" { | ||
name = "/rds/vpc" | ||
type = "String" | ||
value = aws_vpc.main.id | ||
} | ||
|
||
# Armazenar os IDs das Subnets no Parameter Store | ||
resource "aws_ssm_parameter" "subnet_1" { | ||
name = "/rds/subnet_1" | ||
type = "String" | ||
value = aws_subnet.subnet_1.id | ||
} | ||
|
||
resource "aws_ssm_parameter" "subnet_2" { | ||
name = "/rds/subnet_2" | ||
type = "String" | ||
value = aws_subnet.subnet_2.id | ||
} | ||
|
||
resource "aws_ssm_parameter" "subnet_3" { | ||
name = "/rds/subnet_3" | ||
type = "String" | ||
value = aws_subnet.subnet_3.id | ||
} |
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,41 @@ | ||
variable "availability_zone_1" { | ||
description = "Zona de disponibilidade para a primeira Subnet" | ||
type = string | ||
default = "us-east-1a" | ||
} | ||
|
||
variable "availability_zone_2" { | ||
description = "Zona de disponibilidade para a segunda Subnet" | ||
type = string | ||
default = "us-east-1b" | ||
} | ||
|
||
variable "availability_zone_3" { | ||
description = "Zona de disponibilidade para a terceira Subnet" | ||
type = string | ||
default = "us-east-1c" | ||
} | ||
|
||
variable "vpc_cidr" { | ||
description = "CIDR block da VPC" | ||
type = string | ||
default = "10.0.0.0/16" | ||
} | ||
|
||
variable "subnet_1_cidr" { | ||
description = "CIDR block da primeira Subnet" | ||
type = string | ||
default = "10.0.1.0/24" | ||
} | ||
|
||
variable "subnet_2_cidr" { | ||
description = "CIDR block da segunda Subnet" | ||
type = string | ||
default = "10.0.2.0/24" | ||
} | ||
|
||
variable "subnet_3_cidr" { | ||
description = "CIDR block da terceira Subnet" | ||
type = string | ||
default = "10.0.3.0/24" | ||
} |
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,43 @@ | ||
name: Deploy or Destroy | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
destroy_flag: | ||
description: 'Flag to trigger destroy' | ||
required: true | ||
default: "false" | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Passo 1: Checkout do código | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
# Passo 2: Configurar as credenciais da AWS | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
# Passo 3: Instalar o Terraform | ||
- name: Set up Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
|
||
# Passo 4: Inicializar o Terraform com o backend remoto | ||
- name: Initialize Terraform | ||
run: terraform init | ||
|
||
# Passo 5: Aplicar ou Destruir a Infraestrutura | ||
- name: Apply or Destroy Terraform | ||
run: | | ||
if [ "${{ github.event.inputs.destroy_flag }}" == "true" ]; then | ||
terraform destroy -auto-approve | ||
else | ||
terraform apply -auto-approve | ||
fi |