-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
86 lines (66 loc) · 3.41 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
VERSION ?= 0.8.33.0
REGION ?= us-east-1
.DEFAULT_TARGET: help-cmds
.PHONY: help-cmds
help-cmds: ## This help.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: dkr-clean
dkr-clean: ## Clean up all local deps.
-rm -Rf cloud-custodian
.PHONY: dkr-build
dkr-build: ## Builds a Docker image and tags it.
@docker build -t "cloud-custodian:$(VERSION)" .
@docker tag "cloud-custodian:$(VERSION)" "cloud-custodian:$(VERSION)"
.PHONY: dkr-build-nocache
dkr-build-nocache: ## Builds Docker image using "--no-cache" and tags it.
@docker build --no-cache -t "cloud-custodian:$(VERSION)" .
@docker tag "cloud-custodian:$(VERSION)" "cloud-custodian:$(VERSION)"
.PHONY: dkr-tag-latest
dkr-tag-latest: ## Tags `VERSION` image with "latest".
@docker tag "cloud-custodian:$(VERSION)" cloud-custodian:latest
.PHONY: dkr-push
dkr-push: ## Push image with tag `VERSION` to ECR.
@$$(aws ecr get-login --no-include-email --region us-east-1)
@docker tag "cloud-custodian:$(VERSION)" "$$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.$(REGION).amazonaws.com/cloud-custodian:$(VERSION)"
@docker push "$$(cd terraform && terraform output -json | jq -r '.c7n_docker_repo_url.value'):$(VERSION)"
.PHONY: dkr-push-latest
dkr-push-latest: ## Tag image of version `VERSION` with `latest` tag and push to ECR.
@$$(aws ecr get-login --no-include-email --region us-east-1)
@docker tag "cloud-custodian:$(VERSION)" "$$(aws sts get-caller-identity --query 'Account' --output text).dkr.ecr.$(REGION).amazonaws.com/cloud-custodian:latest"
@docker push "$$(cd terraform && terraform output -json | jq -r '.c7n_docker_repo_url.value'):latest"
.PHONY: cust-lambda
cust-lambda: ## Runs "c7n-mailer" with "--update-lambda" flag. Requires AWS environment credentials.
@docker run \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_DEFAULT_REGION="$(REGION)" \
-v "$(CURDIR)/logs:/tmp" \
"cloud-custodian:$(VERSION)" \
-c "/usr/local/bin/c7n-mailer --config mailer.yml --update-lambda"
.PHONY: cust-run
cust-run: ## Run custodian. Requires AWS environment credentials.
@docker run \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_DEFAULT_REGION="$(REGION)" \
-v "$(CURDIR)/logs:/tmp" \
"cloud-custodian:$(VERSION)" \
-c "/usr/local/bin/custodian run -c policy.yml -s .; /usr/local/bin/c7n-mailer --config mailer.yml --run"
.PHONY: logs-s3
logs-s3: ## Run custodian. Requires AWS environment credentials.
@docker run \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_DEFAULT_REGION="$(REGION)" \
-v "$(CURDIR)/logs:/tmp" \
"cloud-custodian:$(VERSION)" \
-c "/usr/local/bin/custodian run --output-dir s3://"${S3_BUCKET_NAME}"/ policy.yml; /usr/local/bin/c7n-mailer --config mailer.yml --run"
.PHONY: cust-dryrun
cust-dryrun: ## Run custodian in dry-run mode. Requires AWS environment credentials.
@docker run \
-e AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
-e AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
-e AWS_DEFAULT_REGION="$(REGION)" \
-v "$(CURDIR)/logs:/tmp" \
"cloud-custodian:$(VERSION)" \
-c "/usr/local/bin/custodian run --dry-run --output-dir=/tmp policy.yml; /usr/local/bin/c7n-mailer --config mailer.yml --run"