-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
148 lines (120 loc) · 5.17 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
SHELL=/bin/bash -euo pipefail
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi
.PHONY: install check-licenses lint
install: install-python install-node install-hooks
install-python:
poetry install
install-node:
npm ci
install-hooks: install-python
poetry run pre-commit install --install-hooks --overwrite
check-licenses: check-licenses-python check-licenses-node
check-licenses-python:
scripts/check_python_licenses.sh
check-licenses-node:
npm run check-licenses --workspace packages/splunkProcessor
lint: lint-cloudformation lint-node lint-githubactions lint-githubaction-scripts
lint-cloudformation:
poetry run cfn-lint -I "cloudformation/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }'
poetry run cfn-lint -I "SAMtemplates/**/*.y*ml" 2>&1 | awk '/Run scan/ { print } /^[EW][0-9]/ { print; getline; print }'
lint-node:
npm run lint --workspace packages/certificateChecker
npm run lint --workspace packages/slackAlerter
npm run lint --workspace packages/proxygen
npm run lint --workspace packages/lambdaJanitor
lint-githubactions:
actionlint
lint-githubaction-scripts:
shellcheck .github/scripts/*.sh
test: generate-mock-certs
npm run test --workspace packages/splunkProcessor
npm run test --workspace packages/certificateChecker
npm run test --workspace packages/slackAlerter
npm run test --workspace packages/proxygen
npm run test --workspace packages/lambdaJanitor
generate-mock-certs:
cd packages/certificateChecker/tests && bash ./generate_mock_certs.sh
package-code:
npm run build
clean:
rm -rf packages/splunkProcessor/lib
rm -rf dist
deep-clean: clean
rm -rf venv
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
poetry env remove --all
aws-configure:
aws configure sso --region eu-west-2
aws-login:
aws sso login --sso-session sso-session
sam-validate:
sam validate --template-file SAMtemplates/lambda_resources.yaml --region eu-west-2
sam-build: sam-validate
sam build --template-file SAMtemplates/lambda_resources.yaml --region eu-west-2
sam-deploy-package: guard-artifact_bucket guard-ARTIFACT_BUCKET_PREFIX guard-STACK_NAME guard-TEMPLATE_FILE guard-cloud_formation_execution_role guard-VERSION_NUMBER guard-PARAMETERS
sam deploy \
--template-file $$TEMPLATE_FILE \
--stack-name $$STACK_NAME \
--capabilities CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \
--region eu-west-2 \
--s3-bucket $$artifact_bucket \
--s3-prefix $$ARTIFACT_BUCKET_PREFIX \
--config-file samconfig_package_and_deploy.toml \
--no-fail-on-empty-changeset \
--role-arn $$cloud_formation_execution_role \
--no-confirm-changeset \
--force-upload \
--tags "version=$$VERSION_NUMBER" \
--parameter-overrides $$PARAMETERS
prepare-eps-route-53-changeset-management:
@echo -e "\nChecking if stack exists in management ...";
@if ! aws cloudformation describe-stacks --stack-name eps-route53-resources --profile prescription-management; then \
echo -e "\nStack does not exist in management, creating empty stack..."; \
aws cloudformation create-stack \
--stack-name eps-route53-resources \
--template-body file://cloudformation/empty_stack.yml \
--profile prescription-management; \
echo "Waiting for stack to be created ..."; \
aws cloudformation wait stack-create-complete \
--stack-name eps-route53-resources --profile prescription-management; \
fi
@echo -e "\nCreating changeset for stack in management ...";
aws cloudformation create-change-set \
--stack-name eps-route53-resources \
--change-set-name update-eps-route-53-$$(date +"%Y-%m-%d-%H%-M%-S") \
--change-set-type UPDATE \
--template-body file://cloudformation/eps_management_route53.yml \
--tags Key="stack_name",Value="eps-route53-resources" \
--profile prescription-management
prepare-eps-route-53-changeset-environment: guard-env
@echo -e "\nChecking if stack exists in $${env} ...";
@if ! aws cloudformation describe-stacks --stack-name eps-route53-resources --profile prescription-$${env}; then \
echo -e "\nStack does not exist in $${env}, creating empty stack ..."; \
aws cloudformation create-stack \
--stack-name eps-route53-resources \
--template-body file://cloudformation/empty_stack.yml \
--profile prescription-$${env}; \
echo "Waiting for stack to be created ..."; \
aws cloudformation wait stack-create-complete \
--stack-name eps-route53-resources --profile prescription-$${env}; \
fi
@echo -e "\nCreating changeset for stack in $${env} ...";
@aws cloudformation create-change-set \
--stack-name eps-route53-resources \
--change-set-name update-route-53-$$(date +"%Y-%m-%d-%H%-M%-S") \
--change-set-type UPDATE \
--template-body file://cloudformation/eps_environment_route53.yml \
--tags Key="stack_name",Value="eps-$${env}-route53-resources" \
--parameters ParameterKey=environment,ParameterValue=$${env} \
--profile prescription-$${env}
show-eps-route-53-nameservers: guard-env
aws cloudformation describe-stacks \
--stack-name eps-route53-resources \
--query "Stacks[*].Outputs[?OutputKey=='NameServers'].{OutputKey: OutputKey, OutputValue: OutputValue, Description: Description}" \
--profile prescription-$${env}
cfn-guard:
./scripts/run_cfn_guard.sh