Boa tarde,
Preciso de uma ajuda pessoal, não estou conseguindo accessar minha EC2 instance na AWS mesmo depois de seguir todos os passos da aula. Será que estou esquecendo de algo.
- Chave publica importada na AWS terraform-aws.pub
- Chave privada salvo em ~/.ssh/terraform-aws
- Criei o arquivo main.tf
provider "aws" {
version = "~> 3.0"
region = "us-east-1"
}
resource "aws_instance" "dev" {
count = 1
ami = "ami-02fe94dee086c0c37"
instance_type = "t2.micro"
key_name = "terraform-aws"
tags = {
Name = "dev${count.index}"
}
vpc_security_group_ids = ["sg-0e6ac4c9decb8a79a"]
}
resource "aws_security_group" "allow_ssh" {
name = "allow_ssh"
description = "Allow ssh inbound traffic"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["68.42.223.178/32"]
}
tags = {
Name = "ssh"
}
}
- Executei o commando terraform plan para add o SG cirado do step anterior.
aws_security_group.allow_ssh: Refreshing state... [id=sg-0e6ac4c9decb8a79a]
aws_instance.dev[0]: Refreshing state... [id=i-018de5bcb07aa1654]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# aws_instance.dev[0] will be updated in-place
~ resource "aws_instance" "dev" {
id = "i-018de5bcb07aa1654"
tags = {
"Name" = "dev0"
}
~ vpc_security_group_ids = [
- "sg-07dda0663baf4cfe6",
+ "sg-0e6ac4c9decb8a79a",
]
# (26 unchanged attributes hidden)
# (4 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
- Rodei o terraform apply.
- quando tento testar a conexão ssh, a EC2 está online, porém só vejo o error seguinte.
ssh -i ~/.ssh/terraform-aws ubuntu@ec2-52-207-137-81.compute-1.amazonaws.com
ssh: connect to host ec2-52-207-137-81.compute-1.amazonaws.com port 22: Connection timed out
Att, Edvaldo