forked from cmdlabs/cmd-tf-aws-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (50 loc) · 2.26 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
51
52
53
54
55
56
57
58
59
60
61
62
63
RELEASE_VERSION = 0.9.1
ifdef CI
PROFILE_REQUIRED=profile
endif
SUBFOLDER ?= .
docs: .env
docker-compose run --rm terraform-utils terraform-docs markdown document . --no-providers --header-from s3.tf > README.md
.PHONY: docs
format: .env
docker-compose run --rm terraform-utils terraform fmt -recursive .
.PHONY: format
formatCheck: .env
docker-compose run --rm terraform-utils terraform fmt -recursive -check -diff .
.PHONY: formatCheck
init: .env $(PROFILE_REQUIRED)
docker-compose run --rm terraform-utils terraform init
.PHONY: init
plan: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform plan
.PHONY: plan
apply: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform apply -auto-approve
.PHONY: apply
destroy: .env $(PROFILE_REQUIRED) init
docker-compose run --rm terraform-utils terraform destroy -auto-approve
.PHONY: destroy
tag:
git tag -a $(RELEASE_VERSION) -m ''
git push origin $(RELEASE_VERSION)
.PHONY: tag
publish: .env
docker-compose run --rm envvars ensure --tags publish
git fetch --all
git remote add github https://$(GIT_USERNAME):$(GIT_PASSWORD)@github.com/cmdlabs/$(CI_PROJECT_NAME)
git checkout master
git pull origin master
git push --follow-tags github master
docker-compose run --rm terraform-utils curl -X POST -H 'Content-type: application/json' --data '{"text":"A new commit has been published to Github\nProject: $(CI_PROJECT_NAME)\nRef: $(CI_COMMIT_REF_NAME)\nDiff: https://github.com/cmdlabs/$(CI_PROJECT_NAME)/commit/$(CI_COMMIT_SHA)"}' $(GIT_PUBLISHING_WEBHOOK)
.PHONY: publish
profile: .env
docker-compose run --rm envvars ensure --tags profile
docker-compose run --rm aws sh -c 'aws configure set credential_source Ec2InstanceMetadata --profile $${AWS_PROFILE_NAME}'
docker-compose run --rm aws sh -c 'aws configure set role_arn arn:aws:iam::$${AWS_ACCOUNT_ID}:role/$${AWS_ROLE_NAME} --profile $${AWS_PROFILE_NAME}'
docker-compose run --rm aws aws configure set credential_source Ec2InstanceMetadata --profile cmdlabtf-tfbackend
docker-compose run --rm aws aws configure set role_arn arn:aws:iam::471871437096:role/gitlab_runner --profile cmdlabtf-tfbackend
.env:
touch .env
docker-compose run --rm envvars validate
docker-compose run --rm envvars envfile --overwrite
.PHONY: .env