|
| 1 | +# requires AWS_PROFILE |
| 2 | +# bucket must exist, prefix will be created |
| 3 | +S3_BUCKET ?= "s4c-cft" |
| 4 | +S3_PREFIX ?= "test" |
| 5 | +# We need the REGION or the TemplateURLs might be created for a different region, resulting in a deployment error |
| 6 | +S3_REGION ?= "eu-west-1" # ireland |
| 7 | +SECURE_API_TOKEN ?= "" |
| 8 | +STACK_NAME = "CSPMTest" |
| 9 | + |
| 10 | +.PHONY: packaged-template.yaml |
| 11 | + |
| 12 | +validate: |
| 13 | + aws cloudformation validate-template --template-body file://./CloudAgentlessRole.yaml |
| 14 | + |
| 15 | +lint: |
| 16 | + cfn-lint *.yaml |
| 17 | + |
| 18 | +packaged-template.yaml: |
| 19 | + aws s3 rm s3://$(S3_BUCKET)/ecs/$(S3_PREFIX) --recursive |
| 20 | + aws cloudformation package \ |
| 21 | + --region $(S3_REGION) \ |
| 22 | + --template-file CloudAgentlessRole.yaml \ |
| 23 | + --s3-bucket $(S3_BUCKET) \ |
| 24 | + --s3-prefix cspm/$(S3_PREFIX) \ |
| 25 | + --force-upload \ |
| 26 | + --output-template-file packaged-template.yaml |
| 27 | + |
| 28 | +test: packaged-template.yaml |
| 29 | + aws cloudformation deploy \ |
| 30 | + --stack-name $(STACK_NAME) \ |
| 31 | + --template-file packaged-template.yaml \ |
| 32 | + --capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ |
| 33 | + --parameter-overrides \ |
| 34 | + "SysdigSecureAPIToken=$(SECURE_API_TOKEN)" |
| 35 | + |
| 36 | +ci: packaged-template.yaml |
| 37 | + aws s3 cp ./packaged-template.yaml s3://$(S3_BUCKET)/cspm/$(S3_PREFIX)/entry-point.yaml |
| 38 | + |
| 39 | +clean: |
| 40 | + aws cloudformation delete-stack --stack-name $(STACK_NAME) |
| 41 | + |
| 42 | +# |
| 43 | +# local-test-manual: |
| 44 | +# (have not found a way to do it via cli) |
| 45 | +# aws console > cloudformation > create new stack (template, upload template: select ./templates_ecs/Cloudvision.yaml) |
| 46 | +# note: this will upload the template into an s3 bucket, remember to delete it afterwards |
| 47 | +# |
0 commit comments