Skip to content

Commit 215756a

Browse files
committed
fix: fix cspm_service_account_email variable condition
- fixing variable condition for `local.cspm_service_account_email` in `project_attachment` module - adding variable validation for `var.aqua_api_key` & `var.aqua_api_secret` in `project_attachment` module - running terraform fmt on `modules/onboarding/modules/iam/locals.tf` - update `README` in `modules/onboarding/README.md` - update `README` in `modules/org_projects/README.md`
1 parent e481833 commit 215756a

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

.github/workflows/pr-checks.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
echo "--> Running tests at $tcase"
3232
(
3333
cd $tcase || exit 1
34+
echo "Replacing <REPLACE_ME> placeholders"
35+
if [[ "$OSTYPE" == "darwin"* ]]; then
36+
sed -i '' 's/<REPLACE_ME>/dummy_value/g' *.tf
37+
else
38+
sed -i 's/<REPLACE_ME>/dummy_value/g' *.tf
39+
fi
3440
echo "Terraform Format Check"
3541
terraform fmt -check
3642
echo "Terraform Init"

modules/onboarding/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ No resources.
3737
|------|-------------|------|---------|:--------:|
3838
| <a name="input_aqua_aws_account_id"></a> [aqua\_aws\_account\_id](#input\_aqua\_aws\_account\_id) | Aqua AWS Account ID | `string` | n/a | yes |
3939
| <a name="input_aqua_bucket_name"></a> [aqua\_bucket\_name](#input\_aqua\_bucket\_name) | Aqua Bucket Name | `string` | n/a | yes |
40-
| <a name="input_aqua_tenant_id"></a> [aqua\_tenant\_id](#input\_aqua\_tenant\_id) | Aqua Tenant ID | `string` | n/a | yes |
4140
| <a name="input_aqua_volscan_api_token"></a> [aqua\_volscan\_api\_token](#input\_aqua\_volscan\_api\_token) | Aqua Volume Scanning API Token | `string` | n/a | yes |
4241
| <a name="input_aqua_volscan_api_url"></a> [aqua\_volscan\_api\_url](#input\_aqua\_volscan\_api\_url) | Aqua Volume Scanning API URL | `string` | n/a | yes |
4342
| <a name="input_create_network"></a> [create\_network](#input\_create\_network) | Toggle to create network resources | `bool` | n/a | yes |

modules/onboarding/modules/iam/locals.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ locals {
1212
cspm_role_id = var.type == "organization" && var.dedicated_project ? google_organization_iam_custom_role.cspm_role[0].id : null
1313

1414
# Defining service account emails
15-
cspm_service_account_email = var.type == "organization" && var.dedicated_project ? (var.create_service_account ? google_service_account.cspm_service_account[0].email : data.google_service_account.cspm_service_account[0].email) : null
16-
service_account_email = var.create_service_account ? google_service_account.service_account[0].email : data.google_service_account.service_account[0].email
15+
cspm_service_account_email = var.type == "organization" && var.dedicated_project ? (var.create_service_account ? google_service_account.cspm_service_account[0].email : data.google_service_account.cspm_service_account[0].email) : null
16+
service_account_email = var.create_service_account ? google_service_account.service_account[0].email : data.google_service_account.service_account[0].email
1717
}

modules/org_projects/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
---
44

5-
This Terraform module retrieves information about the Google Cloud Platform (GCP) organization. It fetches all project IDs, including projects nested under folders, and allows the use of regex patterns to exclude specific project IDs or project names. Note that the GCP Cloud Asset API must be enabled on the project specified in the provider block passed to this module.
5+
This Terraform module retrieves information about the Google Cloud Platform (GCP) organization. It fetches all project IDs, including projects nested under folders, and allows the use of regex patterns to exclude specific project IDs or project names. Note that the GCP Cloud Asset API and the Cloud Resource Manager API must be enabled on the project specified in the provider block passed to this module.
66

77

88
<!-- BEGIN_TF_DOCS -->
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# modules/project_attachment/locals.tf
22

33
locals {
4-
cspm_role_permissions = var.type == "single" ? yamldecode(data.http.autoconnect_cspm_role_yaml[0].response_body).includedPermissions : null
5-
cspm_service_account_name = var.cspm_service_account_name != null ? var.cspm_service_account_name : "aqua-cspm-scanner-${var.aqua_tenant_id}"
6-
cspm_service_account_email = var.create_service_account ? google_service_account.cspm_service_account[0].email : data.google_service_account.cspm_service_account[0].email
7-
service_account_key = var.type == "organization" || (!var.create_service_account && var.type == "single") ? base64decode(nonsensitive(var.onboarding_cspm_service_account_key)) : base64decode(google_service_account_key.cspm_service_account_key[0].private_key)
8-
client_config_rendered = replace(jsonencode(local.client_config), "/\\\\u0026/", "&")
9-
api_services = var.type == "single" ? ["cloudresourcemanager.googleapis.com", "iam.googleapis.com", "compute.googleapis.com"] : ["cloudresourcemanager.googleapis.com", "storage.googleapis.com", "compute.googleapis.com"]
4+
cspm_role_permissions = var.type == "single" ? yamldecode(data.http.autoconnect_cspm_role_yaml[0].response_body).includedPermissions : null
5+
cspm_service_account_name = var.cspm_service_account_name != null ? var.cspm_service_account_name : "aqua-cspm-scanner-${var.aqua_tenant_id}"
6+
cspm_service_account_email = var.type == "single" ? (var.create_service_account ? google_service_account.cspm_service_account[0].email : data.google_service_account.cspm_service_account[0].email) : null
7+
service_account_key = var.type == "organization" || (!var.create_service_account && var.type == "single") ? base64decode(nonsensitive(var.onboarding_cspm_service_account_key)) : base64decode(google_service_account_key.cspm_service_account_key[0].private_key)
8+
client_config_rendered = replace(jsonencode(local.client_config), "/\\\\u0026/", "&")
9+
api_services = var.type == "single" ? ["cloudresourcemanager.googleapis.com", "iam.googleapis.com", "compute.googleapis.com"] : ["cloudresourcemanager.googleapis.com", "storage.googleapis.com", "compute.googleapis.com"]
1010
}

modules/project_attachment/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ variable "aqua_api_key" {
6969
condition = length(var.aqua_api_key) > 0
7070
error_message = "Aqua API key must not be empty"
7171
}
72+
validation {
73+
condition = var.aqua_api_key != "<REPLACE_ME>"
74+
error_message = "Aqua API key must be replaced from its default value of <REPLACE_ME>"
75+
}
7276
}
7377

7478
variable "aqua_api_secret" {
@@ -78,6 +82,10 @@ variable "aqua_api_secret" {
7882
condition = length(var.aqua_api_secret) > 0
7983
error_message = "Aqua API secret must not be empty"
8084
}
85+
validation {
86+
condition = var.aqua_api_secret != "<REPLACE_ME>"
87+
error_message = "Aqua API secret must be replaced from its default value of <REPLACE_ME>"
88+
}
8189
}
8290

8391
variable "aqua_autoconnect_url" {

0 commit comments

Comments
 (0)