Skip to content

Commit

Permalink
changed flask run command
Browse files Browse the repository at this point in the history
  • Loading branch information
proquickly committed Nov 19, 2024
1 parent af74d30 commit dc037ba
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,29 @@ resource "aws_instance" "py_server" {
ami = "ami-06946f6c9b153d494"
instance_type = "t2.micro"

user_data = <<-EOF
user_data = <<-EOF
#!/bin/bash
sudo apt-get update
sudo apt-get install -y python3 python3-pip
# Install Flask
pip3 install flask
# Create application directory
mkdir -p /home/ubuntu/app
# Write the Python script to a file
cat <<EOL > /home/ubuntu/app/app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello from Python!"
app.run(host='0.0.0.0', port=5000)
EOL
# Change to the application directory and run the app
cd /home/ubuntu/app
python3 app.py &
nohup python3 /home/ubuntu/app/app.py &
EOF

tags = {
Name = "FlaskAppInstance"
}

vpc_security_group_ids = [aws_security_group.allow_http.id]
}

resource "aws_security_group" "allow_http" {
Expand Down

0 comments on commit dc037ba

Please sign in to comment.