@@ -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,23 @@ 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
135
139
for region in ${ALL_REGIONS[*]} ; do
136
140
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} " ) " )
141
+ echo " --- :linux: Copying Linux AMD64 $linux_amd64_source_image_id to $region " >&2
142
+ IMAGES+=(" $( copy_ami_to_region " $linux_amd64_source_image_id " " $source_region " " $region " " ${linux_amd64_source_image_name } -${region} " ) " )
139
143
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} " ) " )
144
+ echo " --- :linux: Copying Linux ARM64 $linux_arm64_source_image_id to $region " >&2
145
+ IMAGES+=(" $( copy_ami_to_region " $linux_arm64_source_image_id " " $source_region " " $region " " ${linux_arm64_source_image_name} -${region} " ) " )
146
+
147
+ echo " --- :windows: Copying Windows AMD64 $windows_amd64_source_image_id to $region " >&2
148
+ IMAGES+=(" $( copy_ami_to_region " $windows_amd64_source_image_id " " $source_region " " $region " " ${windows_amd64_source_image_name} -${region} " ) " )
142
149
else
143
- IMAGES+=(" $linux_source_image_id " " $windows_source_image_id " )
150
+ IMAGES+=(" $linux_amd64_source_image_id " " $linux_arm64_source_image_id " " $windows_amd64_source_image_id " )
144
151
fi
145
152
done
146
153
@@ -154,30 +161,39 @@ EOF
154
161
echo " --- Waiting for AMIs to become available" >&2
155
162
156
163
for region in ${ALL_REGIONS[*]} ; do
157
- linux_image_id=" ${IMAGES[0]} "
158
- windows_image_id=" ${IMAGES[1]} "
164
+ linux_amd64_image_id=" ${IMAGES[0]} "
165
+ linux_arm64_image_id=" ${IMAGES[1]} "
166
+ windows_amd64_image_id=" ${IMAGES[2]} "
159
167
160
- wait_for_ami_to_be_available " $linux_image_id " " $region " >&2
168
+ wait_for_ami_to_be_available " $linux_amd64_image_id " " $region " >&2
161
169
162
170
# 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 "
171
+ if [[ $linux_amd64_image_id != " $linux_amd64_source_image_id " ]] ; then
172
+ echo " :linux: Making Linux AMD64 ${linux_amd64_image_id} public" >&2
173
+ make_ami_public " $linux_amd64_image_id " " $region "
174
+ fi
175
+
176
+ wait_for_ami_to_be_available " $linux_arm64_image_id " " $region " >&2
177
+
178
+ # Make the linux ARM AMI public if it's not the source image
179
+ if [[ $linux_arm64_image_id != " $linux_arm64_source_image_id " ]] ; then
180
+ echo " :linux: Making Linux ARM64 ${linux_arm64_image_id} public" >&2
181
+ make_ami_public " $linux_arm64_image_id " " $region "
166
182
fi
167
183
168
- wait_for_ami_to_be_available " $windows_image_id " " $region " >&2
184
+ wait_for_ami_to_be_available " $windows_amd64_image_id " " $region " >&2
169
185
170
186
# 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 "
187
+ if [[ $windows_amd64_image_id != " $windows_amd64_source_image_id " ]] ; then
188
+ echo " :windows: Making Windows AMD64 ${windows_amd64_image_id } public" >&2
189
+ make_ami_public " $windows_amd64_image_id " " $region "
174
190
fi
175
191
176
192
# Write yaml to file
177
- echo " $region : { linux : $linux_image_id , windows: $windows_image_id }" >> " $mapping_file "
193
+ echo " $region : { linuxamd64 : $linux_amd64_image_id , linuxarm64: $linux_arm64_image_id , windows: $windows_amd64_image_id }" >> " $mapping_file "
178
194
179
195
# Shift off the processed images
180
- IMAGES=(" ${IMAGES[@]: 2 } " )
196
+ IMAGES=(" ${IMAGES[@]: 3 } " )
181
197
done
182
198
183
199
echo " --- Uploading mapping to s3 cache"
0 commit comments