Closed onlinejudge95 closed 1 year ago
Hey Have you checked with your Inbound rules such as SSH, All tcp - any where
I fixed it by updating my security group, For some reason I had misspelled /0
with /32
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Description
My EC2 instance created via this module is up and status checks have passed when checked through the EC2 console but unable to connect to them via putty and/or EC2 Instance Connect.
⚠️ Note
Before you submit an issue, please perform the following first:
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
terraform init
Versions
Module version [Required]:
5.3.0
&5.2.1
Terraform version:
provider registry.terraform.io/hashicorp/archive v2.4.0
provider registry.terraform.io/hashicorp/aws v5.8.0
provider registry.terraform.io/hashicorp/tls v4.0.4
Your version of Terraform is out of date! The latest version is 1.5.5. You can update by downloading from https://www.terraform.io/downloads.html
Terraform v1.5.3 on windows_386
Your version of Terraform is out of date! The latest version is 1.5.5. You can update by downloading from https://www.terraform.io/downloads.html
data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } variable "instances" { type = list(string) default = ["master-node", "worker-node-1", "worker-node-2"] } module "instance_key_pair" { source = "terraform-aws-modules/key-pair/aws" version = "2.0.2" key_name = "infra-management-key" public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMhQdG9PKSfS155RjbJdD5hTMxEU0pzVGExfki4/ldQJ" tags = { "Created By" = "Infrastructure Management User" } } module "instance_security_group" { source = "terraform-aws-modules/security-group/aws" version = "5.1.0" name = "instance-security-group" description = "Security Group for instance" vpc_id = data.aws_vpc.default_vpc.id ingress_with_cidr_blocks = [ { from_port = 22 to_port = 22 protocol = "tcp" description = "Adds rule for SSH" cidr_blocks = "0.0.0.0/32" } ] egress_with_cidr_blocks = [ { from_port = 0 to_port = 0 protocol = "-1" description = "Adds egress rule" cidr_blocks = "0.0.0.0/32" } ] } module "ec2_instance_profile" { source = "s3::https://terraform-registry-wecoach.s3.ap-south-1.amazonaws.com/terraform-aws-ec2-instance-profile" name = "instance-profile" attach_cwagent_policy = true attach_ssm_policy = true policy_arns = [ "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryFullAccess", "arn:aws:iam::aws:policy/AmazonEC2FullAccess", "arn:aws:iam::aws:policy/AmazonS3FullAccess", "arn:aws:iam::aws:policy/IAMFullAccess", "arn:aws:iam::aws:policy/CloudWatchFullAccess", "arn:aws:iam::aws:policy/AmazonSSMFullAccess", ] tags = { "Created By" = "Infrastructure Management User" } } module "ec2_instance" { source = "terraform-aws-modules/ec2-instance/aws" version = "5.3.1" for_each = toset(var.instances) ami = data.aws_ami.ubuntu.id associate_public_ip_address = true monitoring = true instance_type = "t3a.small" key_name = module.instance_key_pair.key_pair_name user_data = file("user_data.sh") vpc_security_group_ids = [module.instance_security_group.security_group_id] iam_instance_profile = module.ec2_instance_profile.profile_name tags = { "Created By" = "Infrastructure Management User" "Name" = each.key } }