@@ -91,16 +91,18 @@ IMAGES=(
91
91
)
92
92
93
93
# Configuration
94
- linux_source_image_id=" ${1:- } "
95
- windows_source_image_id=" ${2:- } "
94
+ linux_amd64_source_image_id=" ${1:- } "
95
+ linux_arm64_source_image_id=" ${1:- } "
96
+ windows_amd64_source_image_id=" ${2:- } "
96
97
97
98
source_region=" ${AWS_REGION} "
98
99
mapping_file=" build/mappings.yml"
99
100
100
101
# Read the source images from meta-data if no arguments are provided
101
102
if [ $# -eq 0 ] ; then
102
- linux_source_image_id=$( buildkite-agent meta-data get " linux_image_id" )
103
- windows_source_image_id=$( buildkite-agent meta-data get " windows_image_id" )
103
+ linux_amd64_source_image_id=$( buildkite-agent meta-data get " linux_amd64_image_id" )
104
+ linux_arm64_source_image_id=$( buildkite-agent meta-data get " linux_arm64_image_id" )
105
+ windows_amd64_source_image_id=$( buildkite-agent meta-data get " windows_amd64_image_id" )
104
106
fi
105
107
106
108
# If we're not on the master branch or a tag build skip the copy
@@ -110,15 +112,16 @@ if [[ $BUILDKITE_BRANCH != "master" ]] && [[ "$BUILDKITE_TAG" != "$BUILDKITE_BRA
110
112
cat << EOF > "$mapping_file "
111
113
Mappings:
112
114
AWSRegion2AMI:
113
- ${AWS_REGION} : { linux : $linux_source_image_id , windows: $windows_source_image_id }
115
+ ${AWS_REGION} : { linuxamd64 : $linux_amd64_source_image_id , linuxarm64: $linux_arm64_source_image_id , windows: $windows_amd64_source_image_id }
114
116
EOF
115
117
exit 0
116
118
fi
117
119
118
- s3_mappings_cache=$( printf " s3://%s/mappings-%s-%s-%s.yml" \
120
+ s3_mappings_cache=$( printf " s3://%s/mappings-%s-%s-%s-%s .yml" \
119
121
" ${BUILDKITE_AWS_STACK_BUCKET} " \
120
- " ${linux_source_image_id} " \
121
- " ${windows_source_image_id} " \
122
+ " ${linux_amd64_source_image_id} " \
123
+ " ${linux_arm64_source_image_id} " \
124
+ " ${windows_amd64_source_image_id} " \
122
125
" ${BUILDKITE_BRANCH} " )
123
126
124
127
# Check if there is a previously copy in the cache bucket
@@ -128,19 +131,24 @@ if aws s3 cp "${s3_mappings_cache}" "$mapping_file" ; then
128
131
fi
129
132
130
133
# Get the image names to copy to other regions
131
- linux_source_image_name=$( get_image_name " $linux_source_image_id " " $source_region " )
132
- windows_source_image_name=$( get_image_name " $windows_source_image_id " " $source_region " )
134
+ linux_amd64_source_image_name=$( get_image_name " $linux_amd64_source_image_id " " $source_region " )
135
+ linux_arm64_source_image_name=$( get_image_name " $linux_arm64_source_image_id " " $source_region " )
136
+ windows_amd64_source_image_name=$( get_image_name " $windows_amd64_source_image_id " " $source_region " )
133
137
134
138
# Copy to all other regions
139
+ # shellcheck disable=SC2048
135
140
for region in ${ALL_REGIONS[*]} ; do
136
141
if [[ $region != " $source_region " ]] ; then
137
- echo " --- Copying :linux: $linux_source_image_id to $region " >&2
138
- IMAGES+=(" $( copy_ami_to_region " $linux_source_image_id " " $source_region " " $region " " ${linux_source_image_name } -${region} " ) " )
142
+ echo " --- :linux: Copying Linux AMD64 $linux_amd64_source_image_id to $region " >&2
143
+ IMAGES+=(" $( copy_ami_to_region " $linux_amd64_source_image_id " " $source_region " " $region " " ${linux_amd64_source_image_name } -${region} " ) " )
139
144
140
- echo " --- Copying :windows: $windows_source_image_id to $region " >&2
141
- IMAGES+=(" $( copy_ami_to_region " $windows_source_image_id " " $source_region " " $region " " ${windows_source_image_name} -${region} " ) " )
145
+ echo " --- :linux: Copying Linux ARM64 $linux_arm64_source_image_id to $region " >&2
146
+ IMAGES+=(" $( copy_ami_to_region " $linux_arm64_source_image_id " " $source_region " " $region " " ${linux_arm64_source_image_name} -${region} " ) " )
147
+
148
+ echo " --- :windows: Copying Windows AMD64 $windows_amd64_source_image_id to $region " >&2
149
+ IMAGES+=(" $( copy_ami_to_region " $windows_amd64_source_image_id " " $source_region " " $region " " ${windows_amd64_source_image_name} -${region} " ) " )
142
150
else
143
- IMAGES+=(" $linux_source_image_id " " $windows_source_image_id " )
151
+ IMAGES+=(" $linux_amd64_source_image_id " " $linux_arm64_source_image_id " " $windows_amd64_source_image_id " )
144
152
fi
145
153
done
146
154
@@ -152,32 +160,41 @@ Mappings:
152
160
EOF
153
161
154
162
echo " --- Waiting for AMIs to become available" >&2
155
-
163
+ # shellcheck disable=SC2048
156
164
for region in ${ALL_REGIONS[*]} ; do
157
- linux_image_id=" ${IMAGES[0]} "
158
- windows_image_id=" ${IMAGES[1]} "
165
+ linux_amd64_image_id=" ${IMAGES[0]} "
166
+ linux_arm64_image_id=" ${IMAGES[1]} "
167
+ windows_amd64_image_id=" ${IMAGES[2]} "
159
168
160
- wait_for_ami_to_be_available " $linux_image_id " " $region " >&2
169
+ wait_for_ami_to_be_available " $linux_amd64_image_id " " $region " >&2
161
170
162
171
# Make the linux AMI public if it's not the source image
163
- if [[ $linux_image_id != " $linux_source_image_id " ]] ; then
164
- echo " Making :linux: ${linux_image_id} public" >&2
165
- make_ami_public " $linux_image_id " " $region "
172
+ if [[ $linux_amd64_image_id != " $linux_amd64_source_image_id " ]] ; then
173
+ echo " :linux: Making Linux AMD64 ${linux_amd64_image_id} public" >&2
174
+ make_ami_public " $linux_amd64_image_id " " $region "
175
+ fi
176
+
177
+ wait_for_ami_to_be_available " $linux_arm64_image_id " " $region " >&2
178
+
179
+ # Make the linux ARM AMI public if it's not the source image
180
+ if [[ $linux_arm64_image_id != " $linux_arm64_source_image_id " ]] ; then
181
+ echo " :linux: Making Linux ARM64 ${linux_arm64_image_id} public" >&2
182
+ make_ami_public " $linux_arm64_image_id " " $region "
166
183
fi
167
184
168
- wait_for_ami_to_be_available " $windows_image_id " " $region " >&2
185
+ wait_for_ami_to_be_available " $windows_amd64_image_id " " $region " >&2
169
186
170
187
# Make the windows AMI public if it's not the source image
171
- if [[ $windows_image_id != " $windows_source_image_id " ]] ; then
172
- echo " Making :windows: ${windows_image_id } public" >&2
173
- make_ami_public " $windows_image_id " " $region "
188
+ if [[ $windows_amd64_image_id != " $windows_amd64_source_image_id " ]] ; then
189
+ echo " :windows: Making Windows AMD64 ${windows_amd64_image_id } public" >&2
190
+ make_ami_public " $windows_amd64_image_id " " $region "
174
191
fi
175
192
176
193
# Write yaml to file
177
- echo " $region : { linux : $linux_image_id , windows: $windows_image_id }" >> " $mapping_file "
194
+ echo " $region : { linuxamd64 : $linux_amd64_image_id , linuxarm64: $linux_arm64_image_id , windows: $windows_amd64_image_id }" >> " $mapping_file "
178
195
179
196
# Shift off the processed images
180
- IMAGES=(" ${IMAGES[@]: 2 } " )
197
+ IMAGES=(" ${IMAGES[@]: 3 } " )
181
198
done
182
199
183
200
echo " --- Uploading mapping to s3 cache"
0 commit comments