Skip to content

Commit 98cf09c

Browse files
authored
Merge branch 'master' into patch-2
2 parents d6b0a25 + 5ba33e8 commit 98cf09c

23 files changed

+429
-124
lines changed

.buildkite/pipeline.yml

Lines changed: 106 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,63 @@ steps:
1616
run: unit-tests
1717
config: docker-compose.unit-tests.yml
1818

19+
- id: "s3secrets-helper-linux-amd64"
20+
name: ":golang: :linux: s3secrets-helper-linux-amd64"
21+
agents:
22+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
23+
plugins:
24+
docker#v3.7.0:
25+
image: "golang:1.15"
26+
mount-checkout: false
27+
volumes:
28+
- "./build:/build:rw"
29+
- "./plugins/secrets/s3secrets-helper:/s3secrets-helper:ro"
30+
workdir: /s3secrets-helper
31+
environment:
32+
- "GOOS=linux"
33+
- "GOARCH=amd64"
34+
command: ["go", "build", "-o", "/build/s3secrets-helper-linux-amd64"]
35+
artifact_paths:
36+
- build/s3secrets-helper-linux-amd64
37+
38+
- id: "s3secrets-helper-linux-arm64"
39+
name: ":golang: :linux: s3secrets-helper-linux-arm64"
40+
agents:
41+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
42+
plugins:
43+
docker#v3.7.0:
44+
image: "golang:1.15"
45+
mount-checkout: false
46+
volumes:
47+
- "./build:/build:rw"
48+
- "./plugins/secrets/s3secrets-helper:/s3secrets-helper:ro"
49+
workdir: /s3secrets-helper
50+
environment:
51+
- "GOOS=linux"
52+
- "GOARCH=arm64"
53+
command: ["go", "build", "-o", "/build/s3secrets-helper-linux-arm64"]
54+
artifact_paths:
55+
- build/s3secrets-helper-linux-arm64
56+
57+
- id: "s3secrets-helper-windows-amd64"
58+
name: ":golang: :windows: s3secrets-helper-windows-amd64.exe"
59+
agents:
60+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
61+
plugins:
62+
docker#v3.7.0:
63+
image: "golang:1.15"
64+
mount-checkout: false
65+
volumes:
66+
- "./build:/build:rw"
67+
- "./plugins/secrets/s3secrets-helper:/s3secrets-helper:ro"
68+
workdir: /s3secrets-helper
69+
environment:
70+
- "GOOS=windows"
71+
- "GOARCH=amd64"
72+
command: ["go", "build", "-o", "/build/s3secrets-helper-windows-amd64.exe"]
73+
artifact_paths:
74+
- build/s3secrets-helper-windows-amd64.exe
75+
1976
- id: "packer-windows"
2077
name: ":packer: :windows:"
2178
command: .buildkite/steps/packer.sh windows
@@ -26,26 +83,27 @@ steps:
2683
depends_on:
2784
- "lint"
2885
- "bats-tests"
86+
- "s3secrets-helper-windows-amd64"
2987

30-
- id: "windows-launch"
88+
- id: "launch-windows"
3189
name: ":cloudformation: :windows: Launch"
3290
command: .buildkite/steps/launch.sh windows
3391
agents:
3492
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
3593
artifact_paths: "build/aws-stack.yml"
3694
depends_on: "packer-windows"
3795

38-
- id: "windows-test"
96+
- id: "test-windows"
3997
name: ":cloudformation: :windows: Test"
4098
command: "docker info"
4199
timeout_in_minutes: 5
42100
agents:
43-
stack: "buildkite-aws-stack-test-windows-${BUILDKITE_BUILD_NUMBER}"
44-
queue: "testqueue-windows-${BUILDKITE_BUILD_NUMBER}"
45-
depends_on: "windows-launch"
101+
stack: "buildkite-aws-stack-test-windows-amd64-${BUILDKITE_BUILD_NUMBER}"
102+
queue: "testqueue-windows-amd64-${BUILDKITE_BUILD_NUMBER}"
103+
depends_on: "launch-windows"
46104

