Skip to content

Commit 7ca6ca2

Browse files
author
iru
committed
Merge remote-tracking branch 'origin/master'
2 parents 9a7bf40 + 3c29488 commit 7ca6ca2

File tree

10 files changed

+38
-10
lines changed

10 files changed

+38
-10
lines changed

.github/workflows/pre-commit.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
run: |
6161
pip install pre-commit
6262
go install github.com/hashicorp/terraform-config-inspect@latest
63+
make deps
6364
- name: Initialize terraform modules
6465
if: ${{ matrix.directory != '.' }}
6566
run: |
@@ -112,9 +113,7 @@ jobs:
112113
- name: Install pre-commit dependencies
113114
run: |
114115
pip install pre-commit
115-
go install github.com/terraform-docs/[email protected]
116-
go install github.com/hashicorp/terraform-config-inspect@latest
117-
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
116+
make deps
118117
- name: Execute pre-commit
119118
# Run all pre-commit checks on max version supported
120119
if: ${{ matrix.version == needs.getBaseVersion.outputs.maxVersion }}

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ repos:
3838
- '--args=--only=terraform_required_providers'
3939
- '--args=--only=terraform_standard_module_structure'
4040
- '--args=--only=terraform_workspace_remote'
41+
- id: terrascan
4142
- repo: local
4243
hooks:
4344
- id: terraform_init

CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
* @sysdiglabs/cloud-native
2+
3+
# compliance
4+
/modules/services/cloud-bench/ @haresh-suresh @nkraemer-sysdig @sysdiglabs/cloud-native

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ deps:
55
unzip tflint.zip && \
66
rm tflint.zip && \
77
mv tflint "`go env GOPATH`/bin"
8+
curl -L https://github.com/tenable/terrascan/releases/download/v1.9.0/terrascan_1.9.0_Linux_x86_64.tar.gz -o terrascan.tar.gz && \
9+
tar -xf terrascan.tar.gz terrascan && \
10+
rm terrascan.tar.gz && \
11+
install terrascan "`go env GOPATH`/bin" && \
12+
rm terrascan
813

914
clean:
1015
find -name ".terraform" -type d | xargs rm -rf

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ A: On your Google Cloud account, search for "APIs & Services > Enabled APIs & Se
135135
$ gcloud services list --enabled
136136
```
137137
138-
### Q: Getting "googleapi: 403 Permission *** denied for resource"
138+
### Q: Getting "googleapi: 403 ***"
139139
A: This may happen because permissions are not enough, API services were not correctly enabled, or you're not correctly authenticated for terraform google prolvider.
140-
<br/>S: Verify [permissions](#prerequisites), [api-services](apis), and that the [Terraform Google Provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#configuring-the-provider) authentication has been correctly setup.
140+
<br/>S: Verify [permissions](#prerequisites), [api-services](#apis), and that the [Terraform Google Provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/getting_started#configuring-the-provider) authentication has been correctly setup.
141141
You can also launch the following terraform manifest to check whether you're authenticated with what you expect
142142
143143
```
@@ -208,6 +208,8 @@ $ terraform import 'module.secure-for-cloud_example_organization.module.cloud_be
208208
$ terraform import 'module.secure-for-cloud_example_organization.module.cloud_bench[0].module.trust_relationship["<YOUR_PROJECT_ID>"].google_iam_workload_identity_pool_provider.pool_provider' sysdigcloud/sysdigcloud
209209
```
210210

211+
Note: if you're using terragrunt, run `terragrunt import`
212+
211213
### Q: Getting "Error creating Topic: googleapi: Error 409: Resource already exists in the project (resource=gcr)"
212214
```text
213215
│ Error: Error creating Topic: googleapi: Error 409: Resource already exists in the project (resource=gcr).
@@ -224,6 +226,7 @@ $ terraform import 'module.sfc_example_single_project.module.pubsub_http_subscri
224226
```
225227
Contact us to develop a workaround for this, where the topic name is to be reused.
226228
229+
Note: if you're using terragrunt, run `terragrunt import`
227230

228231
### Q: Getting "Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable."
229232
A: If cloud-connector cloud run module cannot start it will give this error. The error is given by the health-check system, it's not specific to its PORT per-se
@@ -253,19 +256,21 @@ A: Verify that `gcr` topic exists. If `create_gcr_topic` is set to false and `gc
253256

254257
## Upgrading
255258

256-
- Uninstall previous deployment resources before upgrading
259+
1. Uninstall previous deployment resources before upgrading
257260
```
258261
$ terraform destroy
259262
```
260263

261-
- Upgrade the full terraform example with
264+
2. Upgrade the full terraform example with
262265
```
263266
$ terraform init -upgrade
264267
$ terraform plan
265268
$ terraform apply
266269
```
267270

