Pessoal, tudo certo?
Estou recebendo os erros abaixo ao executar o código na última aula do curso:
╷
│ Error: ELBv2 Target Group (ECS-Go) already exists
│
│ with module.homolog.aws_lb_target_group.alvo,
│ on ../../infra/ALB.tf line 17, in resource "aws_lb_target_group" "alvo":
│ 17: resource "aws_lb_target_group" "alvo" {
│
╵
╷
│ Error: creating IAM Role (homolog_cargo): EntityAlreadyExists: Role with name homolog_cargo already exists.
│ status code: 409, request id: 0144e098-366c-403e-a3f8-e00c7396d7f1
│
│ with module.homolog.aws_iam_role.cargo,
│ on ../../infra/IAM.tf line 1, in resource "aws_iam_role" "cargo":
│ 1: resource "aws_iam_role" "cargo" {
│
╵
╷
│ Error: creating RDS DB Subnet Group (vpc-ecs): DBSubnetGroupAlreadyExists: The DB subnet group 'vpc-ecs' already exists.
│ status code: 400, request id: 8c7f44cc-359d-4761-8fb3-f3d2bae06faf
│
│ with module.homolog.module.vpc.aws_db_subnet_group.database[0],
│ on .terraform/modules/homolog.vpc/main.tf line 371, in resource "aws_db_subnet_group" "database":
│ 371: resource "aws_db_subnet_group" "database" {
│
╵
╷
│ Error: creating EC2 EIP: AddressLimitExceeded: The maximum number of addresses has been reached.
│ status code: 400, request id: f4346eeb-37b1-489c-a5bd-4806089b3c2b
│
│ with module.homolog.module.vpc.aws_eip.nat[1],
│ on .terraform/modules/homolog.vpc/main.tf line 1040, in resource "aws_eip" "nat":
│ 1040: resource "aws_eip" "nat" {
│
╵
╷
│ Error: creating CloudWatch Logs Log Group (/aws/ecs/homolog): ResourceAlreadyExistsException: The specified log group already exists
│
│ with module.homolog.module.ecs.module.cluster.aws_cloudwatch_log_group.this[0],
│ on .terraform/modules/homolog.ecs/modules/cluster/main.tf line 99, in resource "aws_cloudwatch_log_group" "this":
│ 99: resource "aws_cloudwatch_log_group" "this" {
│
╵
Error: Terraform exited with code 1.
Error: Process completed with exit code 1.
`
Não consegui encontrar um solução, pois o primerio código a ser executado é exatamente o -destroy que teóricamente limpa o ambiente para não haver conflitos. Fiz o fork do projeto Infra_CI para o meu github e atualizei o main.tf para suar a imagem que está subindo no dockerhub e alterei a região para usar sa-east-1 que eu já estava usando:
Main.tf:
module "homolog" {
source = "../../infra"
nome_repositorio = "homolog"
cargoIAM = "homolog"
ambiante = "homolog"
imagem="matheusrodacki/go_ci:rollback"
}
output "IP_alb" {
value = module.homolog.IP
}
loadTest.yml:
name: Load Test
on:
workflow_call:
jobs:
ecs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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: sa-east-1
- run: git clone https://github.com/matheusrodacki/Infra_CI.git
- name: HashiCorp - Setup Terraform
uses: hashicorp/setup-terraform@v2.0.3
- run: terraform -chdir=Infra_CI/env/Homolog init
- run: terraform -chdir=Infra_CI/env/Homolog destroy -auto-approve
- run: terraform -chdir=Infra_CI/env/Homolog apply -auto-approve
- run: echo "$(terraform -chdir=Infra_CI/env/Homolog output -raw IP_alb)"
id: URL
- name: Setup Python
uses: actions/setup-python@v2.3.3
with:
python-version: "3.10"
- uses: BSFishy/pip-action@v1
with:
packages: |
locust
- run: |
echo "from locust import HttpUser, TaskSet, task, between" >> locustfile.py
echo "" >> locustfile.py
echo "class UserTasks(TaskSet):" >> locustfile.py
echo " @task(1)" >> locustfile.py
echo " def index(self):" >> locustfile.py
echo ' self.client.get("/bruno")' >> locustfile.py
echo "" >> locustfile.py
echo "class WebsiteUser(HttpUser):" >> locustfile.py
echo " tasks = [UserTasks]" >> locustfile.py
echo " wait_time = between(1, 5)" >> locustfile.py
- name: Roda teste de carga
run: sleep 60s ; locust -f locustfile.py --headless -u 10 -r 5 --run-time 60s -H http://${{ steps.URL.outputs.stdout }}
- run: terraform -chdir=Infra_CI/env/Homolog destroy -auto-approve
links para os repositórios:
https://github.com/matheusrodacki/Entrega-Continua branch rollback
https://github.com/matheusrodacki/Infra_CI branch main