-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy
executable file
·111 lines (99 loc) · 4.26 KB
/
deploy
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
#!/bin/bash
#
# This is based on the deploy script in
#
# https://github.com/awslabs/ecs-refarch-continuous-deployment
#
# Creates a subdirectory bucket for the landscape
#
# deploy profile bucket lanscape
# example ./deploy w2c-non-prod buaws-web2cloud-nonprod test
# NOTE MAY NEED TO RUN TWICE! (because of lag in create bucket)
set -o errexit -o xtrace
#region="us-east-1"
#bucket=ecs-refarch-continuous-deployment-v2
regions=(
# ap-northeast-1
# ap-southeast-1
# ap-southeast-2
# ca-central-1
# eu-central-1
# eu-west-1
# eu-west-2
us-east-1
# us-east-2
# us-west-1
us-west-2
#ws-waf-security-automations us-west-2
)
aws="aws"
if [ "x$1" = "x-d" ]; then
aws="echo $aws"
shift
fi
profile="$1"
shift
bucket="$1"
shift
#landscape="$1"
#shift
path="templates"
if [ "x$1" != "x" ]; then
path="$1"
fi
if [ "x$profile" != "x-" ]; then
aws="$aws --profile $profile"
fi
for region in "${regions[@]}"
do
$aws s3api head-bucket --bucket "${bucket}-${region}" --region "$region" ||
$aws s3 mb "s3://${bucket}-${region}" --region "$region"
$aws s3api put-bucket-policy \
--bucket "${bucket}-${region}" \
--policy "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":[\"s3:GetObject\",\"s3:GetObjectVersion\"],\"Resource\":\"arn:aws:s3:::${bucket}-${region}/*\"},{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":[\"s3:ListBucket\",\"s3:GetBucketVersioning\"],\"Resource\":\"arn:aws:s3:::${bucket}-${region}\"}]}" \
--region "$region"
$aws s3api put-bucket-versioning \
--bucket "${bucket}-${region}" \
--versioning-configuration Status=Enabled \
--region "$region"
# $aws s3 cp ecs-refarch-continuous-deployment.yaml "s3://${bucket}-${region}" \
# --region "$region"
$aws s3 cp --recursive templates/ "s3://${bucket}-${region}/$path" \
--region "$region"
done
exit
#bucket=ecs-refarch-continuous-deployment-v2
#regions=(
# ap-northeast-1
# ap-southeast-1
# ap-southeast-2
# ca-central-1
# eu-central-1
# eu-west-1
# eu-west-2
# us-east-1
# us-east-2
# us-west-1
#ws-waf-security-automations us-west-2
#)
#for region in "${regions[@]}"
#do
# aws s3api head-bucket --bucket "${bucket}-${region}" --region "$region" ||
# aws s3 mb "s3://${bucket}-${region}" --region "$region"
#
# aws s3api put-bucket-policy \
# --bucket "${bucket}-${region}" \
# --policy "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":[\"s3:GetObject\",\"s3:GetObjectVersion\"],\"Resource\":\"arn:aws:s3:::${bucket}-${region}/*\"},{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":[\"s3:ListBucket\",\"s3:GetBucketVersioning\"],\"Resource\":\"arn:aws:s3:::${bucket}-${region}\"}]}" \
# --region "$region"
#
# aws s3api put-bucket-versioning \
# --bucket "${bucket}-${region}" \
# --versioning-configuration Status=Enabled \
# --region "$region"
#
# aws s3 cp ecs-refarch-continuous-deployment.yaml "s3://${bucket}-${region}" \
# --region "$region"
#
# aws s3 cp --recursive templates/ "s3://${bucket}-${region}/templates" \
# --region "$region"
#done