Ainda não tem acesso? Estude com a gente! Matricule-se
Ainda não tem acesso? Estude com a gente! Matricule-se

Solucionado (ver solução)

Erro ao aplicar "terraform apply" na criação da maquina dev5

Está aparecendo esse erro na execução, ele informa que tal valor() não pode ficar vazio, já conferi N vezes e não encontrei a causa desse erro. Segue erro e outros códigos abaixo. Obrigada

Error: Error launching instance, possible mismatch of Security Group IDs and Names. See AWS Instance docs here: https://terraform.io/docs/providers/aws/r/instance.html.

        AWS Error: InvalidParameterValue: Value () for parameter groupId is invalid. The value cannot be empty
        status code: 400, request id: 0c9b9bbb-7141-4a9e-91b3-2d54562355d3


Error: InvalidGroup.NotFound: The security group 'aws_security_group.acesso-ssh.id' does not exist
        status code: 400, request id: 6715ef1a-9466-4398-bde3-39b05fbf4f6b


Error: InvalidGroup.NotFound: The security group 'aws_security_group.acesso-ssh.id' does not exist
        status code: 400, request id: 3495bd17-d3a9-4d43-9150-ce735ee2b7c9


Error: InvalidGroup.NotFound: The security group 'aws_security_group.acesso-ssh.id' does not exist
        status code: 400, request id: 1ebc26b3-177a-4ba2-af69-afe1d772f01c


Error: InvalidGroup.NotFound: The security group 'aws_security_group.acesso-ssh.id' does not exist
        status code: 400, request id: 99b09f53-347d-4385-8d1f-f68009361795

Error: InvalidGroup.NotFound: The security group 'aws_security_group.acesso-ssh.id' does not exist
        status code: 400, request id: 97141e9b-79fb-4ed1-aaea-d19d94ff0bbf

Arquivo main

 provider "aws" {
    version = "~> 3.0"
    region = "us-east-1"
 }

  provider "aws" {
     alias ="us-east-2"
    version = "~> 3.0"
    region = "us-east-2"
 }

 resource "aws_instance" "dev" {
    count = 3
    ami = "ami-026c8acd92718196b"
    instance_type = "t2.micro"
    key_name = "terraform-aws"
    tags = {
       Name = "dev${count.index}"
    }
    vpc_security_group_ids = ["aws_security_group.acesso-ssh.id"]
 }

   resource "aws_instance" "dev4" {
    ami = "ami-026c8acd92718196b"
    instance_type = "t2.micro"
    key_name = "terraform-aws"
    tags = {
       Name = "dev4"
    }
    vpc_security_group_ids = ["aws_security_group.acesso-ssh.id"]
    depends_on = [aws_s3_bucket.dev4]
 }

  resource "aws_instance" "dev5" {
    ami = "ami-026c8acd92718196b"
    instance_type = "t2.micro"
    key_name = "terraform-aws"
    tags = {
       Name = "dev5"
    }
    vpc_security_group_ids = ["aws_security_group.acesso-ssh.id"]   
 }  

 resource "aws_instance" "dev6" {
    provider = aws.us-east-2
    ami = "ami-0d8f6eb4f641ef691"
    instance_type = "t2.micro"
    key_name = "terraform-aws"
    tags = {
       Name = "dev6"
    }
    vpc_security_group_ids = ["aws_security_group.acesso-ssh-us-east-2.id"]
    depends_on= [aws_dynamodb_table.dynamodb-homol]
    }  

resource "aws_s3_bucket" "dev4" {
  bucket = "mybucket-dev4"
  acl    = "private"

  tags = {
    Name = "mybucket-dev4"
  }
}

resource "aws_dynamodb_table" "dynamodb-homol" {
  provider = aws.us-east-2
  name           = "GameScores"
  billing_mode   = "PAY_PER_REQUEST"
  hash_key       = "UserId"
  range_key      = "GameTitle"

  attribute {
    name = "UserId"
    type = "S"
  }

  attribute {
    name = "GameTitle"
    type = "S"
  }
 }

Arquivo security-group

resource "aws_security_group" "acesso-ssh" {
  name        = "acesso-ssh"
  description = "acesso-ssh"

  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["187.122.41.55/32"]
  }
  tags = {
    Name = "ssh"
  }
}

resource "aws_security_group" "acesso-ssh-us-east-2" {
  provider = aws.us-east-2  
  name        = "acesso-ssh"
  description = "acesso-ssh"

  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["187.122.41.55/32"]
  }
  tags = {
    Name = "ssh"
  }
}
1 resposta
solução

Resolvido

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software