forked from maintux/quickstart-kubernetes-resource-provider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (47 loc) · 1.67 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
41
42
43
44
45
46
47
48
49
50
.PHONY: build publish clean
REGION ?= us-east-1
BUCKET ?= uno-resource-type-dev
EX_ROLE ?= arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>
LOG_ROLE ?= arn:aws:iam::<ACCOUNT_ID>:role/<ROLE_NAME>
build:
docker build . -t k8s-cfn-build
docker run -i --name k8s-cfn-build k8s-cfn-build
docker cp k8s-cfn-build:/output/. ./build/
docker rm k8s-cfn-build
publish:
set -ex ; \
for n in apply get ; do \
aws s3 cp ./build/awsqs_kubernetes_$${n}.zip s3://$(BUCKET)/ ;\
TYPE_NAME=Resource ;\
if [ "$${n}" == "get" ] ; then TYPE_NAME=Get ; fi ;\
TOKEN=`aws cloudformation register-type \
--type "RESOURCE" \
--type-name "AWSQS::Kubernetes::$${TYPE_NAME}" \
--schema-handler-package s3://$(BUCKET)/awsqs_kubernetes_$${n}.zip \
--logging-config LogRoleArn=$(LOG_ROLE),LogGroupName=/cloudformation/registry/awsqs-kubernetes-$${n} \
--execution-role-arn $(EX_ROLE) \
--region $(REGION) \
--query RegistrationToken \
--output text` ;\
while true; do \
STATUS=`aws cloudformation describe-type-registration \
--registration-token $${TOKEN} \
--region $(REGION) --query ProgressStatus --output text` ;\
if [ "$${STATUS}" == "FAILED" ] ; then \
aws cloudformation describe-type-registration \
--registration-token $${TOKEN} \
--region $(REGION) ;\
exit 1 ; \
fi ; \
if [ "$${STATUS}" == "COMPLETE" ] ; then \
ARN=`aws cloudformation describe-type-registration \
--registration-token $${TOKEN} \
--region $(REGION) --query TypeVersionArn --output text` ;\
break ; \
fi ; \
sleep 5 ; \
done ;\
aws cloudformation set-type-default-version --arn $${ARN} --region $(REGION) ;\
done
clean:
rm -rf build/