-
Notifications
You must be signed in to change notification settings - Fork 134
/
publish.sh
executable file
·1255 lines (1010 loc) · 49.4 KB
/
publish.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
set -xeuo pipefail
scripts=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd "${scripts}"
IMAGE_SHA_MATCHED="FALSE"
AWS_FOR_FLUENT_BIT_VERSION=$(cat ../AWS_FOR_FLUENT_BIT_VERSION)
AWS_FOR_FLUENT_BIT_STABLE_VERSION=$(cat ../AWS_FOR_FLUENT_BIT_STABLE_VERSION)
PUBLISH_LATEST=$(cat ../linux.version | jq -r '.linux.latest')
echo "Publish Latest? ${PUBLISH_LATEST}"
# Problem: when we push a new version bump the version number in AWS_FOR_FLUENT_BIT_VERSION file changes
# but that version is not published immediately. Thus, sync tasks normally
# sync latest version found in DockerHub. But what if we want to release a non-latest version?
# then sync tasks need to know this. So we use the script to check for an already published version
# that's not latest
# this code currenly works because DockerHub returns the only last 100 tags and as of March 2023 we only have 64
# and it should keep working because dockerhub returns the latest tags first
public_ecr_image_tags_token=$(curl -s -S -k https://public.ecr.aws/token/ | jq -r '.token')
public_ecr_image_tags=$(curl -s -S -k -H "Authorization: Bearer $public_ecr_image_tags_token" 'https://public.ecr.aws/v2/aws-observability/aws-for-fluent-bit/tags/list' | jq -r '.tags[]' | sort -rV)
tag_array=(`echo ${public_ecr_image_tags}`)
AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR=$(./get_latest_dockerhub_version.py linux latest ${tag_array[@]})
# If the AWS_FOR_FLUENT_BIT_VERSION is an older version which is already published to dockerhub
# and latest is set to false in linux.version, then we sync an older non-latest version.
# otherwise, normal behavior, sync latest version found in dockerhub
if [ "${PUBLISH_LATEST}" = "false" ]; then
PUBLISH_NON_LATEST=$(./get_latest_dockerhub_version.py linux ${AWS_FOR_FLUENT_BIT_VERSION} ${tag_array[@]})
if [ "${PUBLISH_NON_LATEST}" = "true" ]; then
AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR=${AWS_FOR_FLUENT_BIT_VERSION}
fi
fi
# Enforce STS regional endpoints
AWS_STS_REGIONAL_ENDPOINTS=regional
classic_regions="
us-east-1
eu-west-1
us-west-1
ap-southeast-1
ap-northeast-1
us-west-2
sa-east-1
ap-southeast-2
eu-central-1
ap-northeast-2
ap-south-1
us-east-2
ca-central-1
eu-west-2
eu-west-3
eu-north-1
ap-northeast-3
"
classic_regions_account_id="906394416424"
cn_regions="
cn-north-1
cn-northwest-1
"
cn_regions_account_id="128054284489"
gov_regions="
us-gov-east-1
us-gov-west-1
"
gov_regions_account_id="161423150738"
hongkong_region="ap-east-1"
hongkong_account_id="449074385750"
bahrain_region="me-south-1"
bahrain_account_id="741863432321"
cape_town_region="af-south-1"
cape_town_account_id="928143927712"
milan_region="eu-south-1"
milan_account_id="960320637246"
jakarta_region="ap-southeast-3"
jakarta_account_id="921575906885"
uae_region="me-central-1"
uae_account_id="358001906437"
spain_region="eu-south-2"
spain_account_id="146576467002"
zurich_region="eu-central-2"
zurich_account_id="269912160255"
hyderabad_region="ap-south-2"
hyderabad_account_id="378905956269"
tel_aviv_region="il-central-1"
tel_aviv_account_id="279248816148"
melbourne_region="ap-southeast-4"
melbourne_account_id="577945010369"
gamma_region="us-west-2"
gamma_account_id="626332813196"
DOCKER_HUB_SECRET="com.amazonaws.dockerhub.aws-for-fluent-bit.credentials"
ARCHITECTURES=("amd64" "arm64")
# This variable is used in the image tag
init="init"
docker_hub_login() {
username="$(aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region us-west-2 | jq -r '.SecretString | fromjson.username')"
password="$(aws secretsmanager get-secret-value --secret-id $DOCKER_HUB_SECRET --region us-west-2 | jq -r '.SecretString | fromjson.password')"
# Logout when the script exits
trap cleanup EXIT
cleanup() {
docker logout
}
# login to DockerHub
docker login -u "${username}" --password "${password}"
}
publish_to_docker_hub() {
export DOCKER_CLI_EXPERIMENTAL=enabled
docker_hub_login
if [ $# -eq 2 ]; then
# Get the image SHA's
docker pull ${1}:stable || echo "0"
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' ${1}:stable || echo "0")
docker pull ${1}:${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' ${1}:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})
match_two_sha $sha1 $sha2
if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
create_manifest_list ${1} "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi
else
for arch in "${ARCHITECTURES[@]}"
do
docker tag ${1}:"$arch" ${1}:"${arch}"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push ${1}:"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$arch"-"debug" ${1}:"${arch}"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push ${1}:"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$init"-"$arch" ${1}:"$init"-"${arch}"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push ${1}:"$init"-"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$init"-"$arch"-"debug" ${1}:"$init"-"${arch}"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push ${1}:"$init"-"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
done
create_manifest_list ${1} ${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list ${1} "debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${1} "$init"-${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${1} "$init"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
if [ "${PUBLISH_LATEST}" = "true" ]; then
create_manifest_list ${1} "latest" ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list ${1} "debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${1} "init-latest" ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${1} "init-debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
fi
fi
}
publish_to_public_ecr() {
if [ $# -eq 2 ]; then
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:stable || echo "0"
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:stable || echo "0")
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})
match_two_sha $sha1 $sha2
if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi
else
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
for arch in "${ARCHITECTURES[@]}"
do
docker tag ${1}:"$arch" public.ecr.aws/aws-observability/aws-for-fluent-bit:"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push public.ecr.aws/aws-observability/aws-for-fluent-bit:"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$arch"-"debug" public.ecr.aws/aws-observability/aws-for-fluent-bit:"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push public.ecr.aws/aws-observability/aws-for-fluent-bit:"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$init"-"$arch" public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
docker tag ${1}:"$init"-"$arch"-"debug" public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
docker push public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
done
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit "debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init public.ecr.aws/aws-observability/aws-for-fluent-bit "$init"-${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list_init public.ecr.aws/aws-observability/aws-for-fluent-bit "$init"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
if [ "${PUBLISH_LATEST}" = "true" ]; then
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit "latest" ${AWS_FOR_FLUENT_BIT_VERSION}
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list public.ecr.aws/aws-observability/aws-for-fluent-bit "debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init public.ecr.aws/aws-observability/aws-for-fluent-bit "init-latest" ${AWS_FOR_FLUENT_BIT_VERSION}
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability
create_manifest_list_init public.ecr.aws/aws-observability/aws-for-fluent-bit "init-debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
fi
fi
}
publish_ssm() {
# This optional parameter indicates if we should publish stable (defaults to false)
if [ ${4:-false} = true ]; then
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/stable --overwrite \
--description 'Regional Amazon ECR Image URI for the latest stable AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:${3}
else
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/${3} --overwrite \
--description 'Regional Amazon ECR Image URI for the latest AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:${3}
if [ "${PUBLISH_LATEST}" = "true" ]; then
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/latest --overwrite \
--description 'Regional Amazon ECR Image URI for the latest AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:latest
fi
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/"$init"-${3} --overwrite \
--description 'Regional Amazon ECR Image URI for the "$init"-latest AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:"$init"-${3}
if [ "${PUBLISH_LATEST}" = "true" ]; then
aws ssm put-parameter --name /aws/service/aws-for-fluent-bit/"$init"-latest --overwrite \
--description 'Regional Amazon ECR Image URI for the "$init"-latest AWS for Fluent Bit Docker Image' \
--type String --region ${1} --value ${2}:"$init"-latest
fi
fi
}
rollback_ssm() {
aws ssm delete-parameter --name /aws/service/aws-for-fluent-bit/${AWS_FOR_FLUENT_BIT_VERSION} --region ${1}
aws ssm delete-parameter --name /aws/service/aws-for-fluent-bit/"$init"-${AWS_FOR_FLUENT_BIT_VERSION} --region ${1}
}
check_parameter() {
repo_uri=$(aws ssm get-parameter --name /aws/service/aws-for-fluent-bit/${2} --region ${1} --query 'Parameter.Value')
IFS='.' read -r -a array <<<"$repo_uri"
region="${array[3]}"
if [ "${1}" != "${region}" ]; then
echo "${1}: Region found in repo URI does not match SSM Parameter region: ${repo_uri}"
exit 1
fi
# remove leading and trailing quotes from repo_uri
repo_uri=$(sed -e 's/^"//' -e 's/"$//' <<<"$repo_uri")
docker pull $repo_uri
if [ "${2}" != "stable" ]; then
repo_uri_init=$(aws ssm get-parameter --name /aws/service/aws-for-fluent-bit/"$init"-${2} --region ${1} --query 'Parameter.Value')
IFS='.' read -r -a array <<<"$repo_uri_init"
region="${array[3]}"
if [ "${1}" != "${region}" ]; then
echo "${1}: Region found in repo URI does not match SSM Parameter region: ${repo_uri}"
exit 1
fi
# remove leading and trailing quotes from repo_uri
repo_uri_init=$(sed -e 's/^"//' -e 's/"$//' <<<"$repo_uri")
docker pull $repo_uri_init
fi
}
sync_public_and_repo() {
region=${1}
account_id=${2}
endpoint=${3}
tag=${4}
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:${tag}
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${tag})
aws ecr get-login-password --region ${region}| docker login --username AWS --password-stdin ${account_id}.dkr.ecr.${region}.${endpoint}
repoList=$(aws ecr describe-repositories --region ${region})
repoName=$(echo $repoList | jq .repositories[0].repositoryName)
if [ "$repoName" = '"aws-for-fluent-bit"' ]; then
tagCount=$(aws ecr list-images --repository-name aws-for-fluent-bit --region ${region} | jq -r '.imageIds[].imageTag' | grep -c ${tag} || echo "0")
if [ "$tagCount" = '1' ]; then
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${tag}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${tag})
else
sha2='repo_not_found'
fi
else
sha2='repo_not_found'
fi
match_two_sha $sha1 $sha2
if [ "$IMAGE_SHA_MATCHED" = "FALSE" ]; then
aws ecr create-repository --repository-name aws-for-fluent-bit --image-scanning-configuration scanOnPush=true --region ${region} || true
push_image_ecr public.ecr.aws/aws-observability/aws-for-fluent-bit:${tag} \
${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${tag}
fi
}
sync_ssm() {
namespace_path=${1}
region=${2}
repo=${3}
tag=${4}
# Check the namespace_path looking for stable at the end, if the string were too short it would return an empty string
is_stable=false
if [ "${namespace_path:(-6)}" = "stable" ]; then
is_stable=true
fi
invalid_parameter=
should_prepare=false
# Check to see if namespace is prepared, once a parameter is put into namespace requests should not fail
if ! ssm_parameters=$(aws ssm get-parameters --names ${namespace_path} --region ${region}); then
should_prepare=true
else
invalid_parameter=$(echo $ssm_parameters | jq .InvalidParameters[0])
fi
if [ $should_prepare = true ] || [ "$invalid_parameter" != 'null' ]; then
publish_ssm ${region} ${repo} ${tag} ${is_stable}
fi
}
sync_image_version() {
region=${1}
account_id=${2}
endpoint='amazonaws.com'
if [ "${1}" = "cn-north-1" ] || [ "${1}" = "cn-northwest-1" ]; then
endpoint=${endpoint}.cn
fi
for arch in "${ARCHITECTURES[@]}"
do
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability || echo "0"
sync_public_and_repo ${region} ${account_id} ${endpoint} "${arch}-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}"
sync_public_and_repo ${region} ${account_id} ${endpoint} "${arch}-debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}"
sync_public_and_repo ${region} ${account_id} ${endpoint} "${init}-${arch}-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}"
sync_public_and_repo ${region} ${account_id} ${endpoint} "${init}-${arch}-debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}"
sync_public_and_repo ${region} ${account_id} ${endpoint} "${arch}-${AWS_FOR_FLUENT_BIT_STABLE_VERSION}"
done
if [ "${account_id}" != "${classic_regions_account_id}" ]; then
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR} ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "debug"-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR} debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "$init"-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR} ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "$init"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR} debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
if [ "${PUBLISH_LATEST}" = "true" ]; then
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "latest" ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "init-latest" ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "init-debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
fi
if [ "${AWS_FOR_FLUENT_BIT_STABLE_VERSION}" != "${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}" ]; then
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_STABLE_VERSION} ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
fi
create_manifest_list ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit "stable" ${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0"
make_repo_public ${region}
sync_ssm "/aws/service/aws-for-fluent-bit/${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}" ${region} ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
sync_ssm "/aws/service/aws-for-fluent-bit/stable" ${region} ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
stable_uri=$(aws ssm get-parameters --names /aws/service/aws-for-fluent-bit/stable --region ${region} --query 'Parameters[0].Value')
stable_uri=$(sed -e 's/^"//' -e 's/"$//' <<<"$stable_uri")
if [ "$stable_uri" != "${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION}" ]; then
publish_ssm ${region} ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_STABLE_VERSION} true
fi
}
verify_ssm() {
is_sync_task=${2:-false}
endpoint='amazonaws.com'
if [ "${1}" = "cn-north-1" ] || [ "${1}" = "cn-northwest-1" ]; then
endpoint=${endpoint}.cn
fi
aws ecr get-login-password --region ${1} | docker login --username AWS --password-stdin ${3}.dkr.ecr.${1}.${endpoint}
if [ "${PUBLISH_LATEST}" = "true" ]; then
check_parameter ${1} latest
fi
if [ "${is_sync_task}" = "true" ]; then
check_parameter ${1} ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
check_parameter ${1} stable
else
check_parameter ${1} ${AWS_FOR_FLUENT_BIT_VERSION}
fi
}
create_manifest_list() {
export DOCKER_CLI_EXPERIMENTAL=enabled
tag=${2}
version=${3}
# TODO: Add a way to automatically generate arch images in manifest
docker manifest create ${1}:${tag} ${1}:arm64-${version} ${1}:amd64-${version}
for arch in "${ARCHITECTURES[@]}"
do
docker manifest annotate --arch "$arch" ${1}:${tag} ${1}:"$arch"-${version}
done
# sanity check on the debug log.
docker manifest inspect ${1}:${tag}
docker manifest push ${1}:${tag}
}
create_manifest_list_init() {
export DOCKER_CLI_EXPERIMENTAL=enabled
tag=${2}
version=${3}
# TODO: Add a way to automatically generate arch images in manifest
docker manifest create ${1}:${tag} ${1}:"$init"-arm64-${version} ${1}:"$init"-amd64-${version}
for arch in "${ARCHITECTURES[@]}"
do
docker manifest annotate --arch "$arch" ${1}:${tag} ${1}:"$init"-"$arch"-${version}
done
# sanity check on the debug log.
docker manifest inspect ${1}:${tag}
docker manifest push ${1}:${tag}
}
push_image_ecr() {
docker tag ${1} ${2}
docker push ${2}
}
make_repo_public() {
aws ecr set-repository-policy --repository-name aws-for-fluent-bit --policy-text file://public_repo_policy.json --region ${1}
}
publish_ecr() {
region=${1}
account_id=${2}
aws ecr get-login-password --region ${region}| docker login --username AWS --password-stdin ${account_id}.dkr.ecr.${region}.amazonaws.com
aws ecr create-repository --repository-name aws-for-fluent-bit --image-scanning-configuration scanOnPush=true --region ${region} || true
for arch in "${ARCHITECTURES[@]}"
do
push_image_ecr ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:"$arch" \
${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit:"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
push_image_ecr ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:"$arch"-"debug" \
${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit:"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
push_image_ecr ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:"$init"-"$arch" \
${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit:"$init"-"$arch"-${AWS_FOR_FLUENT_BIT_VERSION}
push_image_ecr ${AWS_ACCOUNT}.dkr.ecr.${AWS_REGION}.amazonaws.com/amazon/aws-for-fluent-bit-test:"$init"-"$arch"-"debug" \
${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit:"$init"-"$arch"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION}
done
create_manifest_list ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "$init"-${AWS_FOR_FLUENT_BIT_VERSION} ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "$init"-"debug"-${AWS_FOR_FLUENT_BIT_VERSION} debug-${AWS_FOR_FLUENT_BIT_VERSION}
if [ "${PUBLISH_LATEST}" = "true" ]; then
create_manifest_list ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "latest" ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "init-latest" ${AWS_FOR_FLUENT_BIT_VERSION}
create_manifest_list_init ${account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit "init-debug-latest" debug-${AWS_FOR_FLUENT_BIT_VERSION}
fi
make_repo_public ${region}
}
verify_ecr() {
region=${1}
account_id=${2}
is_sync_task=${3:-false}
endpoint='amazonaws.com'
if [ "${1}" = "cn-north-1" ] || [ "${1}" = "cn-northwest-1" ]; then
endpoint=${endpoint}.cn
fi
aws ecr get-login-password --region ${region} | docker login --username AWS --password-stdin ${account_id}.dkr.ecr.${region}.${endpoint}
if [ "${is_sync_task}" = "true" ]; then
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:stable || echo "0"
stableSha1=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:stable || echo "0")
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0"
stableSha2=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION} || echo "0")
verify_sha $stableSha1 $stableSha2
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR})
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR})
# verify version number tag against public ECR
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR})
verify_sha $sha1 $sha2
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:init-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:init-${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR})
verify_sha $sha1_init $sha2_init
else
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION}
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION})
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION}
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION})
fi
# in main pipeline when publishing a non-latest release
# we can't verify the SHA against any other tag
# only verification is the above steps to pull the image
if [ "${PUBLISH_LATEST}" = "true" ]; then
# Also validate version number tag against latest tag
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:latest
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:latest)
verify_sha $sha1 $sha2
docker pull ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-latest
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' ${account_id}.dkr.ecr.${region}.${endpoint}/aws-for-fluent-bit:"$init"-latest)
verify_sha $sha1_init $sha2_init
fi
}
check_image_version() {
export DOCKER_CLI_EXPERIMENTAL=enabled
EXIT_CODE=0
docker_hub_login
# check if we can get the image information in dockerhub; if yes, the exit status should be 0
docker manifest inspect public.ecr.aws/aws-observability/aws-for-fluent-bit:${1} > /dev/null || EXIT_CODE=$?
if [ "${EXIT_CODE}" = "0" ]; then
echo "Accidental release: current image version from github source file match a previous version from dockerhub."
exit 1
fi
echo "Approved release: release the image with a new version."
}
verify_ecr_image_scan() {
region=${1}
repo_uri=${2}
tag=${3}
tagCount=$(aws ecr list-images --repository-name ${repo_uri} --region ${region} | jq -r '.imageIds[].imageTag' | grep -c ${tag} || echo "0")
if [ "$tagCount" = '1' ]; then
aws ecr start-image-scan --repository-name ${repo_uri} --image-id imageTag=${tag} --region ${region}
aws ecr wait image-scan-complete --repository-name ${repo_uri} --region ${region} --image-id imageTag=${tag}
highVulnerabilityCount=$(aws ecr describe-image-scan-findings --repository-name ${repo_uri} --region ${region} --image-id imageTag=${tag} | jq '.imageScanFindings.findingSeverityCounts.HIGH')
criticalVulnerabilityCount=$(aws ecr describe-image-scan-findings --repository-name ${repo_uri} --region ${region} --image-id imageTag=${tag} | jq '.imageScanFindings.findingSeverityCounts.CRITICAL')
if [ "$highVulnerabilityCount" != null ] || [ "$criticalVulnerabilityCount" != null ]; then
echo "Uploaded image ${tag} has ${vulnerabilityCount} vulnerabilities."
exit 1
fi
fi
}
verify_dockerhub() {
docker_hub_login
# Verify the image with stable tag
if [ $# -eq 1 ] || [ "${PUBLISH_LATEST}" = "false" ]; then
# Get the image SHA's
docker pull amazon/aws-for-fluent-bit:stable
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:stable)
docker pull amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})
verify_sha $sha1 $sha2
else
# Get the image SHA's
docker pull amazon/aws-for-fluent-bit:latest
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:latest)
docker pull amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION})
verify_sha $sha1 $sha2
docker pull amazon/aws-for-fluent-bit:"$init"-latest
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:"$init"-latest)
docker pull amazon/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' amazon/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION})
verify_sha $sha1_init $sha2_init
fi
}
verify_public_ecr() {
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/aws-observability || echo "0"
# Verify the image with stable tag
if [ $# -eq 1 ] || [ "${PUBLISH_LATEST}" = "false" ]; then
# Get the image SHA's
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:stable
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:stable)
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_STABLE_VERSION})
verify_sha $sha1 $sha2
else
# Get the image SHA's
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:latest
sha1=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:latest)
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION}
sha2=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION})
verify_sha $sha1 $sha2
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-latest
sha1_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-latest)
docker pull public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION}
sha2_init=$(docker inspect --format='{{index .RepoDigests 0}}' public.ecr.aws/aws-observability/aws-for-fluent-bit:"$init"-${AWS_FOR_FLUENT_BIT_VERSION})
verify_sha $sha1_init $sha2_init
fi
}
verify_sha() {
_sha1=${1}
_sha2=${2}
match_two_sha $_sha1 $_sha2
if [ "$IMAGE_SHA_MATCHED" = "TRUE" ]; then
echo '[Publish Verification] Successfull'
IMAGE_SHA_MATCHED="FALSE"
else
echo '[Publish Verification] Failed'
exit 1
fi
}
match_two_sha() {
_sha1=${1}
_sha2=${2}
# Get the last 64 chars of the SHA string
last64_1=$(echo $_sha1 | egrep -o '.{1,64}$')
last64_2=$(echo $_sha2 | egrep -o '.{1,64}$')
if [ "$last64_1" = "$last64_2" ]; then
IMAGE_SHA_MATCHED="TRUE"
else
IMAGE_SHA_MATCHED="FALSE"
fi
}
if [ "${1}" = "publish" ]; then
if [ "${2}" = "dockerhub" ]; then
publish_to_docker_hub amazon/aws-for-fluent-bit
fi
if [ "${2}" = "aws" ]; then
for region in ${classic_regions}; do
publish_ecr ${region} ${classic_regions_account_id}
done
fi
if [ "${2}" = "aws-cn" ]; then
for region in ${cn_regions}; do
publish_ecr ${region} ${cn_regions_account_id}
done
fi
if [ "${2}" = "aws-us-gov" ]; then
for region in ${gov_regions}; do
publish_ecr ${region} ${gov_regions_account_id}
done
fi
if [ "${2}" = "${hongkong_region}" ]; then
publish_ecr ${hongkong_region} ${hongkong_account_id}
fi
if [ "${2}" = "${bahrain_region}" ]; then
publish_ecr ${bahrain_region} ${bahrain_account_id}
fi
if [ "${2}" = "${cape_town_region}" ]; then
publish_ecr ${cape_town_region} ${cape_town_account_id}
fi
if [ "${2}" = "${milan_region}" ]; then
publish_ecr ${milan_region} ${milan_account_id}
fi
if [ "${2}" = "${jakarta_region}" ]; then
publish_ecr ${jakarta_region} ${jakarta_account_id}
fi
if [ "${2}" = "${uae_region}" ]; then
publish_ecr ${uae_region} ${uae_account_id}
fi
if [ "${2}" = "${spain_region}" ]; then
publish_ecr ${spain_region} ${spain_account_id}
fi
if [ "${2}" = "${zurich_region}" ]; then
publish_ecr ${zurich_region} ${zurich_account_id}
fi
if [ "${2}" = "${hyderabad_region}" ]; then
publish_ecr ${hyderabad_region} ${hyderabad_account_id}
fi
if [ "${2}" = "${tel_aviv_region}" ]; then
publish_ecr ${tel_aviv_region} ${tel_aviv_account_id}
fi
if [ "${2}" = "${melbourne_region}" ]; then
publish_ecr ${melbourne_region} ${melbourne_account_id}
fi
if [ "${2}" = "gamma" ]; then
publish_ecr ${gamma_region} ${gamma_account_id}
fi
fi
if [ "${1}" = "verify" ]; then
if [ "${2}" = "dockerhub" ]; then
docker pull amazon/aws-for-fluent-bit:latest
docker pull amazon/aws-for-fluent-bit:${AWS_FOR_FLUENT_BIT_VERSION}
fi
if [ "${2}" = "aws" ]; then
for region in ${classic_regions}; do
verify_ecr ${region} ${classic_regions_account_id}
done
fi
if [ "${2}" = "aws-cn" ]; then
for region in ${cn_regions}; do
verify_ecr ${region} ${cn_regions_account_id}
done
fi
if [ "${2}" = "aws-us-gov" ]; then
for region in ${gov_regions}; do
verify_ecr ${region} ${gov_regions_account_id}
done
fi
if [ "${2}" = "${hongkong_region}" ]; then
verify_ecr ${hongkong_region} ${hongkong_account_id}
fi
if [ "${2}" = "${bahrain_region}" ]; then
verify_ecr ${bahrain_region} ${bahrain_account_id}
fi
if [ "${2}" = "${cape_town_region}" ]; then
verify_ecr ${cape_town_region} ${cape_town_account_id}
fi
if [ "${2}" = "${milan_region}" ]; then
verify_ecr ${milan_region} ${milan_account_id}
fi
if [ "${2}" = "${jakarta_region}" ]; then
verify_ecr ${jakarta_region} ${jakarta_account_id}
fi
if [ "${2}" = "${uae_region}" ]; then
verify_ecr ${uae_region} ${uae_account_id}
fi
if [ "${2}" = "${spain_region}" ]; then
verify_ecr ${spain_region} ${spain_account_id}
fi
if [ "${2}" = "${zurich_region}" ]; then
verify_ecr ${zurich_region} ${zurich_account_id}
fi
if [ "${2}" = "${hyderabad_region}" ]; then
verify_ecr ${hyderabad_region} ${hyderabad_account_id}
fi
if [ "${2}" = "${tel_aviv_region}" ]; then
verify_ecr ${tel_aviv_region} ${tel_aviv_account_id}
fi
if [ "${2}" = "${melbourne_region}" ]; then
verify_ecr ${melbourne_region} ${melbourne_account_id}
fi
if [ "${2}" = "gamma" ]; then
verify_ecr ${gamma_region} ${gamma_account_id}
fi
fi
if [ "${1}" = "publish-ssm" ]; then
if [ "${2}" = "aws" ]; then
for region in ${classic_regions}; do
publish_ssm ${region} ${classic_regions_account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION}
done
fi
if [ "${2}" = "aws-cn" ]; then
for region in ${cn_regions}; do
publish_ssm ${region} ${cn_regions_account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
done
fi
if [ "${2}" = "aws-us-gov" ]; then
for region in ${gov_regions}; do
publish_ssm ${region} ${gov_regions_account_id}.dkr.ecr.${region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
done
fi
if [ "${2}" = "${hongkong_region}" ]; then
publish_ssm ${hongkong_region} ${hongkong_account_id}.dkr.ecr.${hongkong_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${bahrain_region}" ]; then
publish_ssm ${bahrain_region} ${bahrain_account_id}.dkr.ecr.${bahrain_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${cape_town_region}" ]; then
publish_ssm ${cape_town_region} ${cape_town_account_id}.dkr.ecr.${cape_town_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${milan_region}" ]; then
publish_ssm ${milan_region} ${milan_account_id}.dkr.ecr.${milan_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${jakarta_region}" ]; then
publish_ssm ${jakarta_region} ${jakarta_account_id}.dkr.ecr.${jakarta_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${uae_region}" ]; then
publish_ssm ${uae_region} ${uae_account_id}.dkr.ecr.${uae_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${spain_region}" ]; then
publish_ssm ${spain_region} ${spain_account_id}.dkr.ecr.${spain_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${zurich_region}" ]; then
publish_ssm ${zurich_region} ${zurich_account_id}.dkr.ecr.${zurich_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${hyderabad_region}" ]; then
publish_ssm ${hyderabad_region} ${hyderabad_account_id}.dkr.ecr.${hyderabad_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${tel_aviv_region}" ]; then
publish_ssm ${tel_aviv_region} ${tel_aviv_account_id}.dkr.ecr.${tel_aviv_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
if [ "${2}" = "${melbourne_region}" ]; then
publish_ssm ${melbourne_region} ${melbourne_account_id}.dkr.ecr.${melbourne_region}.amazonaws.com/aws-for-fluent-bit ${AWS_FOR_FLUENT_BIT_VERSION_PUBLIC_ECR}
fi
fi
if [ "${1}" = "verify-ssm" ]; then
if [ "${2}" = "aws" ]; then
for region in ${classic_regions}; do
verify_ssm ${region} false ${classic_regions_account_id}
done
fi
if [ "${2}" = "aws-cn" ]; then
for region in ${cn_regions}; do
verify_ssm ${region} false ${cn_regions_account_id}
done
fi
if [ "${2}" = "aws-us-gov" ]; then
for region in ${gov_regions}; do
verify_ssm ${region} false ${gov_regions_account_id}
done
fi
if [ "${2}" = "${hongkong_region}" ]; then
verify_ssm ${hongkong_region} false ${hongkong_account_id}
fi
if [ "${2}" = "${bahrain_region}" ]; then
verify_ssm ${bahrain_region} false ${bahrain_account_id}
fi
if [ "${2}" = "${cape_town_region}" ]; then
verify_ssm ${cape_town_region} false ${cape_town_account_id}
fi
if [ "${2}" = "${milan_region}" ]; then
verify_ssm ${milan_region} false ${milan_account_id}
fi
if [ "${2}" = "${jakarta_region}" ]; then
verify_ssm ${jakarta_region} false ${jakarta_account_id}
fi
if [ "${2}" = "${uae_region}" ]; then
verify_ssm ${uae_region} false ${uae_account_id}
fi
if [ "${2}" = "${spain_region}" ]; then
verify_ssm ${spain_region} false ${spain_account_id}
fi
if [ "${2}" = "${zurich_region}" ]; then
verify_ssm ${zurich_region} false ${zurich_account_id}
fi
if [ "${2}" = "${hyderabad_region}" ]; then
verify_ssm ${hyderabad_region} false ${hyderabad_account_id}
fi
if [ "${2}" = "${tel_aviv_region}" ]; then
verify_ssm ${tel_aviv_region} false ${tel_aviv_account_id}
fi
if [ "${2}" = "${melbourne_region}" ]; then
verify_ssm ${melbourne_region} false ${melbourne_account_id}
fi
fi
if [ "${1}" = "rollback-ssm" ]; then
if [ "${2}" = "aws" ]; then