268-
- If required, you can upgrade cloud-connector component by restarting the task (stop task). Because it's not pinned to an specific version, it will download the latest one.
271+
- If the event-source is created throuh SFC, some events may get lost while upgrading with this approach. however, if the cloudtrail is re-used (normal production setup) events will be recovered once the ingestion resumes.
272+
273+
- If required, you can upgrade cloud-connector component by restarting the task (stop task). Because it's not pinned to an specific version, it will download the `latest` one.
269274
270275
<br/>
271276

examples/single-project-k8s/credentials.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ resource "google_project_iam_member" "event_receiver" {
1414
}
1515

1616
resource "google_project_iam_member" "token_creator" {
17+
# AC_GCP_0006
18+
# Why: Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
19+
# How to avoid security issues: As in the next implementation scanning will be run from within cloudrun which has needed permissions and won't need a token.
20+
# Warning: Organization users musn't be able to impersonate as the created service account.
21+
#ts:skip=AC_GCP_0006 Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
1722
project = data.google_client_config.current.project
1823
member = "serviceAccount:${google_service_account.connector_sa.email}"
1924
role = "roles/iam.serviceAccountTokenCreator"

modules/infrastructure/cloud_build_permission/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Required to execute cloud build runs with this same service account
22
resource "google_project_iam_member" "service_account_user_itself" {
3+
# AC_GCP_0006
4+
# Why: Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
5+
# How to avoid security issues: As in the next implementation scanning will be run from within cloudrun which has needed permissions and won't need a token.
6+
# Warning: Organization users musn't be able to impersonate as the created service account.
7+
#ts:skip=AC_GCP_0006 Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
38
project = var.project_id
49
role = "roles/iam.serviceAccountUser"
510
member = "serviceAccount:${var.cloud_connector_sa_email}"

modules/services/cloud-connector/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ No modules.
6464
| <a name="input_cpu"></a> [cpu](#input\_cpu) | Amount of CPU to reserve for cloud-connector cloud run service | `string` | `"1"` | no |
6565
| <a name="input_deploy_scanning"></a> [deploy\_scanning](#input\_deploy\_scanning) | true/false whether scanning module is to be deployed | `bool` | `false` | no |
6666
| <a name="input_extra_envs"></a> [extra\_envs](#input\_extra\_envs) | Extra environment variables for the Cloud Connector instance | `map(string)` | `{}` | no |
67-
| <a name="input_image_name"></a> [image\_name](#input\_image\_name) | Sysdig Owned Cloud Connector public image. GCP only allows the deployment of images that are registered in gcr.io | `string` | `"gcr.io/mateo-burillo-ns/cloud-connector:latest"` | no |
67+
| <a name="input_image_name"></a> [image\_name](#input\_image\_name) | Sysdig Owned Cloud Connector public image. GCP only allows the deployment of images that are registered in gcr.io | `string` | `"us-docker.pkg.dev/sysdig-public-registry/secure-for-cloud/cloud-connector:latest"` | no |
6868
| <a name="input_is_organizational"></a> [is\_organizational](#input\_is\_organizational) | whether secure-for-cloud should be deployed in an organizational setup | `bool` | `false` | no |
6969
| <a name="input_max_instances"></a> [max\_instances](#input\_max\_instances) | Max number of instances for the Cloud Connector | `number` | `1` | no |
7070
| <a name="input_memory"></a> [memory](#input\_memory) | Amount of memory to reserve for cloud-connector cloud run service | `string` | `"500Mi"` | no |

modules/services/cloud-connector/pubsub_permissions.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ resource "google_project_iam_member" "event_receiver" {
55
}
66

77
resource "google_project_iam_member" "token_creator" {
8+
# AC_GCP_0006
9+
# Why: Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
10+
# How to avoid security issues: As in the next implementation scanning will be run from within cloudrun which has needed permissions and won't need a token.
11+
# Warning: Organization users musn't be able to impersonate as the created service account.
12+
#ts:skip=AC_GCP_0006 Image scanning is run from inside a container. As it needs to get the image from the registry it needs a token to get it from the registry.
813
project = var.project_id
914
member = "serviceAccount:service-${data.google_project.project.number}@gcp-sa-pubsub.iam.gserviceaccount.com"
1015
role = "roles/iam.serviceAccountTokenCreator"

modules/services/cloud-connector/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ variable "verify_ssl" {
4848

4949
variable "image_name" {
5050
type = string
51-
default = "gcr.io/mateo-burillo-ns/cloud-connector:latest"
51+
default = "us-docker.pkg.dev/sysdig-public-registry/secure-for-cloud/cloud-connector:latest"
5252
description = "Sysdig Owned Cloud Connector public image. GCP only allows the deployment of images that are registered in gcr.io"
5353
}
5454

0 commit comments

Comments
 (0)