Skip to content

Commit e86cfd8

Browse files
author
Alex Qiu
authored
feat: enable benchmark on organizational management account (#58)
* create option to deploy in mgmt acc * chore: fix pre-commit docs * chore: add ci changes from WIP PR * update required sysdig provider * chore: doc lint
1 parent 12f6179 commit e86cfd8

File tree

11 files changed

+34
-26
lines changed

11 files changed

+34
-26
lines changed

examples-internal/organizational-k8s-threat-reuse_cloudtrail_s3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Notice that:
8181

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

8787
## Modules

examples/organizational/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
Deploy Sysdig Secure for Cloud using an Organizational Cloudtrail that will fetch events from all organization member accounts (and the managed one too).
44

55
* In the **management account**
6-
* An Organizational Cloutrail will be deployed (with required S3,SNS)
7-
* An additional role `SysdigSecureForCloudRole` will be created
8-
* to be able to read cloudtrail-s3 bucket events from sysdig workload member account.
9-
* will also be used to asummeRole over other roles, and enable the process of scanning on ECR's that may be present in other member accounts.
6+
* An Organizational Cloutrail will be deployed (with required S3,SNS)
7+
* An additional role `SysdigSecureForCloudRole` will be created
8+
* to be able to read cloudtrail-s3 bucket events from sysdig workload member account.
9+
* will also be used to asummeRole over other roles, and enable the process of scanning on ECR's that may be present in other member accounts.
1010
* In the **user-provided member account**
1111
* All the Sysdig Secure for Cloud service-related resources/workload will be created
1212

@@ -24,7 +24,7 @@ Minimum requirements:
2424
> You must be logged in with the management account for the organization to create an organization trail. You must also have sufficient permissions for the IAM user or role in the management account to successfully create an organization trail.
2525
* When an account is created within an organization, AWS will create an `OrganizationAccountAccessRole` [for account management](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html), which Sysdig Secure for Cloud will use for member-account provisioning and role assuming.
2626
* However, when the account is invited into the organization, it's required to [create the role manually](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html#orgs_manage_accounts_create-cross-account-role)
27-
> You have to do this manually, as shown in the following procedure. This essentially duplicates the role automatically set up for created accounts. We recommend that you use the same name, OrganizationAccountAccessRole, for your manually created roles for consistency and ease of remembering.
27+
> You have to do this manually, as shown in the following procedure. This essentially duplicates the role automatically set up for created accounts. We recommend that you use the same name, OrganizationAccountAccessRole, for your manually created roles for consistency and ease of remembering.
2828
* This role name, `OrganizationAccountAccessRole`, is currently hardcoded on the module.
2929
3. Provide a member **account ID for Sysdig Secure for Cloud workload** to be deployed.
3030
Our recommendation is for this account to be empty, so that deployed resources are not mixed up with your workload.
@@ -75,14 +75,14 @@ Notice that:
7575
|------|---------|
7676
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
7777
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.62.0 |
78-
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.19 |
78+
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
7979

8080
## Providers
8181

8282
| Name | Version |
8383
|------|---------|
84-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.0 |
85-
| <a name="provider_aws.member"></a> [aws.member](#provider\_aws.member) | 3.74.0 |
84+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
85+
| <a name="provider_aws.member"></a> [aws.member](#provider\_aws.member) | 3.74.1 |
8686

8787
## Modules
8888

examples/organizational/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
}
77
sysdig = {
88
source = "sysdiglabs/sysdig"
9-
version = ">= 0.5.19"
9+
version = ">= 0.5.29"
1010
}
1111
}
1212
}

examples/single-account-k8s/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ Notice that:
6666
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
6767
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.50.0 |
6868
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >=2.3.0 |
69-
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.19 |
69+
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
7070

7171
## Providers
7272

7373
| Name | Version |
7474
|------|---------|
75-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.0 |
75+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.74.1 |
7676
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.4.1 |
7777

7878
## Modules

