1
+ #! /bin/bash
2
+ #
3
+ # Publish a resource to all regions
4
+ #
5
+ # Run this from the resource folder
6
+
7
+ regions_to_publish=(us-east-1 af-south-1 ap-east-1 ap-northeast-1 ap-northeast-2 ap-northeast-3 ap-south-1 ap-southeast-1 ap-southeast-2 ap-southeast-3 ca-central-1 eu-central-1 eu-north-1 eu-south-1 eu-west-1 eu-west-2 eu-west-3 me-central-1 me-south-1 sa-east-1 us-east-2 us-west-1 us-west-2 eu-central-2 eu-south-2 ap-south-2)
8
+
9
+ # Use this to test succeed-fail locally
10
+ # regions_to_publish=(us-east-1 us-west-2 seattle)
11
+
12
+ successes=()
13
+ failures=()
14
+
15
+ cfn validate
16
+ cfn generate
17
+
18
+ # Create the package
19
+ echo " About to run cfn submit --dry-run to create the package"
20
+ echo " "
21
+ cfn submit --dry-run
22
+ echo " "
23
+
24
+ TYPE_NAME=$( cat .rpdk-config | jq -r .typeName)
25
+ TYPE_NAME_LOWER=" $( echo $TYPE_NAME | sed s/::/-/g | tr ' [:upper:]' ' [:lower:]' ) "
26
+ # For example, awscommunity-s3-deletebucketcontents
27
+ echo " TYPE_NAME_LOWER is $TYPE_NAME_LOWER "
28
+
29
+ ZIPFILE=" ${TYPE_NAME_LOWER} .zip"
30
+ echo " ZIPFILE is $ZIPFILE "
31
+
32
+ ACCOUNT_ID=$( aws sts get-caller-identity| jq -r .Account)
33
+ echo " ACCOUNT_ID is $ACCOUNT_ID "
34
+
35
+ HANDLER_BUCKET=" cep-handler-${ACCOUNT_ID} "
36
+
37
+ # We only need to copy the handler zip once, since it's not regional
38
+ # We use this bucket for logs also. The only drawback is if there are
39
+ # failures, it can be hard to sort out which log file belongs to which region.
40
+
41
+ echo " Copying schema package handler to $HANDLER_BUCKET "
42
+ aws s3 cp $ZIPFILE s3://$HANDLER_BUCKET /$ZIPFILE
43
+
44
+ for region in ${regions_to_publish[@]}
45
+ do
46
+ echo " About to start publishing to $region "
47
+
48
+ ../deregister-all.sh $region RESOURCE
49
+ ../publish-resource.sh $region
50
+
51
+ if [ " $? " -eq 0 ]
52
+ then
53
+ echo " Publishing to $region succeeded"
54
+ successes+=($region )
55
+ else
56
+ echo " Publishing to $region failed"
57
+ failures+=($region )
58
+ fi
59
+
60
+ done
61
+
62
+ echo " The following regions succeeded:"
63
+ for s in " ${successes[@]} "
64
+ do
65
+ echo $s
66
+ done
67
+
68
+ echo " The following regions failed:"
69
+ for f in " ${failures[@]} "
70
+ do
71
+ echo $f
72
+ done
0 commit comments