Skip to content

Commit 4279ce8

Browse files
author
iru
authored
refactor: avoid benchmark role collision with var.name (#132)
* chore: add var.name to benchmark role to avoid collision * chore: add var.name to benchmark role to avoid collision * docs: clarify var.name usage * fix: test. tflint download * ci: tfdocs
1 parent 295742c commit 4279ce8

File tree

11 files changed

+40
-33
lines changed

11 files changed

+40
-33
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
deps:
22
go install github.com/terraform-docs/terraform-docs@v0.16.0
33
go install github.com/hashicorp/terraform-config-inspect@latest
4-
curl -L "`curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip"`" -o tflint.zip && \
4+
5+
# not working- fixme
6+
# curl -L "`curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip"`" -o tflint.zip && \
7+
8+
curl -L https://github.com/terraform-linters/tflint/releases/download/v0.44.1/tflint_linux_amd64.zip -o tflint.zip && \
59
unzip tflint.zip && \
610
rm tflint.zip && \
711
mv tflint "`go env GOPATH`/bin"

examples/organization/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ module "secure-for-cloud_example_organization" {
143143
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | whether benchmark module is to be deployed | `bool` | `true` | no |
144144
| <a name="input_deploy_scanning"></a> [deploy\_scanning](#input\_deploy\_scanning) | true/false whether scanning module is to be deployed | `bool` | `false` | no |
145145
| <a name="input_max_instances"></a> [max\_instances](#input\_max\_instances) | Max number of instances for the workloads | `number` | `1` | no |
146-
| <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 |
146+
| <a name="input_name"></a> [name](#input\_name) | Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues | `string` | `"sfc"` | no |
147147
| <a name="input_repository_project_ids"></a> [repository\_project\_ids](#input\_repository\_project\_ids) | Projects were a `gcr`-named topic will be to subscribe to its repository events. If empty, all organization projects will be defaulted. | `list(string)` | `[]` | no |
148148

149149
## Outputs

examples/organization/benchmark.tf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
locals {
2+
benchmark_projects_ids = length(var.benchmark_project_ids) == 0 ? [for p in data.google_projects.all_projects.projects : p.project_id] : var.benchmark_project_ids
3+
}
4+
5+
module "cloud_bench" {
6+
providers = {
7+
google = google.multiproject
8+
google-beta = google-beta.multiproject
9+
}
10+
11+
count = var.deploy_benchmark ? 1 : 0
12+
source = "../../modules/services/cloud-bench"
13+
14+
is_organizational = true
15+
organization_domain = var.organization_domain
16+
role_name = "${var.name}${var.benchmark_role_name}"
17+
regions = var.benchmark_regions
18+
project_ids = local.benchmark_projects_ids
19+
}

examples/organization/main.tf

-25
Original file line numberDiff line numberDiff line change
@@ -110,28 +110,3 @@ module "pubsub_http_subscription" {
110110
push_to_cloudrun = true
111111
deploy_scanning = var.deploy_scanning
112112
}
113-
114-
115-
#--------------------
116-
# benchmark
117-
#--------------------
118-
119-
locals {
120-
benchmark_projects_ids = length(var.benchmark_project_ids) == 0 ? [for p in data.google_projects.all_projects.projects : p.project_id] : var.benchmark_project_ids
121-
}
122-
123-
module "cloud_bench" {
124-
providers = {
125-
google = google.multiproject
126-
google-beta = google-beta.multiproject
127-
}
128-
129-
count = var.deploy_benchmark ? 1 : 0
130-
source = "../../modules/services/cloud-bench"
131-
132-
is_organizational = true
133-
organization_domain = var.organization_domain
134-
role_name = var.benchmark_role_name
135-
regions = var.benchmark_regions
136-
project_ids = local.benchmark_projects_ids
137-
}

examples/organization/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ variable "benchmark_role_name" {
6565
#
6666
variable "name" {
6767
type = string
68-
description = "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"
68+
description = "Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues"
6969
default = "sfc"
7070

7171
validation {

examples/single-project-k8s/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ See [inputs summary](#inputs) or module module [`variables.tf`](./variables.tf)
116116
| <a name="input_cloud_connector_image"></a> [cloud\_connector\_image](#input\_cloud\_connector\_image) | Cloud-connector image to deploy | `string` | `"quay.io/sysdig/cloud-connector"` | no |
117117
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | whether benchmark module is to be deployed | `bool` | `true` | no |
118118
| <a name="input_deploy_scanning"></a> [deploy\_scanning](#input\_deploy\_scanning) | true/false whether scanning module is to be deployed | `bool` | `false` | no |
119-
| <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 |
119+
| <a name="input_name"></a> [name](#input\_name) | Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues | `string` | `"sfc"` | no |
120120

121121
## Outputs
122122

examples/single-project-k8s/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ variable "benchmark_role_name" {
3232
# general
3333
variable "name" {
3434
type = string
35-
description = "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"
35+
description = "Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues"
3636
default = "sfc"
3737

3838
validation {

examples/single-project/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ module "secure-for-cloud_example_single-project" {
112112
| <a name="input_benchmark_role_name"></a> [benchmark\_role\_name](#input\_benchmark\_role\_name) | The name of the Service Account that will be created. | `string` | `"sysdigcloudbench"` | no |
113113
| <a name="input_deploy_benchmark"></a> [deploy\_benchmark](#input\_deploy\_benchmark) | whether benchmark module is to be deployed | `bool` | `true` | no |
114114
| <a name="input_deploy_scanning"></a> [deploy\_scanning](#input\_deploy\_scanning) | true/false whether scanning module is to be deployed | `bool` | `false` | no |
115-
| <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 |
115+
| <a name="input_name"></a> [name](#input\_name) | Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues | `string` | `"sfc"` | no |
116116

117117
## Outputs
118118

examples/single-project/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ variable "benchmark_role_name" {
3737
#
3838
variable "name" {
3939
type = string
40-
description = "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"
40+
description = "Suffix to be assigned to all created resources. Modify this value in case of conflict / 409 error to bypass Google soft delete issues"
4141
default = "sfc"
4242

4343
validation {

modules/services/cloud-bench/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Cloud Bench deploy for GCP
2+
3+
Deployed on the **target GCP account(s)**:
4+
- The required Workload Identity Pool + Provider + Service Account, to allow Sysdig to run GCP Benchmarks on your behalf.
5+
6+
Deployed on **Sysdig Backend**
7+
- An `gcp_foundations_bench-1.2.0` benchmark task schedule on a random hour of the day `rand rand * * *`
8+
- coped to the configured `gcp.projectId` and `gcp.region`
9+
110
<!-- BEGIN_TF_DOCS -->
211
## Requirements
312

modules/services/cloud-bench/variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variable "regions" {
66

77
variable "role_name" {
88
type = string
9-
description = "The name of the Service Account that will be created."
9+
description = "The name of the Service Account/Role that will be created. Modify this value in case of conflict / 409 error to bypass Google soft delete"
1010
default = "sysdigcloudbench"
1111
}
1212

0 commit comments

Comments
 (0)