Skip to content

Commit a20400e

Browse files
author
iru
authored
refactor!: scanning not defaulted (#84)
* refactor: default cspm only
1 parent a57685c commit a20400e

File tree

27 files changed

+132
-100
lines changed

27 files changed

+132
-100
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ override.tf.json
4242

4343
# test
4444
.kitchen/*
45-
test/fixtures/single-account-ecs/.kitchen/
45+
test/fixtures/**/.kitchen/
4646
test/snippets/*

.pre-commit-config.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,20 @@ repos:
4343
- id: terraform_tflint
4444
exclude: (test)|(examples-internal)\/.*$
4545
args:
46-
- '--args=--only=terraform_deprecated_interpolation'
47-
- '--args=--only=terraform_deprecated_index'
48-
- '--args=--only=terraform_unused_declarations'
4946
- '--args=--only=terraform_comment_syntax'
47+
- '--args=--only=terraform_deprecated_index'
48+
- '--args=--only=terraform_deprecated_interpolation'
5049
- '--args=--only=terraform_documented_outputs'
5150
- '--args=--only=terraform_documented_variables'
52-
- '--args=--only=terraform_typed_variables'
5351
- '--args=--only=terraform_module_pinned_source'
52+
- '--args=--only=terraform_module_version'
5453
- '--args=--only=terraform_naming_convention'
55-
- '--args=--only=terraform_required_version'
5654
- '--args=--only=terraform_required_providers'
55+
- '--args=--only=terraform_required_version'
5756
- '--args=--only=terraform_standard_module_structure'
57+
- '--args=--only=terraform_typed_variables'
58+
- '--args=--only=terraform_unused_declarations'
59+
- '--args=--only=terraform_unused_required_providers'
5860
- '--args=--only=terraform_workspace_remote'
5961
- repo: https://github.com/pre-commit/pre-commit-hooks
6062
rev: v4.1.0

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Provides unified threat-detection, compliance, forensics and analysis through th
1111

1212
* **[Identity and Access Management](https://docs.sysdig.com/en/docs/sysdig-secure/posture/permissions-and-entitlements/)**: Analyses user access overly permissive policies. Requires both modules `cloud-connector` and `cloud-bench`. <br/>
1313

14-
* **[Image Scanning](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)**: Automatically scans all container images pushed to the registry (ECR) and the images that run on the AWS workload (currently ECS). Managed through `cloud-connector`. <br/>
14+
* **[Image Scanning](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)**: Automatically scans all container images pushed to the registry (ECR) and the images that run on the AWS workload (currently ECS). Managed through `cloud-connector`. <br/>Disabled by Default, can be enabled through `deploy_image_scanning_ecr` and `deploy_image_scanning_ecs` input variable parameters.<br/>
1515

1616
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)
1717

@@ -56,10 +56,7 @@ For other Cloud providers check: [GCP](https://github.com/sysdiglabs/terraform-g
5656
- [Single-Account with a pre-existing Kubernetes Cluster](#--single-account-with-a-pre-existing-kubernetes-cluster)
5757
- [Organizational](#--organizational)
5858
- Many module,examples and use-cases provide ways to **re-use existing resources (as optionals)** in your infrastructure (cloudtrail, ecs, vpc, k8s cluster,...)
59-
- Find some real **use-case scenario explanations** under [`/use-cases*`](./use-cases)
60-
- [Single Account - Existing Cloudtrail](use-cases/single-existing-cloudtrail.md)
61-
- [Organizational - Existing Cloudtrail, ECS, VPC, Subnet](use-cases/org-existing-cloudtrail-ecs-vpc-subnet.md)
62-
- [Organizational - Existing Cloudtrail withouth SNS, but with S3 configuration, with K8s Cluster and Filtered Cloudtrail Event Account](use-cases/org-s3-k8s-filtered-account.md)
59+
- Find some real self-baked **use-case scenarios** under [`/use-cases`](./use-cases)
6360

6461
### - Single-Account on ECS
6562

@@ -223,6 +220,10 @@ It may take some time, but you should see logs detecting the new image in the EC
223220

224221
## Troubleshooting
225222

223+
## Q-Debug: Need to troubleshoot cloud-connector with `debug` loglevel
224+
A: both in ECS and AppRunner workload types, cloud-connector configuration is passed as a base64-encoded string through the env var `CONFIG`
225+
<br/>S: Get current value, decode it, edit the desired `logging: debug` value, encode it again, and spin it again with this new definition.
226+
226227
### Q-General: Getting error "Error: cannot verify credentials" on "sysdig_secure_trusted_cloud_identity" data
227228
A: This happens when Sysdig credentials are not working correctly.
228229
<br/>S: Check sysdig provider block is correctly configured with the `sysdig_secure_url` and `sysdig_secure_api_token` variables

examples/organizational/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ Deploy Sysdig Secure for Cloud using an [AWS Organizational Cloudtrail](https://
1212
* In the **user-provided member account**
1313
* All the Sysdig Secure for Cloud service-related resources/workload will be created
1414

15+
### Notice
16+
17+
* All Sysdig Secure for Cloud features **but [Image Scanning](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)** are enabled by default. You can enable it through `deploy_image_scanning_ecr` and `deploy_image_scanning_ecs` input variable parameters.<br/><br/>
18+
* **Resource creation inventory** Find all the resources created by Sysdig examples in the resource-group `sysdig-secure-for-cloud` (AWS Resource Group & Tag Editor) <br/><br/>
19+
* **Deployment cost** This example will create resources that cost money.<br/>Run `terraform destroy` when you don't need them anymore
20+
21+
1522
![organizational diagram](https://raw.githubusercontent.com/sysdiglabs/terraform-aws-secure-for-cloud/master/examples/organizational/diagram-org.png)
1623

1724
## Prerequisites
@@ -72,11 +79,6 @@ Role usage for this example comes as follows. Check [permissions](../../README.m
7279
- if ECS workload is deployed, `ECSTaskRole` will be used to define its permissions
7380
- used by Sysdig to assumeRole on management account `SysdigSecureForCloudRole` and other organizations `OrganizationAccountAccessRole`
7481
75-
## Notice
76-
77-
* **Resource creation inventory** Find all the resources created by Sysdig examples in the resource-group `sysdig-secure-for-cloud` (AWS Resource Group & Tag Editor) <br/><br/>
78-
* **Deployment cost** This example will create resources that cost money.<br/>Run `terraform destroy` when you don't need them anymore
79-
8082
## Usage
8183
8284
For quick testing, use this snippet on your terraform files
@@ -180,8 +182,8 @@ $ terraform apply
180182
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. Used together with `cloudtrail_sns_arn`, `cloudtrail_s3_arn`. If it does not exist, it will be inferred from created cloudtrail. Providing an ARN requires permission to SNS:Subscribe, check ./modules/infrastructure/cloudtrail/sns\_permissions.tf block | `string` | `"create"` | no |
181183
| <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 |
182184
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | Whether to deploy or not the cloud benchmarking | `bool` | `true` | no |
183-
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `true` | no |
184-
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `true` | no |
185+
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
186+
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
185187
| <a name="input_ecs_cluster_name"></a> [ecs\_cluster\_name](#input\_ecs\_cluster\_name) | Name of a pre-existing ECS (elastic container service) cluster. If defaulted, a new ECS cluster/VPC/Security Group will be created. For both options, ECS location will/must be within the `sysdig_secure_for_cloud_member_account_id` parameter accountID | `string` | `"create"` | no |
186188
| <a name="input_ecs_task_cpu"></a> [ecs\_task\_cpu](#input\_ecs\_task\_cpu) | Amount of CPU (in CPU units) to reserve for cloud-connector task | `string` | `"256"` | no |
187189
| <a name="input_ecs_task_memory"></a> [ecs\_task\_memory](#input\_ecs\_task\_memory) | Amount of memory (in megabytes) to reserve for cloud-connector task | `string` | `"512"` | no |

examples/organizational/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module "cloud_connector" {
5454
providers = {
5555
aws = aws.member
5656
}
57+
5758
source = "../../modules/services/cloud-connector-ecs"
5859
name = "${var.name}-cloudconnector"
5960

@@ -89,8 +90,8 @@ module "cloud_connector" {
8990
#-------------------------------------
9091

9192
module "cloud_bench" {
92-
source = "../../modules/services/cloud-bench"
9393
count = var.deploy_benchmark ? 1 : 0
94+
source = "../../modules/services/cloud-bench"
9495

9596
name = "${var.name}-cloudbench"
9697
is_organizational = true

examples/organizational/permissions.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ resource "aws_iam_role" "connector_ecs_task" {
2727
path = "/"
2828
tags = var.tags
2929
}
30+
31+
3032
data "aws_iam_policy_document" "task_assume_role" {
3133
provider = aws.member
3234
statement {

examples/organizational/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ variable "sysdig_secure_for_cloud_member_account_id" {
88
# optionals - with defaults
99
#---------------------------------
1010

11+
1112
#
1213
# organizational
1314
#
@@ -59,13 +60,13 @@ variable "cloudtrail_kms_enable" {
5960
variable "deploy_image_scanning_ecr" {
6061
type = bool
6162
description = "true/false whether to deploy the image scanning on ECR pushed images"
62-
default = true
63+
default = false
6364
}
6465

6566
variable "deploy_image_scanning_ecs" {
6667
type = bool
6768
description = "true/false whether to deploy the image scanning on ECS running images"
68-
default = true
69+
default = false
6970
}
7071

7172

examples/single-account-apprunner/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ $ terraform apply
6666
| Name | Version |
6767
|------|---------|
6868
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
69-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0 |
7069
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.33 |
7170

7271
## Providers
@@ -99,8 +98,8 @@ $ terraform apply
9998
| <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 | `bool` | `true` | no |
10099
| <a name="input_cloudtrail_kms_enable"></a> [cloudtrail\_kms\_enable](#input\_cloudtrail\_kms\_enable) | true/false whether cloudtrail delivered events to S3 should persist encrypted | `bool` | `true` | no |
101100
| <a name="input_cloudtrail_sns_arn"></a> [cloudtrail\_sns\_arn](#input\_cloudtrail\_sns\_arn) | ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. ARN of a pre-existing cloudtrail\_sns. If defaulted, a new cloudtrail will be created. If specified, sysdig deployment account and region must match with the specified SNS | `string` | `"create"` | no |
102-
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `true` | no |
103-
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `true` | no |
101+
| <a name="input_deploy_image_scanning_ecr"></a> [deploy\_image\_scanning\_ecr](#input\_deploy\_image\_scanning\_ecr) | true/false whether to deploy the image scanning on ECR pushed images | `bool` | `false` | no |
102+
| <a name="input_deploy_image_scanning_ecs"></a> [deploy\_image\_scanning\_ecs](#input\_deploy\_image\_scanning\_ecs) | true/false whether to deploy the image scanning on ECS running images | `bool` | `false` | no |
104103
| <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 |
105104
| <a name="input_tags"></a> [tags](#input\_tags) | sysdig secure-for-cloud tags. always include 'product' default tag for resource-group proper functioning | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
106105

examples/single-account-apprunner/cloudtrail.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ locals {
44
}
55

66
module "cloudtrail" {
7-
count = local.cloudtrail_deploy ? 1 : 0
7+
count = local.cloudtrail_deploy ? 1 : 0
8+
89
source = "../../modules/infrastructure/cloudtrail"
910
name = var.name
1011
is_organizational = false

examples/single-account-apprunner/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ variable "cloudtrail_kms_enable" {
3333
variable "deploy_image_scanning_ecr" {
3434
type = bool
3535
description = "true/false whether to deploy the image scanning on ECR pushed images"
36-
default = true
36+
default = false
3737
}
3838

3939
variable "deploy_image_scanning_ecs" {
4040
type = bool
4141
description = "true/false whether to deploy the image scanning on ECS running images"
42-
default = true
42+
default = false
4343
}
4444

4545
#

0 commit comments

Comments
 (0)