Skip to content

Commit a4ea938

Browse files
authored
fix!: use SCC v2 resources (#1432)
1 parent 72fec83 commit a4ea938

File tree

21 files changed

+1723
-295
lines changed

21 files changed

+1723
-295
lines changed

0-bootstrap/README-GitHub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ See the shared folder [README.md](../1-org/envs/shared/README.md#inputs) for add
360360
```bash
361361
export ORG_STEP_SA=$(terraform -chdir="../gcp-bootstrap/envs/shared" output -raw organization_step_terraform_service_account_email)
362362
363-
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --impersonate-service-account=${ORG_STEP_SA}
363+
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --location=global --impersonate-service-account=${ORG_STEP_SA}
364364
```
365365

366366
1. If the notification exists the output will be:

0-bootstrap/README-GitLab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ See the shared folder [README.md](../1-org/envs/shared/README.md#inputs) for add
417417
```bash
418418
export ORG_STEP_SA=$(terraform -chdir="../gcp-bootstrap/envs/shared" output -raw organization_step_terraform_service_account_email)
419419
420-
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --impersonate-service-account=${ORG_STEP_SA}
420+
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --location=global --impersonate-service-account=${ORG_STEP_SA}
421421
```
422422

423423
1. If the notification exists the output will be:

0-bootstrap/README-Jenkins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ Here you will configure a VPN Network tunnel to enable connectivity between the
397397

398398
```bash
399399
export ORGANIZATION_ID=$(terraform -chdir="../gcp-bootstrap/envs/shared" output -json common_config | jq '.org_id' --raw-output)
400-
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID}
400+
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID} --location=global
401401
```
402402

403403
1. Check if your organization already has an Access Context Manager Policy.

0-bootstrap/README-Terraform-Cloud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ See the shared folder [README.md](../1-org/envs/shared/README.md#inputs) for add
329329
```bash
330330
export ORG_STEP_SA=$(terraform -chdir="../gcp-bootstrap/envs/shared" output -raw organization_step_terraform_service_account_email)
331331
332-
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --impersonate-service-account=${ORG_STEP_SA}
332+
gcloud scc notifications describe "scc-notify" --format="value(name)" --organization=${ORGANIZATION_ID} --location=global --impersonate-service-account=${ORG_STEP_SA}
333333
```
334334

335335
1. If the notification exists the output will be:

1-org/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ If required, run `terraform output cloudbuild_project_id` in the `0-bootstrap` f
145145

146146
```bash
147147
export ORGANIZATION_ID=$(terraform -chdir="../terraform-example-foundation/0-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
148-
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID}
148+
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID} --location=global
149149
```
150150

151151
1. Check if your organization already has an Access Context Manager policy.
@@ -239,7 +239,7 @@ Create `gcp-org` folder, copy `1-org` content and Terraform wrapper script; ensu
239239

240240
```bash
241241
export ORGANIZATION_ID=$(terraform -chdir="../gcp-bootstrap/" output -json common_config | jq '.org_id' --raw-output)
242-
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID}
242+
gcloud scc notifications describe "scc-notify" --organization=${ORGANIZATION_ID} --location=global
243243
```
244244

245245
1. Check if your organization already has an Access Context Manager policy.

1-org/envs/shared/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| domains\_to\_allow | The list of domains to allow users from in IAM. Used by Domain Restricted Sharing Organization Policy. Must include the domain of the organization you are deploying the foundation. To add other domains you must also grant access to these domains to the Terraform Service Account used in the deploy. | `list(string)` | n/a | yes |
1010
| enable\_hub\_and\_spoke | Enable Hub-and-Spoke architecture. | `bool` | `false` | no |
1111
| enable\_kms\_key\_usage\_tracking | Enable KMS centralized key usage tracking system. | `bool` | `true` | no |
12-
| enable\_scc\_resources\_in\_terraform | Create Security Command Center resources in Terraform. If your organization has newly enabled any preview features for SCC and get an error related to the v2 API, you must set this variable to false because the v2 API does not yet support Terraform resources. See [issue 1189](https://github.com/terraform-google-modules/terraform-example-foundation/issues/1189) for context. | `bool` | `false` | no |
12+
| enable\_scc\_resources\_in\_terraform | Create Security Command Center resources in Terraform. Security Command Center must be activated before the creation of the resources. See [Overview of activating Security Command Center](https://cloud.google.com/security-command-center/docs/activate-scc-overview) before enabling this feature. | `bool` | `false` | no |
1313
| enforce\_allowed\_worker\_pools | Whether to enforce the organization policy restriction on allowed worker pools for Cloud Build. | `bool` | `false` | no |
1414
| essential\_contacts\_domains\_to\_allow | The list of domains that email addresses added to Essential Contacts can have. | `list(string)` | n/a | yes |
1515
| essential\_contacts\_language | Essential Contacts preferred language for notifications, as a ISO 639-1 language code. See [Supported languages](https://cloud.google.com/resource-manager/docs/managing-notification-contacts#supported-languages) for a list of supported languages. | `string` | `"en"` | no |
@@ -23,7 +23,7 @@
2323
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
2424
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
2525
| scc\_notification\_filter | Filter used to create the Security Command Center Notification, you can see more details on how to create filters in https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications#create-filter | `string` | `"state = \"ACTIVE\""` | no |
26-
| scc\_notification\_name | Name of the Security Command Center Notification. It must be unique in the organization. Run `gcloud scc notifications describe <scc_notification_name> --organization=org_id` to check if it already exists. | `string` | n/a | yes |
26+
| scc\_notification\_name | Name of the Security Command Center Notification. It must be unique in the organization. Run `gcloud scc notifications describe <scc_notification_name> --organization=org_id --location=global` to check if it already exists. | `string` | n/a | yes |
2727
| tfc\_org\_name | Name of the TFC organization | `string` | `""` | no |
2828

2929
## Outputs

1-org/envs/shared/scc_notification.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ resource "google_pubsub_subscription" "scc_notification_subscription" {
3131
project = module.scc_notifications.project_id
3232
}
3333

34-
resource "google_scc_notification_config" "scc_notification_config" {
34+
resource "google_scc_v2_organization_notification_config" "scc_notification_config" {
3535
count = var.enable_scc_resources_in_terraform ? 1 : 0
3636
config_id = var.scc_notification_name
3737
organization = local.org_id

1-org/envs/shared/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ variable "enable_hub_and_spoke" {
2121
}
2222

2323
variable "enable_scc_resources_in_terraform" {
24-
description = "Create Security Command Center resources in Terraform. If your organization has newly enabled any preview features for SCC and get an error related to the v2 API, you must set this variable to false because the v2 API does not yet support Terraform resources. See [issue 1189](https://github.com/terraform-google-modules/terraform-example-foundation/issues/1189) for context."
24+
description = "Create Security Command Center resources in Terraform. Security Command Center must be activated before the creation of the resources. See [Overview of activating Security Command Center](https://cloud.google.com/security-command-center/docs/activate-scc-overview) before enabling this feature."
2525
type = bool
2626
default = false
2727
}
@@ -38,7 +38,7 @@ variable "domains_to_allow" {
3838
}
3939

4040
variable "scc_notification_name" {
41-
description = "Name of the Security Command Center Notification. It must be unique in the organization. Run `gcloud scc notifications describe <scc_notification_name> --organization=org_id` to check if it already exists."
41+
description = "Name of the Security Command Center Notification. It must be unique in the organization. Run `gcloud scc notifications describe <scc_notification_name> --organization=org_id --location=global` to check if it already exists."
4242
type = string
4343
}
4444

1-org/modules/cai-monitoring/function-source/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const uuid4 = require('uuid4')
2121
const moment = require('moment')
2222

2323
// SCC client
24-
const { SecurityCenterClient } = require('@google-cloud/security-center');
24+
const { SecurityCenterClient } = require('@google-cloud/security-center').v2;
2525
const client = new SecurityCenterClient();
2626

2727
// Environment variables

0 commit comments

Comments
 (0)