-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
49 lines (36 loc) · 1.89 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
aws_region = us-west-2
build = build
# TODO: make a one-command launch of the whole stack work
# launch: deploy
# $$(terraform output fleet_env)
# ./control/launch_units.sh
$(build)/plan: $(build)/cluster_id.tfvars $(build)/keys.tfvars $(build)/visible.tfvars
terraform plan -input=false -out $(build)/plan --var-file=$(build)/cluster_id.tfvars --var-file=$(build)/keys.tfvars --var-file=$(build)/visible.tfvars
.PHONY: deploy
deploy: $(build)/plan $(build)/keys.tfvars $(build)/visible.tfvars
terraform apply -input=false --var-file=$(build)/cluster_id.tfvars --var-file=$(build)/keys.tfvars --var-file=$(build)/visible.tfvars < $(build)/plan
.PHONY: destroy
destroy: $(build)/keys.tfvars $(build)/visible.tfvars
terraform destroy -input=false --var-file=$(build)/cluster_id.tfvars --var-file=$(build)/keys.tfvars --var-file=$(build)/visible.tfvars
rm -f $(build)/terraform.tfstate
rm -f $(build)/terraform.tfstate.backup
$(build)/cluster_id.tfvars: $(build)/etcd_discovery_url $(build)/stack_name $(build)/coreos_ami
echo "stack_name = \"$$(cat $(build)/stack_name)\"" > $(build)/cluster_id.tfvars
echo "etcd_discovery_url = \"$$(cat $(build)/etcd_discovery_url)\"" >> $(build)/cluster_id.tfvars
echo "coreos_ami = \"$$(cat $(build)/coreos_ami)\"" >> $(build)/cluster_id.tfvars
$(build)/keys.tfvars:
cd visible; make outputs
$(build)/visible.tfvars:
cd visible; make outputs
$(build)/stack_name:| $(build)
cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z' | head -c 5 > $(build)/stack_name
$(build)/etcd_discovery_url: | $(build)
curl -s https://discovery.etcd.io/new?size=5 > $(build)/etcd_discovery_url
# CoreOS AMIs are alpha channel, HVM virtualization
$(build)/coreos_ami: | $(build)
curl -s https://s3.amazonaws.com/coreos.com/dist/aws/coreos-alpha-hvm.template | jq -r '.Mappings.RegionMap["$(aws_region)"].AMI' > $(build)/coreos_ami
$(build):
mkdir -p $(build)
.PHONY: clean
clean:
rm -Rf $(build)