-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (82 loc) · 2.47 KB
/
Copy pathMakefile
File metadata and controls
99 lines (82 loc) · 2.47 KB
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
.PHONY: test lint format clean install install-dev package venv cdk-install cdk-deploy cdk-destroy cdk-diff
# Create virtual environment
venv:
python3 -m venv venv
@echo "Virtual environment created. Activate with: source venv/bin/activate"
# Install runtime dependencies
install:
python3 -m pip install -r src/requirements.txt
# Install development dependencies
install-dev: install
python3 -m pip install -r requirements-dev.txt
# Install CDK dependencies
cdk-install:
python3 -m pip install -r cdk/requirements.txt
npm install -g aws-cdk
# CDK Bootstrap (run once per account/region)
cdk-bootstrap:
cdk bootstrap
# CDK Deploy - Creates all buckets and deploys Lambda automatically
cdk-deploy:
cdk deploy --require-approval never
# CDK Destroy - Clean up all resources
cdk-destroy:
cdk destroy --force
# CDK Diff - Show what will change
cdk-diff:
cdk diff
# CDK Synth - Generate CloudFormation template
cdk-synth:
cdk synth
# Run tests
test:
cd src && python3 -m pytest ../test/ -v
# Format code
format:
black src/ test/ cdk/ --line-length 100
isort src/ test/ cdk/ --profile black
# Lint code
lint:
mypy src/
black --check src/ test/ cdk/ --line-length 100
isort --check-only src/ test/ cdk/ --profile black
flake8 src/ test/ cdk/
# Clean build artifacts
clean:
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf htmlcov/
rm -rf .coverage
rm -rf coverage.xml
rm -rf dist/
rm -rf build/
rm -rf *.egg-info/
rm -rf venv/
rm -rf cdk.out/
# Package for deployment (legacy CloudFormation)
package:
cd src && zip -r ../lambda_function.zip . -x "*.pyc" "*__pycache__*" "test*"
# Validate bucket security
validate-buckets:
python3 scripts/validate-bucket-security.py $(BUCKETS)
# Legacy CloudFormation deployments (kept for compatibility)
deploy-existing:
aws cloudformation deploy \
--template-file src/template.yaml \
--stack-name sip-security-hub-mapping \
--parameter-overrides UseExistingBuckets=true \
--capabilities CAPABILITY_IAM
# Deploy with new buckets (legacy)
deploy-new:
$(eval TIMESTAMP := $(shell date +%s))
aws cloudformation deploy \
--template-file src/template.yaml \
--stack-name sip-security-hub-mapping \
--parameter-overrides \
UseExistingBuckets=false \
S3BucketName=sip-security-hub-reports-$(TIMESTAMP) \
MappingBucketName=sip-security-hub-mapping-$(TIMESTAMP) \
CodeS3Bucket=sip-security-hub-code-$(TIMESTAMP) \
--capabilities CAPABILITY_IAM