Skip to content

Commit fd4e2fa

Browse files
author
iru
authored
feature: ecs,vpc,sg optionals (#57)
* chore: ecs,vpc,sg optionals * refact: sepparate sns/sns permissions * refact: /ecs-vpc-secgroup/ecs-vpc/ * docs: add troubleshoot sns * docs: reorganize examples-internal * docs: use-case for org-existing-cloudtrail-ecs-vpc-subnet * docs: fix compliance docs link * docs: fix pre-commit and add notes for contributing -_- * docs: update diagrams * docs: link readme with use-cases * docs: cloudtrail org role default clarification
1 parent bdd8505 commit fd4e2fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+716
-436
lines changed

.github/workflows/ci-integration-tests.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,12 @@ jobs:
7474
TF_VAR_cloudnative_secretAccessKey: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
7575
TF_VAR_region: ${{secrets.AWS_QA_MANAGED_RESOURCES_REGION }}
7676
TF_VAR_cloudtrail_s3_name: ${{ secrets.AWS_QA_MANAGED_CLOUDTRAIL_NAME }}
77-
run: bundle exec kitchen test "organizational-k8s-aws"
77+
run: |
78+
bundle exec kitchen create "organizational-k8s-aws"
79+
bundle exec kitchen converge "organizational-k8s-aws"
80+
bundle exec kitchen setup "organizational-k8s-aws"
81+
bundle exec kitchen verify "organizational-k8s-aws"
82+
bundle exec kitchen destroy "organizational-k8s-aws"
7883
7984
- name: Inspect k8s failures
8085
if: ${{ failure() }}
@@ -139,7 +144,12 @@ jobs:
139144
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
140145
AWS_REGION: ${{ secrets.AWS_REGION }}
141146
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
142-
run: bundle exec kitchen test "organizational-aws"
147+
run: |
148+
bundle exec kitchen create "organizational-aws"
149+
bundle exec kitchen converge "organizational-aws"
150+
bundle exec kitchen setup "organizational-aws"
151+
bundle exec kitchen verify "organizational-aws"
152+
bundle exec kitchen destroy "organizational-aws"
143153
144154
- name: Destroy organizational resources
145155
env:

.github/workflows/ci-pull-request.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- master
1010
paths:
1111
- '**.tf'
12+
env:
13+
GO_VERSION: "^1.17"
1214

1315
jobs:
1416
getModules:
@@ -100,14 +102,18 @@ jobs:
100102
uses: actions/checkout@v2
101103
- name: Install Python
102104
uses: actions/setup-python@v2
105+
- name: Set up Go
106+
uses: actions/setup-go@v2
107+
with:
108+
go-version: ${{ env.GO_VERSION }}
103109
- name: Install Terraform v${{ matrix.version }}
104110
uses: hashicorp/setup-terraform@v1
105111
with:
106112
terraform_version: ${{ matrix.version }}
107113
- name: Install pre-commit dependencies
108114
run: |
109115
pip install pre-commit
110-
curl -Lo ./terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.13.0/terraform-docs-v0.13.0-$(uname)-amd64.tar.gz && tar -xzf terraform-docs.tar.gz && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
116+
go install github.com/terraform-docs/terraform-docs@v0.16.0
111117
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
112118
- name: Execute pre-commit
113119
# Run all pre-commit checks on max version supported

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ override.tf.json
4040
/lib/bundler/man/
4141

4242

43-
#Kitchen test
43+
# test
4444
.kitchen/*
4545
test/fixtures/single-account/.kitchen/
46+
test/snippets/*

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#
22
# requirements
33
# - install pre-commit (latest)
4-
# - install terraform-docs (0.13)
4+
# - install terraform-docs (latest)
55
# - see .github/workflows/ci-pull-request.yaml for more info on what's being valiated on CI
6-
# `$ pre-commit run --color=always --show-diff-on-failure --all-files`
6+
# $ pre-commit run --color=always --show-diff-on-failure --all-files
77
#
88

99

CONTRIBUTE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ We're using **pre-commit** | https://pre-commit.com
5959
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6060
```
6161

62+
- If pre-commit fails on Github but not on your local, try cleaning-up `terraform` files with
63+
```bash
64+
-- resources/terraform-clean.sh
65+
$ find . -name ".terraform" -exec rm -fr {} \;
66+
$ find . -name "terraform.tfstate*" -exec rm -fr {} \;
67+
$ find . -name ".terraform.lock.hcl*" -exec rm -fr {} \;
68+
```
69+
70+
6271
## 2. Check::Integration tests
6372

6473
Final user validation. Checks that the snippets for the usage, stated in the official Sysdig Terraform Registry, are working correctly.

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Terraform module that deploys the [**Sysdig Secure for Cloud** stack in **AWS**]
55

66
Provides unified threat-detection, compliance, forensics and analysis through these major components:
77

8-
* **[CSPM/Compliance](https://docs.sysdig.com/en/docs/sysdig-secure/benchmarks/)**: It evaluates periodically your cloud configuration, using Cloud Custodian, against some benchmarks and returns the results and remediation you need to fix. Managed through `cloud-bench` module. <br/>
8+
* **[CSPM/Compliance](https://docs.sysdig.com/en/docs/sysdig-secure/posture/compliance-unified-/)**: It evaluates periodically your cloud configuration, using Cloud Custodian, against some benchmarks and returns the results and remediation you need to fix. Managed through `cloud-bench` module. <br/>
99

1010
* **[CIEM](https://docs.sysdig.com/en/docs/sysdig-secure/posture/)**: Permissions and Entitlements management. Requires BOTH modules `cloud-connector` and `cloud-bench`. <br/>
1111

@@ -41,7 +41,12 @@ For other Cloud providers check: [GCP](https://github.com/sysdiglabs/terraform-g
4141

4242
## Usage
4343

44-
There are several ways to deploy this in you AWS infrastructure:
44+
- There are several ways to deploy this in you AWS infrastructure, gathered under **[`/examples`](./examples)**
45+
- Many module,examples and use-cases provide ways to **re-use existing resources (as optionals)** in your infrastructure (cloudtrail, ecs, vpc, k8s cluster,...)
46+
- Find some real **use-case scenario explanations** under [`/examples-internal/use-cases*`](./examples-internal)
47+
- [Single Account - Existing Cloudtrail](./examples-internal/use-cases-reuse-resources/single-existing-cloudtrail.md)
48+
- [Organizational - Existing Cloudtrail, ECS, VPC, Subnet](./examples-internal/use-cases-reuse-resources/org-existing-cloudtrail-ecs-vpc-subnet.md)
49+
- [Organizational - Existing Cloudtrail withouth SNS, but with S3 configuration, with K8s Cluster and Filtered Cloudtrail Event Account](./examples-internal/use-cases-self-baked/org-s3-k8s-filtered-account.md)
4550

4651
### - Single-Account
4752

@@ -135,9 +140,23 @@ Upload any image to the ECR repository of AWS.
135140

136141
## Troubleshooting
137142

143+
### Q: Getting error "404 Invalid parameter: TopicArn" when trying to reuse an existing cloudtrail-sns
144+
145+
```text
146+
│ Error: error creating SNS Topic Subscription: InvalidParameter: Invalid parameter: TopicArn
147+
│ status code: 400, request id: 1fe94ceb-9f58-5d39-a4df-169f55d25eba
148+
149+
│ with module.cloudvision_aws_single_account.module.cloud_connector.module.cloud_connector_sqs.aws_sns_topic_subscription.this,
150+
│ on ../../../modules/infrastructure/sqs-sns-subscription/main.tf line 6, in resource "aws_sns_topic_subscription" "this":
151+
│ 6: resource "aws_sns_topic_subscription" "this" {
138152
139-
### Q: Getting error when creating the ECS subnet due to nats not being supported
140153
```
154+
155+
A: In order to subscribe to a SNS Topic, SQS queue must be in the same region
156+
S: Change `aws provider` `region` variable to match same region for all resources
157+
158+
### Q: Getting error "400 availabilityZoneId is invalid" when creating the ECS subnet
159+
```text
141160
│ Error: error creating subnet: InvalidParameterValue: Value (apne1-az3) for parameter availabilityZoneId is invalid. Subnets can currently only be created in the following availability zones: apne1-az1, apne1-az2, apne1-az4.
142161
│ status code: 400, request id: 6e32d757-2e61-4220-8106-22ccf814e1fe
143162

examples-internal/organizational-k8s-threat-reuse_cloudtrail/README.md renamed to examples-internal/organizational-k8s-threat-reuse_cloudtrail_s3/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ Notice that:
8181

8282
| Name | Version |
8383
|------|---------|
84-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.50.0 |
85-
| <a name="provider_helm"></a> [helm](#provider\_helm) | >=2.3.0 |
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.0 |
85+
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.4.1 |
8686

8787
## Modules
8888

8989
| Name | Source | Version |
9090
|------|--------|---------|
91-
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | ../../modules/infrastructure/resource-group | |
92-
| <a name="module_ssm"></a> [ssm](#module\_ssm) | ../../modules/infrastructure/ssm | |
91+
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | ../../modules/infrastructure/resource-group | n/a |
92+
| <a name="module_ssm"></a> [ssm](#module\_ssm) | ../../modules/infrastructure/ssm | n/a |
9393

9494
## Resources
9595

examples-internal/single-account-benchmark/main.tf

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples-internal/single-account-benchmark/outputs.tf

Whitespace-only changes.

examples-internal/single-account-benchmark/variables.tf

Lines changed: 0 additions & 45 deletions
This file was deleted.

examples-internal/single-account-benchmark/versions.tf

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples-internal/single-account-existing-cloudtrail/main.tf

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples-internal/single-account-existing-cloudtrail/outputs.tf

Whitespace-only changes.

examples-internal/single-account-existing-cloudtrail/variables.tf

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)