Skip to content

Commit 775a02e

Browse files
Feat: Surface region and name in benchmark examples (#28)
* feat(bench): surface region and name in benchmark examples
1 parent 9e36114 commit 775a02e

File tree

8 files changed

+32
-7
lines changed

8 files changed

+32
-7
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ module "cloud_bench" {
1616

1717
account_id = data.aws_caller_identity.me.account_id
1818
tags = var.tags
19+
regions = var.benchmark_regions
20+
name = "${var.name}-cloudbench"
1921
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ variable "tags" {
3131
"product" = "sysdig-secure-for-cloud"
3232
}
3333
}
34+
35+
variable "benchmark_regions" {
36+
type = list(string)
37+
description = "List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default."
38+
default = []
39+
}
40+
41+
variable "name" {
42+
type = string
43+
description = "Name for the Cloud Vision deployment"
44+
default = "sysdig-secure-for-cloud"
45+
}

examples/single-account/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Notice that:
8080
| Name | Description | Type | Default | Required |
8181
|------|-------------|------|---------|:--------:|
8282
| <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 |
83+
| <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 |
8384
| <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 |
8485
| <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 |
8586
| <a name="input_name"></a> [name](#input\_name) | Name for the Cloud Vision deployment | `string` | `"sysdig-secure-for-cloud"` | no |

examples/single-account/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,6 @@ module "cloud_bench" {
113113

114114
account_id = data.aws_caller_identity.me.account_id
115115
tags = var.tags
116+
regions = var.benchmark_regions
117+
name = "${var.name}-cloudbench"
116118
}

examples/single-account/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ variable "tags" {
5454
"product" = "sysdig-secure-for-cloud"
5555
}
5656
}
57+
58+
variable "benchmark_regions" {
59+
type = list(string)
60+
description = "List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default."
61+
default = []
62+
}

modules/services/cloud-bench/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ No modules.
4444
| Name | Description | Type | Default | Required |
4545
|------|-------------|------|---------|:--------:|
4646
| <a name="input_account_id"></a> [account\_id](#input\_account\_id) | the account\_id in which to provision the cloud-bench IAM role | `string` | n/a | yes |
47+
| <a name="input_name"></a> [name](#input\_name) | The name of the IAM Role that will be created. | `string` | `"SysdigCloudBench"` | no |
4748
| <a name="input_regions"></a> [regions](#input\_regions) | List of regions in which to run the benchmark. If empty, the task will contain all aws regions by default. | `list(string)` | `[]` | no |
48-
| <a name="input_role_name"></a> [role\_name](#input\_role\_name) | The name of the IAM Role that will be created. | `string` | `"SysdigCloudBench"` | no |
4949
| <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 |
5050

5151
## Outputs

modules/services/cloud-bench/main.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "sysdig_secure_cloud_account" "cloud_account" {
55
account_id = var.account_id
66
cloud_provider = "aws"
77
role_enabled = "true"
8-
role_name = var.role_name
8+
role_name = var.name
99
}
1010

1111
data "sysdig_secure_trusted_cloud_identity" "trusted_identity" {
@@ -23,15 +23,19 @@ resource "sysdig_secure_benchmark_task" "benchmark_task" {
2323
scope = "aws.accountId = \"${var.account_id}\"${local.regions_scope_clause}"
2424

2525
# Creation of a task requires that the Cloud Account already exists in the backend, and has `role_enabled = true`
26-
depends_on = [sysdig_secure_cloud_account.cloud_account]
26+
# We only want to create the task once the rust relationship is established, otherwise running the task will fail.
27+
depends_on = [
28+
sysdig_secure_cloud_account.cloud_account,
29+
aws_iam_role_policy_attachment.cloudbench_security_audit, # Depends on cloudbench_role implicitly
30+
]
2731
}
2832

2933
#
3034
# aws role provisioning
3135
#
3236

3337
resource "aws_iam_role" "cloudbench_role" {
34-
name = var.role_name
38+
name = var.name
3539
assume_role_policy = data.aws_iam_policy_document.trust_relationship.json
3640
tags = var.tags
3741
}
@@ -52,8 +56,6 @@ data "aws_iam_policy_document" "trust_relationship" {
5256
}
5357
}
5458

55-
56-
5759
resource "aws_iam_role_policy_attachment" "cloudbench_security_audit" {
5860
role = aws_iam_role.cloudbench_role.id
5961
policy_arn = data.aws_iam_policy.security_audit.arn

modules/services/cloud-bench/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variable "account_id" {
77
# optionals - with default
88
#---------------------------------
99

10-
variable "role_name" {
10+
variable "name" {
1111
type = string
1212
description = "The name of the IAM Role that will be created."
1313
default = "SysdigCloudBench"

0 commit comments

Comments
 (0)