I cannot connect to my EC2 Instance via HTTPS Protocol (I click "open address" button in Instance Summary next to Public IPv4 Address")

0

Good Day,

Please help me.

In AWS Skills Builder, Module 2 - Lesson 16 - Demonstration: Launching the Employee Directory Application on Amazon EC2 it guided me to create EC2 instance.

I create instance per tutorial video and I click open address(see attached ss) and error page(see attached ss)...

I can't connect to my instance via EC2 Instance Connect. I go to Systems Manager and start session, I run: sudo -i sudo yum install httpd -y

I think maybe now I can connect EC2 Instance Connect? Yes, nice. I verify that I can connect, but I still keep running commands in Systems Manager Session. Now, I run: sudo systemctl start httpd sudo systemctl enable httpd

I know I can now click open address (see attached ss) in instance summary tab for my instance, and it will take me to error page(see attached ss). After this, I can try http by removing the s from https in url, and successful!

However, could you please help me in explaining why is it that the script is not working properly? I know I created Amazon Linux 2023 Instance, so I used the Amazon Linux 2023 Instance user data script from the tutorial video (please see below).

Amazon Linux 2023 user data script:

#!/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-pip pip install -r requirements.txt 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

"in Insert-Region Here I put the region of where I am us-east-2"

Finally, could you please help me understand why the final result of "how it looks for me"(see attached ss) is not the same as "how it looks for instructor"(see attached ss). Also, help me understand why I can't just click open address and connect to my instance like I see in the tutorial video?

P.S:

  1. All system checks are passed and instance is in running state

  2. Internet connection is stable and I am able to visit other website (for example, Gmail)

  3. Security Group has correct Inbound/Outbound rules for SSH, HTTPS, HTTP (In AWS Skills Builder, Module 2 - Lesson 16 - Demonstration: Launching the Employee Directory Application, the lesson guided me to set up HTTPS/HTTP inbound rules) are correct.

  4. Subnet is correct, and the Access Control List is correct, and the Route Table has a correct Internet Gateway that is active and good.

  5. Request timed out when I ping my website.

  6. I can access my website via HTTP, just not HTTPS, and again there is the fact that it just says [It Works] vs [Employee-Directory-App] like it shows in the video.

I posted 3 pictures in postimg.cc because I could not attach screenshots. Attachments (https://postimg.cc/gallery/2b5sJN7) Error Page and Open Address.png How it looks for instructor.png How it looks for me.png

Please help me, Amazon Support couldn't help me, and I'm too broke to afford paid technical support, but I can't give up on learning aws, this is the first time in my life where I actually feel like my life has a meaning. I need to learn this like I need to breathe.

  • Added comment to my answer which will put everything to rest my friend.

User19r
asked 9 months ago458 views
2 Answers
2
Accepted Answer

This skills tests DOES NOT setup HTTPS. As per the instructions this will only work over HTTP. https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/exercise-3-compute.html

As part of the instructions in task 2, step 3 it states:-

In a new browser window, paste the IP address that you copied. Make sure to remove the ‘S’ after HTTP so you are using only HTTP instead.

There are no steps to setup HTTPs in this excercise. You have completed the task correctly. There is nothing to worry about, all is good.

profile picture
EXPERT
answered 9 months ago
  • Gary, honestly this makes me feel really good, but at the same time in the instruction video, when the instructor clicks "open address" next to Public IPv4 address in Instance Summary for [myinstance], she arrives at the window that Riku_Kobayashi arrived at when doing that tutorial. I cannot arrive to this window, for me when I access http it just states on the web browser page "It Works!", and when I try to access https, it gives me an error. (HTTPS is automatically tried when clicking "open address"). I'm sorry I'm so stubborn, but did I really complete this task if I can't view what the instructor is viewing when I followed her instructions to the T?

    AWS Skills Builder Link: https://explore.skillbuilder.aws/learn/course/1851/play/85986/aws-technical-essentials;lp=1044

  • Several things to mention here.. In the excercise it states "The demonstration video below is intended as visual walk-through and not as a hands-on exercise." When the instructor hovered over the link, it did infact show a URL of HTTPs. What you dont see is her browser window open, its already open. I conclude that its impossible for this to work on https and the instructor changed the site to http from https and was left out and not clearly stated.

  • Also, 3:30 in the video, she states "We are going to be only using http directly" when configuring the security group

  • You weren't lying when you said this would put everything to rest my friend. Hit me with the 1 2 combo of "do you even listen" and "pay closer attention" in 2 breezy comments. I really appreciate it. I promise to listen more attentively and focus on visual references a little bit less. Thanks again, you are the man Gary!

  • Hey don’t kick yourself. It’s great you’re learning and trying, it’s not straight forward and so many moving parts.. I’ve been in the game 25 years and there’s always something new to learn. Enjoy reach out anytime.

1

Hello.
You have httpd installed, but installation is not required.
If httpd is installed, stop it with the following command.

sudo systemctl stop httpd

I also ran the user data script and was able to get it to work correctly.

#!/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-pip 
pip install -r requirements.txt
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

web

profile picture
EXPERT
answered 9 months ago
  • Failed to stop httpd.service: Unit httpd.service not loaded. This is after I created a new instance with this script, and did not install anything with the sudo commands in Amazon EC2 Instance Connect Client.

  • Can you confirm that the process is running with the following command? Also, have you changed the <INSERT REGION HERE> in the script to the region you are using?

    ps aux | grep "/usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80"
    

    When accessing by EC2 public IP address, access as follows.

    http://your EC2 Public IP
    
  • Thank you so much for responding so quickly. I hope you could help me solve this... Okay, how could I confirm that the process is running with that command ? ps aux | grep "/usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80" Where do I run that command to check this? Edit: I just ran this in EC2 Connect Client: [ec2-user@ip-172-31-2-106 ~]$ ps aux | grep "/usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80" ec2-user 3100 0.0 0.2 222356 2028 pts/0 S+ 01:41 0:00 grep --color=auto /usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80

    yes, I changed the region to us-east-2. Here is my Public IPv4 Address. In the tutorial, it is called the open address button to access this Public IPv4 address: Public IPv4 address 18.224.73.69 | open address When I run http://18.224.73.69 I get this: This site can’t be reached 18.224.73.69 refused to connect. Try: Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED

  • Thanks for the reply. When the process is running, it looks like this. So, in your case, the process is not started. If the process is not running, the application cannot be accessed.

    [ssm-user@ip-172-31-34-37 bin]$ ps aux | grep "/usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80"
    root        2477  1.6  4.9 285604 48572 ?        S    01:57   0:00 /usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80
    ssm-user   25038  0.0  0.2 222356  2024 pts/0    S+   01:57   0:00 grep --color=auto /usr/bin/python3 /usr/local/bin/flask run --host=0.0.0.0 --port=80
    

    Perhaps you are not getting the user data scripts to work well with your EC2. First run the following command in EC2 via Instance Connect instead of user data to see where the problem is.

    sudo su -
    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-pip 
    pip install -r requirements.txt
    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
    
  • sudo su -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-pip pip install -r requirements.txt 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 su: user https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/FlaskApp.zip does not exist or the user entry does not contain all the required fields unzip: cannot find or open FlaskApp.zip, FlaskApp.zip.zip or FlaskApp.zip.ZIP. -bash: cd: FlaskApp/: No such file or directory Last metadata expiration check: 2:34:38 ago on Tue Aug 8 00:08:14 2023. Package python3-pip-21.3.1-2.amzn2023.0.5.noarch is already installed. Dependencies resolved. Nothing to do. Complete! ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' Last metadata expiration check: 2:34:39 ago on Tue Aug 8 00:08:14 2023. Package stress-1.0.4-28.amzn2023.0.2.x86_64 is already installed. Dependencies resolved. Nothing to do. Complete! -bash: syntax error near unexpected token `newline' Usage: flask run [OPTIONS] Try 'flask run --help' for help.

    Error: Could not import 'application'.

    This is what I get when I run that command.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions