-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
30 lines (26 loc) · 1.12 KB
/
update.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
#!/bin/bash
# File containing subdomains
SUBDOMAIN_FILE="build_domains.txt"
TEMPLATE_FILE="cloudformation-s3-website-ssl-with-redirect.yaml"
ACM_CERTIFICATE_ARN="arn:aws:acm:us-east-1:YOURACCOUNT:certificate/YOURGUID"
HOSTED_ZONE_ID="ENTERYOURZONE"
REDIRECT_TARGET="ENTERYOURREDIRECT"
# Loop through subdomains and update stacks
while read -r SUBDOMAIN; do
STACK_NAME=$(echo "$SUBDOMAIN" | cut -d. -f1)
echo "Updating stack for subdomain: $SUBDOMAIN (stack name: $STACK_NAME)"
aws cloudformation update-stack --stack-name "$STACK_NAME" \
--template-body "file://$TEMPLATE_FILE" \
--parameters \
ParameterKey=BucketName,ParameterValue="$SUBDOMAIN" \
ParameterKey=RedirectTarget,ParameterValue="$REDIRECT_TARGET" \
ParameterKey=DomainName,ParameterValue="$SUBDOMAIN" \
ParameterKey=ACMCertificateARN,ParameterValue="$ACM_CERTIFICATE_ARN" \
ParameterKey=HostedZoneId,ParameterValue="$HOSTED_ZONE_ID" \
--capabilities CAPABILITY_NAMED_IAM
if [[ $? -eq 0 ]]; then
echo "Stack update initiated for $SUBDOMAIN"
else
echo "Failed to initiate stack update for $SUBDOMAIN"
fi
done < "$SUBDOMAIN_FILE"