Skip to content

Commit c682701

Browse files
author
Néstor Salceda
authored
refactor: Use project ID instead of project name (#34)
* refactor(examples/single-account): Use project ID instead of project names https://registry.terraform.io/providers/hashicorp/google/latest/docs * refactor: Use project id's instead of name
1 parent 62fadef commit c682701

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

examples/organization/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ This example deploys Cloud Connector into a GCP organizational GCP account.
4444
| <a name="input_create_gcr_topic"></a> [create\_gcr\_topic](#input\_create\_gcr\_topic) | Deploys a PubSub topic called `gcr` as part of this stack, which is needed for GCR scanning. Set to `true` only if it doesn't exist yet. If this is not deployed, and no existing `gcr` topic is found, the GCR scanning is ommited and won't be deployed. For more info see [GCR PubSub topic](https://cloud.google.com/container-registry/docs/configuring-notifications#create_a_topic). | `bool` | `true` | no |
4545
| <a name="input_location"></a> [location](#input\_location) | Zone where the stack will be deployed | `string` | `"us-central1"` | no |
4646
| <a name="input_max_instances"></a> [max\_instances](#input\_max\_instances) | Max number of instances for the workloads | `number` | `1` | no |
47-
| <a name="input_naming_prefix"></a> [naming\_prefix](#input\_naming\_prefix) | Naming prefix for all the resources created | `string` | `"sfc"` | no |
48-
| <a name="input_org_project_name"></a> [org\_project\_name](#input\_org\_project\_name) | Google cloud project name | `string` | n/a | yes |
47+
| <a name="input_naming_prefix"></a> [naming\_prefix](#input\_naming\_prefix) | Naming prefix for all the resources created | `string` | `"secure-for-cloud"` | no |
48+
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project ID | `string` | n/a | yes |
4949
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig's Secure API Token | `string` | n/a | yes |
5050
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
5151

examples/organization/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ EOT
99
}
1010

1111
provider "google" {
12-
project = var.org_project_name
12+
project = var.project_id
1313
region = var.location
1414
}
1515

1616
data "google_project" "project" {
17-
project_id = var.org_project_name
17+
project_id = var.project_id
1818
}
1919

2020
#######################
@@ -51,15 +51,15 @@ module "cloud_connector" {
5151
# SCANNING #
5252
#######################
5353
resource "google_service_account" "scanning_sa" {
54-
account_id = "${var.naming_prefix}-cloud-connector"
55-
display_name = "Service account for cloud-connector"
54+
account_id = "${var.naming_prefix}-cloud-scanning"
55+
display_name = "Service account for cloud-scanning"
5656
}
5757

5858

5959
resource "google_organization_iam_custom_role" "org_gcr_image_puller" {
6060
org_id = data.google_project.project.org_id
6161

62-
role_id = "sysdig_gcr_image_puller"
62+
role_id = "${var.naming_prefix}_gcr_image_puller"
6363
title = "Sysdig GCR Image Puller"
6464
description = "Allows pulling GCR images from all accounts in the organization"
6565
permissions = ["storage.objects.get", "storage.objects.list"]

examples/organization/variables.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ variable "sysdig_secure_api_token" {
44
description = "Sysdig's Secure API Token"
55
}
66

7-
variable "org_project_name" {
7+
variable "project_id" {
88
type = string
9-
description = "Google cloud project name"
9+
description = "Project ID"
1010
}
1111

1212
# Vars with defaults
@@ -25,7 +25,7 @@ variable "sysdig_secure_endpoint" {
2525
variable "naming_prefix" {
2626
type = string
2727
description = "Naming prefix for all the resources created"
28-
default = "sfc"
28+
default = "secure-for-cloud"
2929
}
3030

3131
variable "max_instances" {

examples/single-project/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ This example deploys Cloud Connector and Cloud Scanning into a GCP account.
3434
|------|------|
3535
| [google_service_account.connector_sa](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
3636
| [google_service_account.scanning_sa](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource |
37-
| [google_project.project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source |
3837

3938
## Inputs
4039

@@ -43,7 +42,7 @@ This example deploys Cloud Connector and Cloud Scanning into a GCP account.
4342
| <a name="input_create_gcr_topic"></a> [create\_gcr\_topic](#input\_create\_gcr\_topic) | Deploys a PubSub topic called `gcr` as part of this stack, which is needed for GCR scanning. Set to `true` if it doesn't exist yet. If this is not deployed, and no existing `gcr` topic is found, the GCR scanning is ommited and won't be deployed. For more info see [GCR PubSub topic](https://cloud.google.com/container-registry/docs/configuring-notifications#create_a_topic). | `bool` | `true` | no |
4443
| <a name="input_location"></a> [location](#input\_location) | Zone where the stack will be deployed | `string` | `"us-central1"` | no |
4544
| <a name="input_naming_prefix"></a> [naming\_prefix](#input\_naming\_prefix) | Naming prefix for all the resources created | `string` | `"sfc"` | no |
46-
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | Google cloud project name | `string` | n/a | yes |
45+
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | Project ID | `string` | n/a | yes |
4746
| <a name="input_sysdig_secure_api_token"></a> [sysdig\_secure\_api\_token](#input\_sysdig\_secure\_api\_token) | Sysdig's Secure API Token | `string` | n/a | yes |
4847
| <a name="input_sysdig_secure_endpoint"></a> [sysdig\_secure\_endpoint](#input\_sysdig\_secure\_endpoint) | Sysdig Secure API endpoint | `string` | `"https://secure.sysdig.com"` | no |
4948

examples/single-project/main.tf

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ locals {
44
protoPayload.methodName = "google.cloud.run.v1.Services.CreateService" OR protoPayload.methodName = "google.cloud.run.v1.Services.ReplaceService"
55
EOT
66
connector_filter = <<EOT
7-
logName=~"^projects/${data.google_project.project.project_id}/logs/cloudaudit.googleapis.com" AND -resource.type="k8s_cluster"
7+
logName=~"^projects/${var.project_id}/logs/cloudaudit.googleapis.com" AND -resource.type="k8s_cluster"
88
EOT
99
}
1010

11-
data "google_project" "project" {
12-
}
13-
1411

1512
#######################
1613
# CONNECTOR #
1714
#######################
1815
provider "google" {
19-
project = var.project_name
16+
project = var.project_id
2017
region = var.location
2118
}
2219

examples/single-project/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ variable "sysdig_secure_api_token" {
44
description = "Sysdig's Secure API Token"
55
}
66

7-
variable "project_name" {
7+
variable "project_id" {
88
type = string
9-
description = "Google cloud project name"
9+
description = "Project ID"
1010
}
1111

1212
# Vars with defaults

0 commit comments

Comments
 (0)