forked from CSYE-6225-Cloud-Computing/aws-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_data.sh
37 lines (26 loc) · 787 Bytes
/
user_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /bin/bash
cat << EOF >> home/ec2-user/webapp/app.env
DB_HOST=${db_host}
DB_USER=${db_user}
DB_PASS=${db_pwd}
DB_DATABASE=${db}
DB_DIALECT=${db_engine}
DB_PORT=${db_port}
AWS_BUCKET_NAME=${s3_bucket}
AWS_BUCKET_REGION=${s3_region}
PORT="8080"
EOF
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
-a fetch-config \
-m ec2 \
-c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json \
-s
sudo systemctl daemon-reload
# cloud watch agent service start
sudo systemctl enable amazon-cloudwatch-agent
sudo systemctl start amazon-cloudwatch-agent
sudo systemctl status amazon-cloudwatch-agent
# webapp service start
sudo systemctl enable webapp.service
sudo systemctl start webapp.service
sudo systemctl status webapp.service