|
| 1 | +# requires AWS_PROFILE |
| 2 | +# bucket must exist, prefix will be created |
| 3 | +S3_BUCKET ?= "s4c-cft" |
| 4 | +S3_PREFIX ?= "test" |
| 5 | +S3_REGION ?= eu-west-1 |
| 6 | +STACK_NAME = Sysdig-Secure |
| 7 | +PARAM_NAME_SUFFIX ?= test |
| 8 | +PARAM_IS_ORGANIZATIONAL ?= false |
| 9 | +PARAM_EXTERNAL_ID ?= test |
| 10 | +PARAM_TRUSTED_IDENTITY ?= arn:aws:iam:::role/$(PARAM_NAME_SUFFIX) |
| 11 | +PARAM_TARGET_EVENT_BUS_ARN ?= arn:aws:events:us-east-1::event-bus/default |
| 12 | +PARAM_BUCKET_ARN ?= arn:aws:s3:::cloudtrail-$(PARAM_NAME_SUFFIX) |
| 13 | +PARAM_REGIONS ?= us-east-1 |
| 14 | + |
| 15 | +.PHONY: validate lint deploy test clean |
| 16 | +validate: export AWS_PAGER="" |
| 17 | +validate: |
| 18 | + aws cloudformation validate-template --template-body file://./foundational.cft.yaml |
| 19 | + aws cloudformation validate-template --template-body file://./log_ingestion.events.cft.yaml |
| 20 | + aws cloudformation validate-template --template-body file://./log_ingestion.s3.cft.yaml |
| 21 | + aws cloudformation validate-template --template-body file://./volume_access.cft.yaml |
| 22 | + |
| 23 | +lint: |
| 24 | + cfn-lint *.cft.yaml |
| 25 | + yq '.Resources.OrganizationStackSet.Properties.TemplateBody' foundational.cft.yaml | cfn-lint - |
| 26 | + yq '.Resources.EventBridgeRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - |
| 27 | + yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - |
| 28 | + yq '.Resources.OrganizationRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - |
| 29 | + yq '.Resources.ScanningKmsKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - |
| 30 | + yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - |
| 31 | + yq '.Resources.OrganizationKMSKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - |
| 32 | + |
| 33 | +publish: |
| 34 | + aws s3 cp foundational.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/foundational.cft.yaml |
| 35 | + aws s3 cp log_ingestion.s3.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/log_ingestion.s3.cft.yaml |
| 36 | + aws s3 cp log_ingestion.events.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/log_ingestion.events.cft.yaml |
| 37 | + aws s3 cp volume_access.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/volume_access.cft.yaml |
| 38 | + |
| 39 | +deploy: |
| 40 | + aws cloudformation deploy \ |
| 41 | + --stack-name $(STACK_NAME)-Foundational-$(PARAM_NAME_SUFFIX) \ |
| 42 | + --template-file foundational.cft.yaml \ |
| 43 | + --capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ |
| 44 | + --parameter-overrides \ |
| 45 | + "NameSuffix=$(PARAM_NAME_SUFFIX)" \ |
| 46 | + "ExternalID=$(PARAM_EXTERNAL_ID)" \ |
| 47 | + "TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ |
| 48 | + "IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ |
| 49 | + "OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" |
| 50 | + aws cloudformation deploy \ |
| 51 | + --stack-name $(STACK_NAME)-LogIngestion-EventBridge-$(PARAM_NAME_SUFFIX) \ |
| 52 | + --template-file log_ingestion.events.cft.yaml \ |
| 53 | + --capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ |
| 54 | + --parameter-overrides \ |
| 55 | + "NameSuffix=$(PARAM_NAME_SUFFIX)" \ |
| 56 | + "ExternalID=$(PARAM_EXTERNAL_ID)" \ |
| 57 | + "TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ |
| 58 | + "Regions=$(PARAM_REGIONS)" \ |
| 59 | + "TargetEventBusARN=$(PARAM_TARGET_EVENT_BUS_ARN)" \ |
| 60 | + "IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ |
| 61 | + "OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" |
| 62 | + aws cloudformation deploy \ |
| 63 | + --stack-name $(STACK_NAME)-LogIngestion-S3-$(PARAM_NAME_SUFFIX) \ |
| 64 | + --template-file log_ingestion.s3.cft.yaml \ |
| 65 | + --capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ |
| 66 | + --parameter-overrides \ |
| 67 | + "NameSuffix=$(PARAM_NAME_SUFFIX)" \ |
| 68 | + "ExternalID=$(PARAM_EXTERNAL_ID)" \ |
| 69 | + "TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ |
| 70 | + "BucketARN=$(PARAM_BUCKET_ARN)" \ |
| 71 | + "IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ |
| 72 | + "OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" |
| 73 | + aws cloudformation deploy \ |
| 74 | + --stack-name $(STACK_NAME)-VolumeAccess-$(PARAM_NAME_SUFFIX) \ |
| 75 | + --template-file volume_access.cft.yaml \ |
| 76 | + --capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ |
| 77 | + --parameter-overrides \ |
| 78 | + "NameSuffix=$(PARAM_NAME_SUFFIX)" \ |
| 79 | + "ExternalID=$(PARAM_EXTERNAL_ID)" \ |
| 80 | + "TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ |
| 81 | + "Regions=$(PARAM_REGIONS)" \ |
| 82 | + "IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ |
| 83 | + "OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" |
| 84 | + |
| 85 | +clean: |
| 86 | + aws cloudformation delete-stack --stack-name $(STACK_NAME)-Foundational-$(PARAM_NAME_SUFFIX) |
| 87 | + aws cloudformation delete-stack --stack-name $(STACK_NAME)-LogIngestion-EventBridge-$(PARAM_NAME_SUFFIX) |
| 88 | + aws cloudformation delete-stack --stack-name $(STACK_NAME)-LogIngestion-S3-$(PARAM_NAME_SUFFIX) |
| 89 | + aws cloudformation delete-stack --stack-name $(STACK_NAME)-VolumeAccess-$(PARAM_NAME_SUFFIX) |
| 90 | + |
| 91 | + |
0 commit comments