examples/single-account-k8s/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
}
77
sysdig = {
88
source = "sysdiglabs/sysdig"
9-
version = ">= 0.5.19"
9+
version = ">= 0.5.29"
1010
}
1111
helm = {
1212
source = "hashicorp/helm"

examples/single-account/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ provider "aws" {
2525
}
2626
2727
module "secure_for_cloud_aws_single_account" {
28-
source = "sysdiglabs/secure-for-cloud/aws//examples/single-account"
28+
source = "sysdiglabs/secure-for-cloud/aws//examples/single-account"
2929
30-
sysdig_secure_api_token = "00000000-1111-2222-3333-444444444444"
30+
sysdig_secure_api_token = "00000000-1111-2222-3333-444444444444"
3131
}
3232
```
3333

@@ -51,7 +51,7 @@ Notice that:
5151
|------|---------|
5252
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
5353
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.62.0 |
54-
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.21 |
54+
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
5555

5656
## Providers
5757

examples/single-account/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terraform {
66
}
77
sysdig = {
88
source = "sysdiglabs/sysdig"
9-
version = ">= 0.5.21"
9+
version = ">= 0.5.29"
1010
}
1111
}
1212
}

modules/services/cloud-bench/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ Deployed on **Sysdig Backend**
2020
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.15.0 |
2121
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.62.0 |
2222
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.1.0 |
23-
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.21 |
23+
| <a name="requirement_sysdig"></a> [sysdig](#requirement\_sysdig) | >= 0.5.29 |
2424

2525
## Providers
2626

2727
| Name | Version |
2828
|------|---------|
2929
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.62.0 |
3030
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.1.0 |
31-
| <a name="provider_sysdig"></a> [sysdig](#provider\_sysdig) | >= 0.5.21 |
31+
| <a name="provider_sysdig"></a> [sysdig](#provider\_sysdig) | >= 0.5.29 |
3232

3333
## Modules
3434

@@ -59,6 +59,7 @@ No modules.
5959
| <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 |
6060
| <a name="input_is_organizational"></a> [is\_organizational](#input\_is\_organizational) | whether secure-for-cloud should be deployed in an organizational setup | `bool` | `false` | no |
6161
| <a name="input_name"></a> [name](#input\_name) | The name of the IAM Role that will be created. | `string` | `"sfc-cloudbench"` | no |
62+
| <a name="input_provision_in_management_account"></a> [provision\_in\_management\_account](#input\_provision\_in\_management\_account) | Whether to deploy the stack in the management account | `bool` | `true` | no |
6263
| <a name="input_region"></a> [region](#input\_region) | Default region for resource creation in organization mode | `string` | `"eu-central-1"` | no |
6364
| <a name="input_tags"></a> [tags](#input\_tags) | sysdig secure-for-cloud tags | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
6465

modules/services/cloud-bench/main.tf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ data "sysdig_secure_trusted_cloud_identity" "trusted_identity" {
1313
}
1414

1515
locals {
16-
member_account_ids = var.is_organizational ? [for a in data.aws_organizations_organization.org[0].non_master_accounts : a.id] : []
16+
member_account_ids = var.is_organizational ? [for a in data.aws_organizations_organization.org[0].non_master_accounts : a.id] : []
17+
account_ids_to_deploy = var.is_organizational && var.provision_in_management_account ? concat(local.member_account_ids, [data.aws_organizations_organization.org[0].master_account_id]) : local.member_account_ids
1718

1819
benchmark_task_name = var.is_organizational ? "Organization: ${data.aws_organizations_organization.org[0].id}" : data.aws_caller_identity.me.account_id
19-
accounts_scope_clause = var.is_organizational ? "aws.accountId in (\"${join("\", \"", local.member_account_ids)}\")" : "aws.accountId = \"${data.aws_caller_identity.me.account_id}\""
20+
accounts_scope_clause = var.is_organizational ? "aws.accountId in (\"${join("\", \"", local.account_ids_to_deploy)}\")" : "aws.accountId = \"${data.aws_caller_identity.me.account_id}\""
2021
regions_scope_clause = length(var.benchmark_regions) == 0 ? "" : " and aws.region in (\"${join("\", \"", var.benchmark_regions)}\")"
2122
}
2223

@@ -25,7 +26,7 @@ locals {
2526
#----------------------------------------------------------
2627

2728
resource "sysdig_secure_cloud_account" "cloud_account" {
28-
for_each = var.is_organizational ? toset(local.member_account_ids) : [data.aws_caller_identity.me.account_id]
29+
for_each = var.is_organizational ? toset(local.account_ids_to_deploy) : [data.aws_caller_identity.me.account_id]
2930

3031
account_id = each.value
3132
cloud_provider = "aws"
@@ -35,7 +36,7 @@ resource "sysdig_secure_cloud_account" "cloud_account" {
3536

3637
locals {
3738
external_id = try(
38-
sysdig_secure_cloud_account.cloud_account[local.member_account_ids[0]].external_id,
39+
sysdig_secure_cloud_account.cloud_account[local.account_ids_to_deploy[0]].external_id,
3940
sysdig_secure_cloud_account.cloud_account[data.aws_caller_identity.me.account_id].external_id,
4041
)
4142
}
@@ -90,7 +91,7 @@ data "aws_iam_policy_document" "trust_relationship" {
9091
}
9192

9293
resource "aws_iam_role" "cloudbench_role" {
93-
count = var.is_organizational ? 0 : 1
94+
count = var.is_organizational && !var.provision_in_management_account ? 0 : 1
9495

9596
name = var.name
9697
assume_role_policy = data.aws_iam_policy_document.trust_relationship.json
@@ -99,7 +100,7 @@ resource "aws_iam_role" "cloudbench_role" {
99100

100101

101102
resource "aws_iam_role_policy_attachment" "cloudbench_security_audit" {
102-
count = var.is_organizational ? 0 : 1
103+
count = var.is_organizational && !var.provision_in_management_account ? 0 : 1
103104

104105
role = aws_iam_role.cloudbench_role[0].id
105106
policy_arn = data.aws_iam_policy.security_audit.arn

modules/services/cloud-bench/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ variable "tags" {
3434
"product" = "sysdig-secure-for-cloud"
3535
}
3636
}
37+
38+
variable "provision_in_management_account" {
39+
type = bool
40+
default = true
41+
description = "Whether to deploy the stack in the management account"
42+
}

modules/services/cloud-bench/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ terraform {
1111
}
1212
sysdig = {
1313
source = "sysdiglabs/sysdig"
14-
version = ">= 0.5.21"
14+
version = ">= 0.5.29"
1515
}
1616
}
1717
}

0 commit comments

Comments
 (0)