forked from PagerDuty/pd-oncall-chat-topic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (36 loc) · 1.22 KB
/
Makefile
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
STACKNAME_BASE=asapp-pagerduty-oncall-chat-topic
REGION="us-east-1"
# Bucket in REGION that is used for deployment (`pd-oncall-chat-topic` is already used)
BUCKET=$(STACKNAME_BASE)
SSMKeyArn=$(shell aws kms --region $(REGION) describe-key --key-id alias/aws/ssm --query KeyMetadata.Arn)
MD5=$(shell md5sum lambda/*.py | md5sum | cut -d ' ' -f 1)
deploy:
-aws s3 mb \
s3://$(STACKNAME_BASE)
cd lambda && \
zip -r9 /tmp/deployment.zip *.py && \
aws s3 cp --region $(REGION) /tmp/deployment.zip \
s3://$(BUCKET)/$(MD5) && \
rm -rf /tmp/deployment.zip
aws cloudformation deploy \
--template-file deployment.yml \
--stack-name $(STACKNAME_BASE) \
--region $(REGION) \
--parameter-overrides \
"Bucket=$(BUCKET)" \
"md5=$(MD5)" \
"SSMKeyArn"=$(SSMKeyArn) \
"PDSSMKeyName"=$(STACKNAME_BASE) \
"SlackSSMKeyName"=$(STACKNAME_BASE)-slack \
--capabilities CAPABILITY_IAM || exit 0
discover:
aws cloudformation --region $(REGION) \
describe-stacks \
--stack-name $(STACKNAME_BASE) \
--query 'Stacks[0].Outputs'
put-pd-key:
./scripts/put-ssm.sh $(STACKNAME_BASE) $(STACKNAME_BASE) $(REGION)
put-slack-key:
./scripts/put-ssm.sh $(STACKNAME_BASE)-slack $(STACKNAME_BASE) $(REGION)
put-config:
./scripts/put-config.sh