summaryrefslogtreecommitdiff
path: root/tools/bin/deploy-stack.sh
blob: ef8f5ff3d398538f5e0492d59fc391b1238a961c (plain)
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
#!/usr/bin/env sh

set -ex

STACK_NAME=blog-kennyballou
REGION=us-east-1

function deploy() {
    aws cloudformation \
        --region ${REGION} \
        create-stack \
        --stack-name ${STACK_NAME} \
        --capabilities CAPABILITY_NAMED_IAM \
        --template-body file://$(pwd)/_build/${REGION}/stacks/blog.template
}

function undeploy() {
    aws cloudformation \
        --region ${REGION} \
        delete-stack \
        --stack-name ${STACK_NAME}
}

function changeset() {
    aws cloudformation \
        --region ${REGION} \
        create-change-set \
        --stack-name ${STACK_NAME} \
        --change-set-name ${STACK_NAME}-$(uuidgen) \
        --capabilities CAPABILITY_NAMED_IAM \
        --template-body file://$(pwd)/_build/${REGION}/stacks/blog.template
}

case $1 in
    deploy)
        deploy
        ;;
    changeset)
        changeset
        ;;
    undeploy)
        undeploy
        ;;
    *)
        echo "Available commands are DEPLOY | CHANGESET | UNDEPLOY";
        exit 1;
        ;;
esac