-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
34 lines (30 loc) · 1.74 KB
/
Makefile
File metadata and controls
34 lines (30 loc) · 1.74 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
CF_PROFILE := armcknight
CF_DISTRIBUTION := E3GUZCB8D2ZU0V
CF_FUNCTION := tworingsoft-com-redirect-to-mcknight-io
.PHONY: init
init:
which brew || /bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew bundle ||:
.PHONY: deploy
deploy:
$(eval ETAG := $(shell aws --profile $(CF_PROFILE) cloudfront describe-function --name $(CF_FUNCTION) --stage DEVELOPMENT --query 'ETag' --output text))
aws --profile $(CF_PROFILE) cloudfront update-function \
--name $(CF_FUNCTION) \
--if-match $(ETAG) \
--function-config '{"Comment":"301 redirect tworingsoft.com to mcknight.io preserving path+query","Runtime":"cloudfront-js-2.0"}' \
--function-code fileb://infra/cloudfront/redirect-to-mcknight-io.js
$(eval ETAG := $(shell aws --profile $(CF_PROFILE) cloudfront describe-function --name $(CF_FUNCTION) --stage DEVELOPMENT --query 'ETag' --output text))
aws --profile $(CF_PROFILE) cloudfront publish-function \
--name $(CF_FUNCTION) \
--if-match $(ETAG)
.PHONY: status
status:
aws --profile $(CF_PROFILE) cloudfront get-distribution --id $(CF_DISTRIBUTION) --query 'Distribution.Status' --output text
.PHONY: test
test:
aws --profile $(CF_PROFILE) cloudfront test-function \
--name $(CF_FUNCTION) \
--if-match $$(aws --profile $(CF_PROFILE) cloudfront describe-function --name $(CF_FUNCTION) --stage DEVELOPMENT --query 'ETag' --output text) \
--stage DEVELOPMENT \
--event-object "$$(echo '{"version":"1.0","context":{"eventType":"viewer-request"},"viewer":{"ip":"1.2.3.4"},"request":{"method":"GET","uri":"/blog/foo","querystring":{"bar":{"value":"baz"}},"headers":{"host":{"value":"tworingsoft.com"}}}}' | base64)" \
--query 'TestResult.{Error:FunctionErrorMessage,Output:FunctionOutput}' --output table