47-
- id: "packer-linux"
48-
name: ":packer: :linux:"
105+
- id: "packer-linux-amd64"
106+
name: ":packer: :linux: AMD64"
49107
command: .buildkite/steps/packer.sh linux
50108
timeout_in_minutes: 60
51109
retry: { automatic: { limit: 3 } }
@@ -54,23 +112,53 @@ steps:
54112
depends_on:
55113
- "lint"
56114
- "bats-tests"
115+
- "s3secrets-helper-linux-amd64"
57116

58-
- id: "linux-launch"
59-
name: ":cloudformation: :linux: Launch"
117+
- id: "launch-linux-amd64"
118+
name: ":cloudformation: :linux: AMD64 Launch"
60119
command: .buildkite/steps/launch.sh linux
61120
agents:
62121
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
63122
artifact_paths: "build/aws-stack.yml"
64-
depends_on: "packer-linux"
123+
depends_on: "packer-linux-amd64"
124+
125+
- id: "test-linux-amd64"
126+
name: ":cloudformation: :linux: AMD64 Test"
127+
command: "goss validate --format documentation"
128+
timeout_in_minutes: 5
129+
agents:
130+
stack: "buildkite-aws-stack-test-linux-amd64-${BUILDKITE_BUILD_NUMBER}"
131+
queue: "testqueue-linux-amd64-${BUILDKITE_BUILD_NUMBER}"
132+
depends_on: "launch-linux-amd64"
133+
134+
- id: "packer-linux-arm64"
135+
name: ":packer: :linux: ARM64"
136+
command: .buildkite/steps/packer.sh linux arm64
137+
timeout_in_minutes: 60
138+
retry: { automatic: { limit: 3 } }
139+
agents:
140+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
141+
depends_on:
142+
- "lint"
143+
- "bats-tests"
144+
- "s3secrets-helper-linux-arm64"
145+
146+
- id: "launch-linux-arm64"
147+
name: ":cloudformation: :linux: ARM64 Launch"
148+
command: .buildkite/steps/launch.sh linux arm64
149+
agents:
150+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
151+
artifact_paths: "build/aws-stack.yml"
152+
depends_on: "packer-linux-arm64"
65153

66-
- id: "linux-test"
67-
name: ":cloudformation: :linux: Test"
154+
- id: "test-linux-arm64"
155+
name: ":cloudformation: :linux: ARM64 Test"
68156
command: "goss validate --format documentation"
69157
timeout_in_minutes: 5
70158
agents:
71-
stack: "buildkite-aws-stack-test-linux-${BUILDKITE_BUILD_NUMBER}"
72-
queue: "testqueue-linux-${BUILDKITE_BUILD_NUMBER}"
73-
depends_on: "linux-launch"
159+
stack: "buildkite-aws-stack-test-linux-arm64-${BUILDKITE_BUILD_NUMBER}"
160+
queue: "testqueue-linux-arm64-${BUILDKITE_BUILD_NUMBER}"
161+
depends_on: "launch-linux-arm64"
74162

75163
- id: "copy-ami"
76164
name: ":cloudformation: 🚚 🌎"
@@ -79,8 +167,9 @@ steps:
79167
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE}"
80168
artifact_paths: "build/mappings.yml"
81169
depends_on:
82-
- "linux-test"
83-
- "windows-test"
170+
- "test-linux-amd64"
171+
- "test-linux-arm64"
172+
- "test-windows"
84173

85174
- id: "publish"
86175
name: ":cloudformation: :rocket:"

.buildkite/steps/cleanup.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ delete_test_stack() {
2525
}
2626

2727
if [[ -n "${BUILDKITE_BUILD_NUMBER:-}" ]] ; then
28-
delete_test_stack "windows"
29-
delete_test_stack "linux"
28+
delete_test_stack "windows-amd64"
29+
delete_test_stack "linux-amd64"
30+
delete_test_stack "linux-arm64"
3031
fi
3132

3233
if [[ $OSTYPE =~ ^darwin ]] ; then
@@ -44,15 +45,15 @@ aws s3api list-buckets \
4445
--output text \
4546
--query "$(printf 'Buckets[?CreationDate<`%s`].[Name]' "$cutoff_date" )" \
4647
| xargs -n1 \
47-
| grep -E 'buildkite-aws-stack-test-(\d+-)?managedsecrets' \
48+
| grep -E 'buildkite-aws-stack-test-.*-managedsecretsbucket' \
4849
| xargs -n1 -t -I% aws s3 rb s3://% --force
4950

