Skip to content

Commit

Permalink
fix(instances): remove duplicate instances
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Nov 6, 2024
1 parent 8f99522 commit 110e510
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 114 deletions.
6 changes: 6 additions & 0 deletions instances/envs/production.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
legacy_server_instance_type="t2.micro"
sites_server_instance_type="t3.micro"
ami="ami-0866a3c8686eaeeba"
env="production"
key_name="custom-host"
private_key_path="~/Repositories/nossas/keys/ailton-krenak.pem"
20 changes: 5 additions & 15 deletions instances/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,21 @@ provider "aws" {

# Módulo para o servidor web
module "legacy_server" {
source = "./modules/legacy_server"
source = "./modules/common"
ami = var.ami
instance_type = var.legacy_server_instance_type
env = var.env
instance_name = "legacy-server-${var.env}"
key_name = var.key_name
private_key_path = var.private_key_path
monitoring_files_path = "./monitoring"
}

module "sites_server" {
source = "./modules/sites_server"
source = "./modules/common"
ami = var.ami
instance_type = var.sites_server_instance_type
env = var.env
instance_name = "sites-server-${var.env}"
key_name = var.key_name
private_key_path = var.private_key_path
monitoring_files_path = "./monitoring"
}

# Módulo para o servidor de banco de dados
# module "db_server" {
# source = "./modules/db_server"
# ami_id = var.db_server_ami_id
# instance_type = var.db_server_instance_type
# key_name = var.key_name
# instance_name = "db-server-${var.env}"
# private_key_path = var.private_key_path
# }
}
11 changes: 5 additions & 6 deletions instances/modules/common/main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# resource "aws_key_pair" "devops_key_pair" {
# key_name = "devops-host"
# public_key = file("~/.ssh/id_rsa.pub")
# }
# Define um formato de instância genérica para criar novas instâncias monitoradas
# e habilitadas para implantar arquiteturas baseadas em Docker.

resource "aws_instance" "common_instance" {
resource "aws_instance" "server" {
# Sistema operacional na Amazon
ami = var.ami
instance_type = var.instance_type

Expand Down Expand Up @@ -33,7 +32,7 @@ resource "aws_instance" "common_instance" {
"sudo systemctl start docker",
"sudo systemctl enable docker",
"sudo usermod -aG docker ubuntu",
# Altera o hostname antes de instalar o telegraf
# Altera o hostname antes de instalar o telegraf
"sudo hostnamectl set-hostname --transient --static ${var.instance_name}",
# Inicia a configuração do monitoramento
"cd /home/ubuntu/monitoring/",
Expand Down
16 changes: 0 additions & 16 deletions instances/modules/legacy_server/main.tf

This file was deleted.

29 changes: 0 additions & 29 deletions instances/modules/legacy_server/variables.tf

This file was deleted.

16 changes: 0 additions & 16 deletions instances/modules/sites_server/main.tf

This file was deleted.

29 changes: 0 additions & 29 deletions instances/modules/sites_server/variables.tf

This file was deleted.

4 changes: 1 addition & 3 deletions instances/variables.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
variable ami {
description = "Tipo de imagem para o servidor legado (APIS e Clientes Bonde)"
type = string
default = "ami-0866a3c8686eaeeba"
default = "ami-0866a3c8686eaeeba" # Ubuntu
}

variable "legacy_server_instance_type" {
description = "Tipo de instância para o servidor legado (APIS e Clientes Bonde)"
type = string
default = "t2.micro"
}

variable "sites_server_instance_type" {
description = "Tipo de instância para o servidor de sites (Bonde Público e CMS)"
type = string
default = "t2.micro"
}

variable "env" {
Expand Down

0 comments on commit 110e510

Please sign in to comment.