-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GCP promote and quarantine add support for cross project
- Loading branch information
1 parent
c3d48db
commit 795fbe3
Showing
6 changed files
with
179 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
main.auto.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
post-scan-actions/gcp-python-promote-or-quarantine/provider.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
terraform { | ||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = "~> 5.11.0" | ||
} | ||
} | ||
} | ||
|
||
provider "google" { | ||
project = var.project_id | ||
region = var.region | ||
} | ||
|
||
provider "google" { | ||
alias = "quarantine_provider" | ||
project = var.quarantine_bucket_properties.project_id != "" ? var.quarantine_bucket_properties.project_id : var.project_id | ||
region = var.quarantine_bucket_properties.region != "" ? var.quarantine_bucket_properties.region : var.region | ||
} | ||
|
||
provider "google" { | ||
alias = "promote_provider" | ||
project = var.promote_bucket_properties.project_id != "" ? var.promote_bucket_properties.project_id : var.project_id | ||
region = var.promote_bucket_properties.region != "" ? var.promote_bucket_properties.region : var.region | ||
} |
2 changes: 1 addition & 1 deletion
2
post-scan-actions/gcp-python-promote-or-quarantine/src/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
google-cloud-storage==2.14.0 | ||
google-cloud-storage==2.16.0 |
144 changes: 83 additions & 61 deletions
144
post-scan-actions/gcp-python-promote-or-quarantine/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,83 @@ | ||
variable "project_id" { | ||
type = string | ||
description = "ID of the GCP project which the plugin will be deployed" | ||
sensitive = true | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
description = "GCP region to deploy the plugin" | ||
} | ||
|
||
variable "plugin_prefix" { | ||
type = string | ||
description = "GCP function prefix to use for the plugin" | ||
} | ||
|
||
variable "deployment_name" { | ||
type = string | ||
description = "The name of the deployment" | ||
} | ||
|
||
variable "scan_result_topic" { | ||
type = string | ||
description = "The name of the Pub/Sub topic for scan results topic" | ||
} | ||
|
||
variable "scanning_bucket" { | ||
type = string | ||
description = "Scanning bucket name" | ||
nullable = false | ||
} | ||
|
||
variable "quarantine_mode" { | ||
type = string | ||
description = "The quarantine mode to use: 'move' or 'copy'" | ||
nullable = false | ||
validation { | ||
condition = contains(["move", "copy"], var.quarantine_mode) | ||
error_message = "Value must be one of 'move' or 'copy'." | ||
} | ||
} | ||
|
||
variable "quarantine_bucket" { | ||
type = string | ||
description = "The quarantine bucket to use. Leave it empty if you don't want to quarantine files." | ||
} | ||
|
||
variable "promote_mode" { | ||
type = string | ||
description = "The promote mode to use: 'move' or 'copy'" | ||
nullable = false | ||
validation { | ||
condition = contains(["move", "copy"], var.promote_mode) | ||
error_message = "Value must be one of 'move' or 'copy'." | ||
} | ||
} | ||
|
||
variable "promote_bucket" { | ||
type = string | ||
description = "The promote bucket to use. Leave it empty if you don't want to promote files." | ||
} | ||
variable "project_id" { | ||
type = string | ||
description = "ID of the GCP project which the plugin will be deployed" | ||
sensitive = true | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
description = "GCP region to deploy the plugin" | ||
} | ||
|
||
variable "plugin_prefix" { | ||
type = string | ||
description = "GCP function prefix to use for the plugin" | ||
} | ||
|
||
variable "deployment_name" { | ||
type = string | ||
description = "The name of the deployment" | ||
} | ||
|
||
variable "scan_result_topic" { | ||
type = string | ||
description = "The name of the Pub/Sub topic for scan results topic" | ||
} | ||
|
||
variable "scanning_bucket" { | ||
type = string | ||
description = "Scanning bucket name" | ||
nullable = false | ||
} | ||
|
||
variable "quarantine_mode" { | ||
type = string | ||
description = "The quarantine mode to use: 'move' or 'copy'" | ||
nullable = false | ||
validation { | ||
condition = contains(["move", "copy"], var.quarantine_mode) | ||
error_message = "Value must be one of 'move' or 'copy'." | ||
} | ||
default = "move" | ||
} | ||
|
||
variable "quarantine_bucket" { | ||
type = string | ||
description = "The quarantine bucket to use. Leave it empty if you don't want to quarantine files." | ||
nullable = true | ||
default = "" | ||
} | ||
|
||
variable "quarantine_bucket_properties" { | ||
type = object({ | ||
project_id = string | ||
region = string | ||
}) | ||
description = "The properties of the quarantine bucket including the following: gcp project, location, CMEK used." | ||
} | ||
|
||
variable "promote_mode" { | ||
type = string | ||
description = "The promote mode to use: 'move' or 'copy'" | ||
nullable = false | ||
validation { | ||
condition = contains(["move", "copy"], var.promote_mode) | ||
error_message = "Value must be one of 'move' or 'copy'." | ||
} | ||
default = "move" | ||
} | ||
|
||
variable "promote_bucket" { | ||
type = string | ||
description = "The promote bucket to use. Leave it empty if you don't want to promote files." | ||
nullable = true | ||
default = "" | ||
} | ||
|
||
variable "promote_bucket_properties" { | ||
type = object({ | ||
project_id = string | ||
region = string | ||
}) | ||
description = "The properties of the promote bucket including the following: gcp project, location, CMEK used." | ||
} |