11# AWS S3 Demo Makefile
2- # UCM is installed locally via compile .sh (same version as Docker)
2+ # UCM is installed locally via install .sh
33
44UCM_VERSION ?= 1.0.0
55
66.PHONY : all
7- all : generate
7+ all : clean generate
88
99.PHONY : generate
10- generate : clean
11- #
12- # Download S3 model from AWS SDKs: https://github.com/aws/api-models-aws/blob/main/models/s3/service/2006-03-01/s3-2006-03-01.json
13- #
14- wget https://raw.githubusercontent.com/aws/api-models-aws/refs/heads/main/models/s3/service/2006-03-01/s3-2006-03-01.json
15- mv s3-2006-03-01.json model/
10+ generate : model/s3-2006-03-01.json
1611 #
1712 # Generate Unison code from Smithy model
1813 #
@@ -24,6 +19,10 @@ clean:
2419 rm -rf generated/* .u ./build
2520 rm -f compiled/main.uc
2621 rm -f model/* .json
22+ rm -rf terraform/.terraform
23+ rm -f terraform/.terraform.lock.hcl
24+ rm -f terraform/terraform.tfstate
25+ rm -f terraform/terraform.tfstate.backup
2726
2827.PHONY : install
2928install :
@@ -46,23 +45,47 @@ compile-with-lib: install
4645 #
4746 ./compile-with-lib.sh
4847
49- .PHONY : docker/ test
50- docker/ test : compile docker/clean
48+ .PHONY : test
49+ test : compiled/main.uc docker/start terraform
5150 #
52- # Run compiled code in Docker Compose
51+ # Run compiled Unison code against LocalStack
5352 #
54- UCM_VERSION=$(UCM_VERSION ) docker compose build
55- docker compose run --rm test
53+ ./demo.sh
5654
57- .PHONY : docker/ integration-test
58- docker/ integration-test : compile-with-lib docker/clean
55+ .PHONY : integration-test
56+ integration-test : compile-with-lib docker/start terraform
5957 #
6058 # Run compiled code in Docker Compose
6159 #
62- UCM_VERSION=$(UCM_VERSION ) docker compose build
63- docker compose run --rm test
60+ ./demo.sh
61+
62+ # make sure model/s3-2006-03-01.json is available
63+ model/s3-2006-03-01.json :
64+ #
65+ # Download S3 model from AWS SDKs: https://github.com/aws/api-models-aws/blob/main/models/s3/service/2006-03-01/s3-2006-03-01.json
66+ #
67+ wget https://raw.githubusercontent.com/aws/api-models-aws/refs/heads/main/models/s3/service/2006-03-01/s3-2006-03-01.json
68+ mv s3-2006-03-01.json model/
69+
70+ # make sure compiled/main.uc is up to date
71+ compiled/main.uc :
72+ make compile
73+
74+ .PHONY : terraform
75+ terraform :
76+ #
77+ # Run Terraform to create the S3 bucket
78+ #
79+ cd terraform && terraform init && terraform apply -auto-approve
80+
81+ .PHONY : docker/start
82+ docker/start : docker/stop
83+ #
84+ # Run LocalStack in Docker
85+ #
86+ docker run --rm -d -p 4566:4566 -e SERVICES=s3 --name localstack localstack/localstack
6487
65- .PHONY : docker/clean
66- docker/clean :
67- docker compose down --volumes --remove-orphans
68- docker compose rm --stop --force 2> /dev/null || true
88+ .PHONY : docker/stop
89+ docker/stop :
90+ docker stop localstack & > /dev/null || true
91+ docker rm localstack & > /dev/null || true
0 commit comments