Skip to content

Commit 0183731

Browse files
author
iru
authored
Feat/enable bench example single k8s (#46)
* feat: enable benchmark on single-account-k8s * docs: clarify CIEM * fix: honour name on cloudrun
1 parent 9bf3cba commit 0183731

File tree

13 files changed

+171
-127
lines changed

13 files changed

+171
-127
lines changed

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

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,58 +15,58 @@ on:
1515
concurrency: terraform
1616

1717
jobs:
18-
integration_test_ecs:
18+
# integration_test_ecs:
1919
# concurrency: terraform-account
20-
21-
name: Test-Kitchen-ECS
22-
runs-on: ubuntu-latest
23-
env:
24-
TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
25-
TF_VAR_sysdig_secure_api_token: ${{secrets.KUBELAB_SECURE_API_TOKEN}}
26-
27-
steps:
28-
- name: Checkout
29-
uses: actions/checkout@v2
30-
31-
- uses: ruby/setup-ruby@v1
32-
with:
33-
ruby-version: 2.7
34-
bundler-cache: true
35-
36-
- name: Run single-account test
37-
env:
38-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
39-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
40-
AWS_REGION: ${{ secrets.AWS_REGION }}
41-
run: bundle exec kitchen test "single-account-aws"
42-
43-
- name: Destroy single-account resources
44-
env:
45-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
46-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
47-
AWS_REGION: ${{ secrets.AWS_REGION }}
48-
if: ${{ failure() }}
49-
run: bundle exec kitchen destroy "single-account-aws"
50-
51-
- name: Run organizational test
52-
env:
53-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
54-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
55-
AWS_REGION: ${{ secrets.AWS_REGION }}
56-
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
57-
run: bundle exec kitchen test "organizational-aws"
58-
59-
- name: Destroy organizational resources
60-
env:
61-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
62-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
63-
AWS_REGION: ${{ secrets.AWS_REGION }}
64-
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
65-
if: ${{ failure() }}
66-
run: bundle exec kitchen destroy "organizational-aws"
20+
#
21+
# name: Test-Kitchen-ECS
22+
# runs-on: ubuntu-latest
23+
# env:
24+
# TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
25+
# TF_VAR_sysdig_secure_api_token: ${{secrets.KUBELAB_SECURE_API_TOKEN}}
26+
#
27+
# steps:
28+
# - name: Checkout
29+
# uses: actions/checkout@v2
30+
#
31+
# - uses: ruby/setup-ruby@v1
32+
# with:
33+
# ruby-version: 2.7
34+
# bundler-cache: true
35+
#
36+
# - name: Run single-account test
37+
# env:
38+
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
39+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
40+
# AWS_REGION: ${{ secrets.AWS_REGION }}
41+
# run: bundle exec kitchen test "single-account-aws"
42+
#
43+
# - name: Destroy single-account resources
44+
# env:
45+
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
46+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
47+
# AWS_REGION: ${{ secrets.AWS_REGION }}
48+
# if: ${{ failure() }}
49+
# run: bundle exec kitchen destroy "single-account-aws"
50+
#
51+
# - name: Run organizational test
52+
# env:
53+
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
54+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
55+
# AWS_REGION: ${{ secrets.AWS_REGION }}
56+
# TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
57+
# run: bundle exec kitchen test "organizational-aws"
58+
#
59+
# - name: Destroy organizational resources
60+
# env:
61+
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
62+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
63+
# AWS_REGION: ${{ secrets.AWS_REGION }}
64+
# TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
65+
# if: ${{ failure() }}
66+
# run: bundle exec kitchen destroy "organizational-aws"
6767

6868
integration_test-eks:
69-
# concurrency: terraform-account
69+
concurrency: terraform-account
7070
continue-on-error: true
7171

7272
name: Test-Kitchen-EKS

README.md

Lines changed: 51 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Sysdig Secure for Cloud in AWS
22

33
Terraform module that deploys the [**Sysdig Secure for Cloud** stack in **AWS**](https://docs.sysdig.com/en/docs/installation/sysdig-secure-for-cloud/deploy-sysdig-secure-for-cloud-on-aws).
4-
<br/>It provides unified threat detection, compliance, forensics and analysis.
4+
<br/>
5+
6+
Provides unified threat-detection, compliance, forensics and analysis through these major components:
57

6-
There are three major components:
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/>
79

8-
* **CSPM/Compliance**: 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](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-bench).<br/>
10+
* **[CIEM](https://docs.sysdig.com/en/docs/sysdig-secure/posture/)**: Permissions and Entitlements management. Requires BOTH modules `cloud-connector` and `cloud-bench`. <br/>
911

10-
* **Cloud Threat Detection**: Tracks abnormal and suspicious activities in your cloud environment based on Falco language. Managed through [cloud-connector module](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector).<br/>
12+
* **[Cloud Threat Detection](https://docs.sysdig.com/en/docs/sysdig-secure/insights/)**: Tracks abnormal and suspicious activities in your cloud environment based on Falco language. Managed through `cloud-connector` module. <br/>
1113

12-
* **Cloud Scanning**: Automatically scans all container images pushed to the registry or as soon a new task which involves a container is spawned in your account. Managed through [cloud-connector module](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector).<br/>
14+
* **[Cloud Scanning](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)**: Automatically scans all container images pushed to the registry or as soon a new task which involves a container is spawned in your account. Managed through `cloud-connector`. <br/>
1315

1416
For other Cloud providers check: [GCP](https://github.com/sysdiglabs/terraform-google-secure-for-cloud), [Azure](https://github.com/sysdiglabs/terraform-azurerm-secure-for-cloud)
1517

@@ -73,45 +75,55 @@ Notice that:
7375
* This example will create resources that cost money.<br/>Run `terraform destroy` when you don't need them anymore
7476
* All created resources will be created within the tags `product:sysdig-secure-for-cloud`, within the resource-group `sysdig-secure-for-cloud`
7577

78+
<br/><br/>
79+
80+
## Forcing Events
81+
82+
**Threat Detection**
83+
84+
Choose one of the rules contained in the `AWS Best Practices` policy and execute it in your AWS account.
7685

86+
ex.: 'Delete Bucket Public Access Block' can be easily tested going to an
87+
`S3 bucket > Permissions > Block public access (bucket settings) > edit >
88+
uncheck 'Block all public access'`
89+
90+
Remember that in case you add new rules to the policy you need to give it time to propagate the changes.
91+
92+
In the `cloud-connector` logs you should see similar logs to these
93+
> A public access block for a bucket has been deleted (requesting user=OrganizationAccountAccessRole, requesting IP=x.x.x.x, AWS region=eu-central-1, bucket=***
94+
95+
If that's not working as expected, some other questions can be checked
96+
- are events consumed in the sqs queue, or are they pending?
97+
- are events being sent to sns topic?
98+
99+
**Image Scanning**
100+
101+
Upload any image to the ECR repository of AWS.
102+
<br/>You should see a log in the ECS-cloud-scanner task + CodeBuild project being launched successfully
77103

78104
<br/><br/>
79105
## Troubleshooting
80106

81-
- Q: How to **validate secure-for-cloud cloud-connector (thread-detection) provisioning** is working as expected?<br/>
82-
A: Check each pipeline resource is working as expected (from high to low lvl)
83-
- select a rule to break manually, from the 'Sysdig AWS Best Practices' policies. for example, 'Delete Bucket Public Access Block'. can you see the event?
84-
- are there any errors in the ECS task logs? can also check cloudwatch logs
85-
for previous example we should see the event
86-
```
87-
{"level":"info","component":"console-notifier","time":"2021-07-26T12:45:25Z","message":"A pulic access block for a bucket has been deleted (requesting user=OrganizationAccountAccessRole, requesting IP=x.x.x.x, AWS region=eu-central-1, bucket=sysdig-secure-for-cloud-nnnnnn-config)"}
88-
```
89-
- are events consumed in the sqs queue, or are they pending?
90-
- are events being sent to sns topic?
91-
92-
93-
- Q: How to iterate **cloud-connector modification testing**
94-
<br/>A: Build a custom docker image of cloud-connector `docker build . -t <DOCKER_IMAGE> -f ./build/cloud-connector/Dockerfile` and upload it to any registry (like dockerhub).
95-
Modify the [var.image](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector/variables.tf) variable to point to your image and deploy
96-
97-
98-
- Q: How can I iterate **ECS testing**
99-
<br/>A: After applying your modifications (vía terraform for example) restart the service
100-
```
101-
$ aws ecs update-service --force-new-deployment --cluster sysdig-secure-for-cloud-ecscluster --service sysdig-secure-for-cloud-cloudconnector --profile <AWS_PROFILE>
102-
```
103-
For the AWS_PROFILE, set your `~/.aws/config` to impersonate
104-
```
105-
[profile secure-for-cloud]
106-
region=eu-central-1
107-
role_arn=arn:aws:iam::<AWS_MANAGEMENT_ORGANIZATION_ACCOUNT>:role/OrganizationAccountAccessRole
108-
source_profile=<AWS_MANAGEMENT_ACCOUNT_PROFILE>
109-
```
110-
111-
- Q: How to test **cloud-scanner** image-scanning?<br/>
112-
A: Upload any image to the ECR repository of AWS. You should see a log in the ECS-cloud-scanner task + CodeBuild project being launched successfully
113-
<br/>
114-
107+
### Q: I'm not able to see Cloud Infrastructure Entitlements Management (CIEM) results
108+
A: Make sure you installed both [cloud-bench](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-bench) and [cloud-connector](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector) modules
109+
110+
### Q: How to iterate cloud-connector modification testing
111+
A: Build a custom docker image of cloud-connector `docker build . -t <DOCKER_IMAGE> -f ./build/cloud-connector/Dockerfile` and upload it to any registry (like dockerhub).
112+
Modify the [var.image](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/tree/master/modules/services/cloud-connector/variables.tf) variable to point to your image and deploy
113+
114+
115+
### Q: How can I iterate ECS modification testing
116+
A: After applying your modifications (vía terraform for example) restart the service
117+
```
118+
$ aws ecs update-service --force-new-deployment --cluster sysdig-secure-for-cloud-ecscluster --service sysdig-secure-for-cloud-cloudconnector --profile <AWS_PROFILE>
119+
```
120+
For the AWS_PROFILE, set your `~/.aws/config` to impersonate
121+
```
122+
[profile secure-for-cloud]
123+
region=eu-central-1
124+
role_arn=arn:aws:iam::<AWS_MANAGEMENT_ORGANIZATION_ACCOUNT>:role/OrganizationAccountAccessRole
125+
source_profile=<AWS_MANAGEMENT_ACCOUNT_PROFILE>
126+
```
115127

116128
<br/><br/>
117129
## Authors

examples/organizational/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Notice that:
118118
| <a name="input_cloudtrail_s3_arn"></a> [cloudtrail\_s3\_arn](#input\_cloudtrail\_s3\_arn) | ARN of a pre-existing cloudtrail\_sns s3 bucket. If it does not exist, it will be inferred from create cloudtrail | `string` | `"create"` | no |
119119
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If it does not exist, it will be inferred from created cloudtrail | `string` | `"create"` | no |
120120
| <a name="input_connector_ecs_task_role_name"></a> [connector\_ecs\_task\_role\_name](#input\_connector\_ecs\_task\_role\_name) | Name for the ecs task role. This is only required to resolve cyclic dependency with organizational approach | `string` | `"organizational-ECSTaskRole"` | no |
121-
| <a name="input_deploy_bench"></a> [deploy\_bench](#input\_deploy\_bench) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
121+
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
122122
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
123123
| <a name="input_organizational_member_default_admin_role"></a> [organizational\_member\_default\_admin\_role](#input\_organizational\_member\_default\_admin\_role) | Default role created by AWS for managed-account users to be able to admin member accounts.<br/>https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html | `string` | `"OrganizationAccountAccessRole"` | no |
124124
| <a name="input_region"></a> [region](#input\_region) | Default region for resource creation in both organization master and secure-for-cloud member account | `string` | `"eu-central-1"` | no |

examples/organizational/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ module "cloud_connector" {
9999

100100
module "cloud_bench" {
101101
source = "../../modules/services/cloud-bench"
102-
count = var.deploy_bench ? 1 : 0
102+
count = var.deploy_benchmark ? 1 : 0
103103

104104
name = "${var.name}-cloudbench"
105-
tags = var.tags
106105
is_organizational = true
107106
region = data.aws_region.current.name
108107
benchmark_regions = var.benchmark_regions
108+
109+
tags = var.tags
109110
}

examples/organizational/variables.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,17 @@ variable "cloudtrail_kms_enable" {
6262
# benchmark configuration
6363
#
6464

65-
variable "benchmark_regions" {
66-
type = list(string)
67-
description = "List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default."
68-
default = []
69-
}
70-
71-
variable "deploy_bench" {
65+
variable "deploy_benchmark" {
7266
type = bool
7367
description = "Whether to deploy or not the cloud benchmarking"
7468
default = true
7569
}
7670

71+
variable "benchmark_regions" {
72+
type = list(string)
73+
description = "List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default."
74+
default = []
75+
}
7776

7877
#
7978
# general

examples/single-account-k8s/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
Deploy Sysdig Secure for Cloud in a provided existing Kubernetes Cluster.
44

5-
- Sysdig **Helm** charts will be used to deploy threat-detection and scanning modules
6-
- [Cloud-Connector Chart](https://charts.sysdig.com/charts/cloud-connector/)
7-
- [Cloud-Scanning Chart](https://charts.sysdig.com/charts/cloud-scanning/)
8-
- Because these charts require specific AWS credentials to be passed by parameter, a new user + access key will be created within account. See [`credentials.tf`](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/examples/single-account-k8s/credentials.tf)
5+
- Sysdig **Helm** [cloud-connector chart](https://charts.sysdig.com/charts/cloud-connector/) will be used to deploy threat-detection and scanning features
6+
<br/>Because these charts require specific AWS credentials to be passed by parameter, a new user + access key will be created within account. See [`credentials.tf`](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/examples/single-account-k8s/credentials.tf)
97
- Used architecture is similar to [single-account](https://github.com/sysdiglabs/terraform-aws-secure-for-cloud/blob/master/examples/single-account) but changing ECS <---> with an existing EKS
108

119
All the required resources and workloads will be run under the same AWS account.
@@ -81,6 +79,7 @@ Notice that:
8179

8280
| Name | Source | Version |
8381
|------|--------|---------|
82+
| <a name="module_cloud_bench"></a> [cloud\_bench](#module\_cloud\_bench) | ../../modules/services/cloud-bench | |
8483
| <a name="module_cloud_connector_sqs"></a> [cloud\_connector\_sqs](#module\_cloud\_connector\_sqs) | ../../modules/infrastructure/sqs-sns-subscription | |
8584
| <a name="module_cloudtrail"></a> [cloudtrail](#module\_cloudtrail) | ../../modules/infrastructure/cloudtrail | |
8685
| <a name="module_codebuild"></a> [codebuild](#module\_codebuild) | ../../modules/infrastructure/codebuild | |
@@ -100,9 +99,11 @@ Notice that:
10099
| Name | Description | Type | Default | Required |
101100
|------|-------------|------|---------|:--------:|
102101
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig Secure API token | `string` | n/a | yes |
102+
| <a name="input_benchmark_regions"></a> [benchmark\_regions](#input\_benchmark\_regions) | List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default. | `list(string)` | `[]` | no |
103103
| <a name="input_cloudtrail_is_multi_region_trail"></a> [cloudtrail\_is\_multi\_region\_trail](#input\_cloudtrail\_is\_multi\_region\_trail) | true/false whether cloudtrail will ingest multiregional events. testing/economization purpose. | `bool` | `true` | no |
104104
| <a name="input_cloudtrail_kms_enable"></a> [cloudtrail\_kms\_enable](#input\_cloudtrail\_kms\_enable) | true/false whether s3 should be encrypted. testing/economization purpose. | `bool` | `true` | no |
105105
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If it does not exist, it will be inferred from created cloudtrail | `string` | `"create"` | no |
106+
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
106107
| <a name="input_deploy_image_scanning"></a> [deploy\_image\_scanning](#input\_deploy\_image\_scanning) | true/false whether to deploy cloud\_scanning | `bool` | `true` | no |
107108
| <a name="input_deploy_threat_detection"></a> [deploy\_threat\_detection](#input\_deploy\_threat\_detection) | true/false whether to deploy cloud\_connector | `bool` | `true` | no |
108109
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
provider "sysdig" {
2+
sysdig_secure_url = var.sysdig_secure_endpoint
3+
sysdig_secure_api_token = var.sysdig_secure_api_token
4+
sysdig_secure_insecure_tls = length(regexall("https://.*?\\.sysdig(cloud)?.com/?", var.sysdig_secure_endpoint)) == 1 ? false : true
5+
}
6+
7+
module "cloud_bench" {
8+
source = "../../modules/services/cloud-bench"
9+
count = var.deploy_benchmark ? 1 : 0
10+
11+
name = "${var.name}-cloudbench"
12+
benchmark_regions = var.benchmark_regions
13+
14+
tags = var.tags
15+
}

examples/single-account-k8s/cloud-connector.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module "cloud_connector_sqs" {
55
count = var.deploy_threat_detection ? 1 : 0
66
source = "../../modules/infrastructure/sqs-sns-subscription"
77

8-
name = "${var.name}-cloud_connector"
8+
name = var.name
99
sns_topic_arn = local.cloudtrail_sns_arn
1010
tags = var.tags
1111
}
@@ -14,6 +14,7 @@ module "codebuild" {
1414
count = var.deploy_image_scanning ? 1 : 0
1515
source = "../../modules/infrastructure/codebuild"
1616

17+
name = var.name
1718
secure_api_token_secret_name = module.ssm.secure_api_token_secret_name
1819

1920
tags = var.tags

0 commit comments

Comments
 (0)