@@ -9,27 +9,27 @@ echo "RESOURCE_ID=${_NODE_CF_LOGICAL_ID_}" >> /etc/environment
9
9
echo " STACK_NAME=${_STACK_NAME_} " >> /etc/environment
10
10
echo " STACK_ID=${_STACK_ID_} " >> /etc/environment
11
11
12
+ source /etc/environment
13
+
12
14
# ############################
13
15
# Prerequisites
14
- # Aws cli (for signalling)
15
16
# Pip
16
17
# Pipx
17
- # docker.io
18
- # Docker compose
19
18
# Go
20
19
# ############################
21
20
21
+
22
+
23
+
22
24
# Update Ubuntu, answer yes to all prompts non-interactively
23
25
echo " [user-data] Update Ubuntu package list"
26
+ sudo add-apt-repository ppa:deadsnakes/ppa
24
27
sudo apt-get update --yes
25
28
26
29
27
30
# Install pip
28
- echo " [user-data] Install Python, Pip, and Venv"
29
- sudo add-apt-repository ppa:deadsnakes/ppa --yes
30
- sudo apt-get update --yes
31
- sudo apt install python3.7 --yes
32
- sudo apt-get install -y python3-pip python3-venv
31
+ echo " [user-data] Pip"
32
+ sudo apt-get install -y python3-pip
33
33
34
34
35
35
# Install Pipx
@@ -41,7 +41,6 @@ pipx ensurepath
41
41
echo " [user-data] Install Go"
42
42
sudo apt-get install golang-go --yes
43
43
44
- # Install Docker Compose
45
44
# Install ca-certificates, a certificate authority package for verifying third-party identities, and curl, a data transfer tool:
46
45
echo " [user-data] Install ca-certificates"
47
46
sudo apt-get install ca-certificates --yes
@@ -61,68 +60,20 @@ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyring
61
60
echo " [user-data] set read permissions for key"
62
61
sudo chmod a+r /etc/apt/keyrings/docker.asc
63
62
63
+ # install cfn
64
64
65
- # Add the Docker repository to the list of APT sources:
66
- echo \
67
- " deb [arch=$( dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
68
- $( . /etc/os-release && echo " $VERSION_CODENAME " ) stable" | \
69
- sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
70
-
71
- # update again since we added the docker repo to apt sources
72
- echo " [user-data] Update again after adding docker repo to apt sources"
73
- sudo apt-get update --yes
74
-
75
- # Install Docker Compose:
76
- echo " [user-data] Install docker compose"
77
- sudo apt-get install docker-compose-plugin --yes
78
-
79
- # Install Docker.io
80
- echo " [user-data] Install docker.io"
81
- sudo apt-get install docker.io --yes
82
-
83
- # After the download completes, confirm that Docker Compose is installed by typing:
84
- echo " [user-data] run docker compose version"
85
- docker compose version
86
-
87
- echo " [user-data] docker group and usermod"
88
- # Create the docker group if it does not already exist:
89
- sudo groupadd -f docker
90
- # Add the current user to the docker group via the usermod command:
91
- sudo usermod -aG docker $USER
92
-
93
- # Start docker service
94
- echo " [user-data] Starting docker service"
95
- sudo service docker start
96
-
97
- echo " [user-data] Signaling completion to CloudFormation"
98
- if [[ " $STACK_ID " != " none" ]]; then
99
- echo " Install and enable CloudFormation helper scripts"
100
- mkdir -p /opt/aws/
101
- pip3 install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-py3-latest.tar.gz
102
- sudo ln -s /usr/local/init/ubuntu/cfn-hup /etc/init.d/cfn-hup
103
-
104
- echo " Configuring CloudFormation helper scripts"
105
- mkdir -p /etc/cfn/
106
- mv /opt/cfn-hup/cfn-hup.conf /etc/cfn/cfn-hup.conf
107
- sed -i " s;__AWS_STACK_ID__;\" $STACK_ID \" ;g" /etc/cfn/cfn-hup.conf
108
- sed -i " s;__AWS_REGION__;\" $AWS_REGION \" ;g" /etc/cfn/cfn-hup.conf
109
-
110
- mkdir -p /etc/cfn/hooks.d/
111
- mv /opt/cfn-hup/cfn-auto-reloader.conf /etc/cfn/hooks.d/cfn-auto-reloader.conf
112
- sed -i " s;__AWS_STACK_NAME__;\" $STACK_NAME \" ;g" /etc/cfn/hooks.d/cfn-auto-reloader.conf
113
- sed -i " s;__AWS_REGION__;\" $AWS_REGION \" ;g" /etc/cfn/hooks.d/cfn-auto-reloader.conf
114
-
115
- echo " Starting CloudFormation helper scripts as a service"
116
- mv /opt/cfn-hup/cfn-hup.service /etc/systemd/system/cfn-hup.service
65
+ # install python 3.11
66
+ sudo apt-get install python3.11 --yes
117
67
118
- systemctl daemon-reload
119
- systemctl enable --now cfn-hup
120
- systemctl start cfn-hup.service
68
+ sudo apt-get install python3.11-venv
69
+ sudo python3.11 -m venv env
70
+ source env/bin/activate
121
71
122
- cfn-signal --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
123
- fi
72
+ sudo apt-get install heat-cfntools --yes
124
73
74
+ cfn-init --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION --configsets setup
125
75
76
+ cfn-signal -e $? --stack $STACK_NAME --resource $RESOURCE_ID --region $AWS_REGION
126
77
127
78
echo " ----------------------------------------------"
128
79
echo " [user-data] Allora user-data script successful"
0 commit comments