Skip to content

Commit

Permalink
adding ssh for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
proquickly committed Dec 5, 2024
1 parent 48f6177 commit c82eba3
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ provider "aws" {
region = "us-west-2"
}

resource "aws_key_pair" "deployer" {
key_name = "my-key-pair" # Set this to any descriptive name you prefer
public_key = file("~/.ssh/id_rsa.pub") # Path to your public key file
}

resource "aws_instance" "py_server" {
ami = "ami-06946f6c9b153d494"
instance_type = "t2.micro"

key_name = aws_key_pair
user_data = <<-EOF
#!/bin/bash
sudo apt-get update
Expand All @@ -26,9 +31,29 @@ resource "aws_instance" "py_server" {
Name = "FlaskAppInstance"
}

vpc_security_group_ids = [aws_security_group.allow_http.id]
vpc_security_group_ids = [aws_security_group.allow_http.id,
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"
Expand Down

0 comments on commit c82eba3

Please sign in to comment.