-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·38 lines (31 loc) · 1.14 KB
/
deploy.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.14 KB
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
#!/usr/bin/env bash
cd "$(dirname "${BASH_SOURCE[0]}")/infrastructure"
set -eu
stack_name=${1:-${STACK_NAME:-}}
if ! [[ $stack_name ]]; then
[[ $(aws sts get-caller-identity --query Arn --output text) =~ \/([^\/\.]+)\. ]] && user=${BASH_REMATCH[1]} || exit
stack_name="$user-otg-hmrc"
echo "» Using stack name '$stack_name'"
fi
export AWS_DEFAULT_REGION=${AWS_REGION:-eu-west-2}
sam validate -t template.yaml
sam validate -t template.yaml --lint
sam build -t template.yaml --cached --parallel
if status=$(aws cloudformation describe-stacks --stack-name "$stack_name" \
--query "Stacks[0].StackStatus" --output text 2> /dev/null) && [[ $status =~ _FAILED ]]; then
echo "» Deleting stack $stack_name in a failed state"
sam delete --no-prompts --stack-name "$stack_name"
fi
sam deploy --stack-name "$stack_name" \
--no-fail-on-empty-changeset \
--no-confirm-changeset \
--resolve-s3 \
--s3-prefix "$stack_name" \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--tags \
cri:component=ipv-cri-otg-hmrc \
cri:stack-type=dev \
cri:application=Orange \
cri:deployment-source=manual \
--parameter-overrides \
Environment=dev