Creating Employee Directory Application automatically with AWS
🔥You can create an EC2 Amazon Linux 2023 user data script
It will run script after you start EC2.
Launch EC2 instance
select the Amazon Machine Image
Amazon Machine Images can come from AWS, like this Amazon Linux 2023 AMI, for example. This is the one that we will be using, but you can also browse more AMIs that would include AMIs coming from the AWS Marketplace.
Next, we have to decide if we want to configure a key pair.
We are going to select that we are going to proceed without a key pair for this, and the reason for that is because I don't intend to SSH into this instance to connect to it.Network settings
Edit
Keep the default VPC selection
Subnet: Choose the first subnet in the dropdown list
Auto-assign Public IP: Enable🖱️
Then expanding the advanced details section
under IAM instance profile choose S3DynamoDBFullAccessRole
pasting user data below (change
AWS_DEFAULT_REGION
)
click Launch instances
For Amazon Linux 2023
#!/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=ap-northeast-1
export DYNAMO_MODE=on
FLASK_APP=application.py /usr/local/bin/flask run --host=0.0.0.0 --port=80
For Amazon Linux 2
#!/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
open address🔚
your Employee Directory Application running~
when you start the instance, the script will execute.
Top comments (0)