-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_machine_script.tmpl
49 lines (44 loc) · 1.73 KB
/
create_machine_script.tmpl
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# sudo yum update -y
# sudo amazon-linux-extras install docker -y
# sudo yum install git -y
# sudo amazon-linux-extras install vim -y
# sudo amazon-linux-extras install postgresql11
# sudo service docker start
# sudo groupadd docker
# sudo gpasswd -a ec2-user docker
# sudo usermod -aG docker ec2-user
# sudo systemctl restart docker
# sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
# sudo chmod +x /usr/local/bin/docker-compose
# # Monitoring memory and disk utilization with cloudwatch alarm
# cd /tmp
# wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
# sudo rpm -U amazon-cloudwatch-agent.rpm
# sudo cat <<EOT >> amazon-cloudwatch-agent.json
# {
# "agent": {
# "metrics_collection_interval": 60
# },
# "metrics": {
# "metrics_collected": {
# "disk": {
# "resources": ["/", "/tmp"],
# "measurement": ["disk_used_percent"],
# "ignore_file_system_types": ["sysfs", "devtmpfs"]
# },
# "mem": {
# "measurement": ["mem_used_percent"]
# }
# },
# "aggregation_dimensions": [["InstanceId", "InstanceType"], ["InstanceId"]],
# "append_dimensions": {
# "InstanceId": "AWS_INSTANCE_ID"
# }
# }
# }
# EOT
# sudo sed -i 's/AWS_INSTANCE_ID/$${aws:InstanceId}/g' amazon-cloudwatch-agent.json
# sudo cp amazon-cloudwatch-agent.json /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json
# 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
# sudo systemctl restart amazon-cloudwatch-agent