From 8ab4f302acbc98301b995f4101c1695c7c99198e Mon Sep 17 00:00:00 2001 From: Andy Miles Date: Thu, 5 Dec 2024 07:31:21 -0800 Subject: [PATCH] adding ssh for debug --- terraform/main.tf | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index d871c8a..b25f099 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -3,14 +3,33 @@ provider "aws" { } resource "aws_key_pair" "deployer" { - key_name = "my-key-pair" # Set this to any descriptive name you prefer + key_name = "deployer-key" # Set this to any descriptive name you prefer public_key = file("~/.ssh/id_rsa.pub") # Path to your public key file } + 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 = ["0.0.0.0/0"] # Be cautious with this setting; restrict to specific IPs if possible + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } + } + resource "aws_instance" "py_server" { ami = "ami-06946f6c9b153d494" instance_type = "t2.micro" - key_name = aws_key_pair + key_name = aws_key_pair.deployer.key_name user_data = <<-EOF #!/bin/bash sudo apt-get update @@ -35,25 +54,6 @@ resource "aws_instance" "py_server" { aws_security_group.allow_ssh.id] } - 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 = ["0.0.0.0/0"] # Be cautious with this setting; restrict to specific IPs if possible - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - } - resource "aws_security_group" "allow_http" { name = "allow_http_flask_web_app" description = "Allow inbound HTTP traffic"