From cf058b8ec012207de075e98f2f837ba2ececf09b Mon Sep 17 00:00:00 2001 From: Andy Miles Date: Wed, 13 Nov 2024 18:57:26 -0800 Subject: [PATCH] separated files for reply --- bin/deploy | 6 ++++++ src/tfgha/app.py | 8 ++++++++ terraform/main.tf | 17 +++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100755 bin/deploy create mode 100644 src/tfgha/app.py diff --git a/bin/deploy b/bin/deploy new file mode 100755 index 0000000..96db86e --- /dev/null +++ b/bin/deploy @@ -0,0 +1,6 @@ +#!/bin/sh +cd /app +git clone git@github.com:proquickly/tfgha.git +cd ./tfgha +poetry install +poetry shell && poetry run src/thgha/app.py diff --git a/src/tfgha/app.py b/src/tfgha/app.py new file mode 100644 index 0000000..bf6099f --- /dev/null +++ b/src/tfgha/app.py @@ -0,0 +1,8 @@ +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello(): + return "Hello from Python!" +if __name__ == '__main__': + app.run(host='0.0.0.0', port=5000) diff --git a/terraform/main.tf b/terraform/main.tf index edb02a8..4da0023 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -9,20 +9,13 @@ resource "aws_instance" "py_server" { user_data = <<-EOF #!/bin/bash yum update -y - yum install -y python3 python3-pip + yum install -y python3 python3-pip git curl + curl -sSL https://install.python-poetry.org | python3 - + export PATH="$HOME/.local/bin:$PATH" mkdir /app - cat < /app/app.py - from flask import Flask - app = Flask(__name__) - @app.route('/') - def hello(): - return "Hello from Python!" - if __name__ == '__main__': - app.run(host='0.0.0.0', port=5000) - EOT - pip3 install flask - python3 /app/app.py & + chmod +x ./bin/deploy + ./bin/deploy EOF tags = {