5051
echo "--- Deleting old cloudformation stacks"
5152
aws cloudformation describe-stacks \
5253
--output text \
5354
--query "$(printf 'Stacks[?CreationTime<`%s`].[StackName]' "$cutoff_date" )" \
5455
| xargs -n1 \
55-
| grep -E 'buildkite-aws-stack-test-\d+' \
56+
| grep -E 'buildkite-aws-stack-test-(linux|windows)-(amd64|arm64)-[[:digit:]]+' \
5657
| xargs -n1 -t -I% aws cloudformation delete-stack --stack-name "%"
5758

5859
echo "--- Deleting old packer builders"

.buildkite/steps/copy.sh

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,18 @@ IMAGES=(
9191
)
9292

9393
# 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:-}"
9697

9798
source_region="${AWS_REGION}"
9899
mapping_file="build/mappings.yml"
99100

100101
# Read the source images from meta-data if no arguments are provided
101102
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")
104106
fi
105107

106108
# 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
110112
cat << EOF > "$mapping_file"
111113
Mappings:
112114
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 }
114116
EOF
115117
exit 0
116118
fi
117119

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" \
119121
"${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}" \
122125
"${BUILDKITE_BRANCH}")
123126

124127
# 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
128131
fi
129132

130133
# 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")
133137

134138
# Copy to all other regions
135139
for region in ${ALL_REGIONS[*]}; do
136140
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}")")
139143

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}")")
142149
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")
144151
fi
145152
done
146153

@@ -154,30 +161,39 @@ EOF
154161
echo "--- Waiting for AMIs to become available" >&2
155162

156163
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]}"
159167

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
161169

162170
# 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"
166182
fi
167183

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
169185

170186
# 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"
174190
fi
175191

176192
# 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"
178194

179195
# Shift off the processed images
180-
IMAGES=("${IMAGES[@]:2}")
196+
IMAGES=("${IMAGES[@]:3}")
181197
done
182198

183199
echo "--- Uploading mapping to s3 cache"

.buildkite/steps/launch.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
set -eu
33

44
os="${1:-linux}"
5-
stack_name="buildkite-aws-stack-test-${os}-${BUILDKITE_BUILD_NUMBER}"
6-
stack_queue_name="testqueue-${os}-${BUILDKITE_BUILD_NUMBER}"
5+
arch="${2:-amd64}"
6+
stack_name="buildkite-aws-stack-test-${os}-${arch}-${BUILDKITE_BUILD_NUMBER}"
7+
stack_queue_name="testqueue-${os}-${arch}-${BUILDKITE_BUILD_NUMBER}"
78

89
# download parfait binary
910
wget -N https://github.com/lox/parfait/releases/download/v1.1.3/parfait_linux_amd64
@@ -15,8 +16,8 @@ subnets=$(aws ec2 describe-subnets --filters "Name=vpc-id,Values=$vpc_id" --quer
1516
subnet_ids=$(awk '{print $1}' <<< "$subnets" | tr ' ' ',' | tr '\n' ',' | sed 's/,$//')
1617
az_ids=$(awk '{print $2}' <<< "$subnets" | tr ' ' ',' | tr '\n' ',' | sed 's/,$//')
1718

18-
image_id=$(buildkite-agent meta-data get "${os}_image_id")
19-
echo "Using AMI $image_id for $os"
19+
image_id=$(buildkite-agent meta-data get "${os}_${arch}_image_id")
20+
echo "Using AMI $image_id for $os/$arch"
2021

2122
instance_type="t3.nano"
2223
instance_disk="10"
@@ -26,6 +27,10 @@ if [[ "$os" == "windows" ]] ; then
2627
instance_disk="100"
2728
fi
2829

30+
if [[ "$arch" == "arm64" ]] ; then
31+
instance_type="m6g.large"
32+
fi
33+
2934
cat << EOF > config.json
3035
[
3136
{
@@ -88,7 +93,7 @@ cat << EOF > config.json
8893
EOF
8994

9095
echo "--- Building templates"
91-
make "mappings-for-${os}-image" build/aws-stack.yml "IMAGE_ID=$image_id"
96+
make "mappings-for-${os}-${arch}-image" build/aws-stack.yml "IMAGE_ID=$image_id"
9297

9398
echo "--- Validating templates"
9499
make validate

0 commit comments

Comments
 (0)