employee directotory exercise3 - Launching an EC2 Instance

1

hello Im trying to process excersice 3 for creation of EC2 instance as part of online training. all isntructions are described here : https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/exercise-3-compute.html

Im able to succesfully create EC2 instnace but page which shoudl be available is till unreacable Im able to connect to linux server where below code should be executed as part of instance createion (according to isntructions) #!/bin/bash -ex wget https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip unzip FlaskApp.zip cd FlaskApp/ yum -y install python3 mysql pip3 install -r requirements.txt amazon-linux-extras install epel yum -y install stress export PHOTOS_BUCKET=${SUB_PHOTOS_BUCKET} export AWS_DEFAULT_REGION=<INSERT REGION HERE> export DYNAMO_MODE=on FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80

however nothing fromt this is executed on the server. When I try to execute this manualy one by one I have to additionaly use sudo command and install individualy pip3 and still amazon-linux-extras is not executable. At the and page is still not reachable. I think that the provided instructution for this excercise are realy outdated. So can anybody help me to successfully complete this excercise so page be reachable? What is the peroper set of commands whcih have to be executed? And why non of them is executed duritng boot as they are part of user data box durign instance creation ?

Thank you anybody for the answer.

Regards

已提問 1 年前檢視次數 290 次
2 個答案
0

Hi, After spent a couple of hours I was able to run it. Steps

  1. Add SSH in the security group as inbound.
  2. Connect your EC2 instance and install python3 + pip3.
  3. Install Flask
  4. Due to Flask security reason you cannot run in Port 80 because it was considered as production App. The current project can be easily run on Port 8080.
  5. If you want to run on Port 80 then you should use some CGI server as there are plenty of options.
  6. Before running App on Port 8080 you must add security group inbound rule "Custom TCP" in Port Range : 8080 I hope it will help you

Thanks in advance

已回答 1 年前
0

Hey, I'm also doing the program on coursera and encountering the same problem. Have reported it as an issue on the course, so hopefully they fix that soon. In the meantime, choosing a different AMI (Amazon Linux 2) makes the instance work as intended, without manually needing to ssh and install stuff. Reference: https://repost.aws/questions/QUXuZePk-bR5ePXWyxqjFLaA/coursera-aws-cloud-technical-essentials-help-exercise-3-launching-an-ec-2-instance

As for the needing to use sudo - "Scripts entered as user data are run as the root user", which is why sudo is not included in the user data script but you need to include it as ec2-user when you ssh. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts

已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南