Skip to content

Commit

Permalink
fix: aula terraform test
Browse files Browse the repository at this point in the history
  • Loading branch information
gomex committed Jul 16, 2024
1 parent 92f6d28 commit d2c3a0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Módulo para criação do ambiente sugerido pelo professor

# TODO ( Para fazer)

- Uma etapa do pipeline que atualize automaticamente a versão do example
- Uma etapa do pipeline que atualize automaticamente a versão do example
- Adicionar teste automatizado no pipeline
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data "aws_ami" "ubuntu" {

resource "aws_instance" "this" {
ami = data.aws_ami.ubuntu.id
instance_type = each.value["instance_type"]
instance_type = "t3.micro"

dynamic "ebs_block_device" {
for_each = var.ebs_block_devices
Expand Down
3 changes: 2 additions & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
output "public_ip" {
description = "IPs públicos"
value = { for key, instance in aws_instance.this : instance.tags["Env"] => instance.public_ip... }
value = aws_instance.this.public_ip
}


15 changes: 15 additions & 0 deletions tests/instancia.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variables {
nome = "test"
}

run "validar_nome" {

command = apply

assert {
condition = aws_instance.this.tags["Name"] == var.nome
error_message = "Nome inválido"
}

}

0 comments on commit d2c3a0f

Please sign in to comment.