-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rolls up all modules into single CI workflow * extend deploy target for all modules
- Loading branch information
Showing
16 changed files
with
165 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: CI - Modules | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'modules/**' | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'modules/**' | ||
|
||
jobs: | ||
lint: | ||
name: Lint Templates | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: cfn-lint | ||
uses: scottbrenner/cfn-lint-action@v2 | ||
|
||
- name: Lint | ||
working-directory: modules | ||
run: make lint | ||
|
||
validate: | ||
name: Validate Templates | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-west-1 | ||
|
||
- name: Validate Templates | ||
run: make validate | ||
working-directory: modules | ||
|
||
publish: | ||
name: Publish Templates | ||
runs-on: ubuntu-latest | ||
needs: | ||
- lint | ||
- validate | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: eu-west-1 | ||
|
||
- name: Publish Templates | ||
run: make publish | ||
working-directory: modules | ||
env: | ||
S3_BUCKET: cf-templates-cloudvision-ci | ||
S3_PREFIX: ${{ github.event.name == 'push' && 'main' || format('pr/{0}', github.event.pull_request.number)}} |
48 changes: 0 additions & 48 deletions
48
.github/workflows/ci-pull-request-modules-foundational.yaml
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
.github/workflows/ci-pull-request-modules-log_ingestion.yaml
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
.github/workflows/ci-pull-request-modules-volume_access.yaml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# requires AWS_PROFILE | ||
# bucket must exist, prefix will be created | ||
S3_BUCKET ?= "s4c-cft" | ||
S3_PREFIX ?= "test" | ||
S3_REGION ?= eu-west-1 | ||
STACK_NAME = Sysdig-Secure | ||
PARAM_NAME_SUFFIX ?= test | ||
PARAM_IS_ORGANIZATIONAL ?= false | ||
PARAM_EXTERNAL_ID ?= test | ||
PARAM_TRUSTED_IDENTITY ?= arn:aws:iam::064689838359:role/$(PARAM_NAME_SUFFIX) | ||
PARAM_TARGET_EVENT_BUS_ARN ?= arn:aws:events:us-east-1::event-bus/default | ||
PARAM_BUCKET_ARN ?= arn:aws:s3:::cloudtrail-$(PARAM_NAME_SUFFIX) | ||
PARAM_REGIONS ?= us-east-1 | ||
|
||
.PHONY: validate lint deploy test clean | ||
validate: export AWS_PAGER="" | ||
validate: | ||
aws cloudformation validate-template --template-body file://./foundational.cft.yaml | ||
aws cloudformation validate-template --template-body file://./log_ingestion.events.cft.yaml | ||
aws cloudformation validate-template --template-body file://./log_ingestion.s3.cft.yaml | ||
aws cloudformation validate-template --template-body file://./volume_access.cft.yaml | ||
|
||
lint: | ||
cfn-lint *.cft.yaml | ||
yq '.Resources.OrganizationStackSet.Properties.TemplateBody' foundational.cft.yaml | cfn-lint - | ||
yq '.Resources.EventBridgeRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - | ||
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - | ||
yq '.Resources.OrganizationRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint - | ||
yq '.Resources.ScanningKmsKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - | ||
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - | ||
yq '.Resources.OrganizationKMSKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint - | ||
|
||
publish: | ||
aws s3 cp foundational.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/foundational.cft.yaml | ||
aws s3 cp log_ingestion.s3.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/log_ingestion.s3.cft.yaml | ||
aws s3 cp log_ingestion.events.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/log_ingestion.events.cft.yaml | ||
aws s3 cp volume_access.cft.yaml s3://$(S3_BUCKET)/modules/$(S3_PREFIX)/volume_access.cft.yaml | ||
|
||
deploy: | ||
aws cloudformation deploy \ | ||
--stack-name $(STACK_NAME)-Foundational-$(PARAM_NAME_SUFFIX) \ | ||
--template-file foundational.cft.yaml \ | ||
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ | ||
--parameter-overrides \ | ||
"NameSuffix=$(PARAM_NAME_SUFFIX)" \ | ||
"ExternalID=$(PARAM_EXTERNAL_ID)" \ | ||
"TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ | ||
"IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ | ||
"OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" | ||
aws cloudformation deploy \ | ||
--stack-name $(STACK_NAME)-LogIngestion-EventBridge-$(PARAM_NAME_SUFFIX) \ | ||
--template-file log_ingestion.events.cft.yaml \ | ||
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ | ||
--parameter-overrides \ | ||
"NameSuffix=$(PARAM_NAME_SUFFIX)" \ | ||
"ExternalID=$(PARAM_EXTERNAL_ID)" \ | ||
"TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ | ||
"Regions=$(PARAM_REGIONS)" \ | ||
"TargetEventBusARN=$(PARAM_TARGET_EVENT_BUS_ARN)" \ | ||
"IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ | ||
"OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" | ||
aws cloudformation deploy \ | ||
--stack-name $(STACK_NAME)-LogIngestion-S3-$(PARAM_NAME_SUFFIX) \ | ||
--template-file log_ingestion.s3.cft.yaml \ | ||
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ | ||
--parameter-overrides \ | ||
"NameSuffix=$(PARAM_NAME_SUFFIX)" \ | ||
"ExternalID=$(PARAM_EXTERNAL_ID)" \ | ||
"TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ | ||
"BucketARN=$(PARAM_BUCKET_ARN)" \ | ||
"IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ | ||
"OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" | ||
aws cloudformation deploy \ | ||
--stack-name $(STACK_NAME)-VolumeAccess-$(PARAM_NAME_SUFFIX) \ | ||
--template-file volume_access.cft.yaml \ | ||
--capabilities "CAPABILITY_NAMED_IAM" "CAPABILITY_AUTO_EXPAND" \ | ||
--parameter-overrides \ | ||
"NameSuffix=$(PARAM_NAME_SUFFIX)" \ | ||
"ExternalID=$(PARAM_EXTERNAL_ID)" \ | ||
"TrustedIdentity=$(PARAM_TRUSTED_IDENTITY)" \ | ||
"Regions=$(PARAM_REGIONS)" \ | ||
"IsOrganizational=$(PARAM_IS_ORGANIZATIONAL)" \ | ||
"OrganizationalUnitIDs=$(PARAM_ORGANIZATIONAL_UNIT_IDS)" | ||
|
||
clean: | ||
aws cloudformation delete-stack --stack-name $(STACK_NAME)-Foundational-$(PARAM_NAME_SUFFIX) | ||
aws cloudformation delete-stack --stack-name $(STACK_NAME)-LogIngestion-EventBridge-$(PARAM_NAME_SUFFIX) | ||
aws cloudformation delete-stack --stack-name $(STACK_NAME)-LogIngestion-S3-$(PARAM_NAME_SUFFIX) | ||
aws cloudformation delete-stack --stack-name $(STACK_NAME)-VolumeAccess-$(PARAM_NAME_SUFFIX) | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.