Skip to content

Commit

Permalink
Convert example templates (part 5) (GoogleCloudPlatform#10398)
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 authored and balanaguharsha committed May 2, 2024
1 parent 78debdc commit 402af7f
Show file tree
Hide file tree
Showing 214 changed files with 7,073 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mmv1/templates/terraform/examples/go/scan_config_basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "google_compute_address" "scanner_static_ip" {
provider = google-beta
name = "{{index $.Vars "address_name"}}"
}

resource "google_security_scanner_scan_config" "{{$.PrimaryResourceId}}" {
provider = google-beta
display_name = "{{index $.Vars "scan_config_name"}}"
starting_urls = ["http://${google_compute_address.scanner_static_ip.address}"]
target_platforms = ["COMPUTE"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_scc_event_threat_detection_custom_module" "{{$.PrimaryResourceId}}" {
organization = "{{index $.TestEnvVars "org_id"}}"
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
type = "{{index $.Vars "type"}}"
description = "My Event Threat Detection Custom Module"
config = jsonencode({
"metadata": {
"severity": "LOW",
"description": "Flagged by Forcepoint as malicious",
"recommendation": "Contact the owner of the relevant project."
},
"ips": [
"192.0.2.1",
"192.0.2.0/24"
]
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
resource "google_folder" "folder" {
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
display_name = "{{index $.Vars "folder_display_name"}}"
}

resource "google_scc_folder_custom_module" "{{$.PrimaryResourceId}}" {
folder = google_folder.folder.folder_id
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
description = "The rotation period of the identified cryptokey resource exceeds 30 days."
recommendation = "Set the rotation period to at most 30 days."
severity = "MEDIUM"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
resource "google_folder" "folder" {
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
display_name = "{{index $.Vars "folder_display_name"}}"
}

resource "google_scc_folder_custom_module" "{{$.PrimaryResourceId}}" {
folder = google_folder.folder.folder_id
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
custom_output {
properties {
name = "duration"
value_expression {
expression = "resource.rotationPeriod"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
}
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
severity = "LOW"
description = "Description of the custom module"
recommendation = "Steps to resolve violation"
}
}
6 changes: 6 additions & 0 deletions mmv1/templates/terraform/examples/go/scc_mute_config.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resource "google_scc_mute_config" "{{$.PrimaryResourceId}}" {
mute_config_id = "{{index $.Vars "mute_config_id"}}"
parent = "organizations/{{index $.TestEnvVars "org_id"}}"
filter = "category: \"OS_VULNERABILITY\""
description = "My Mute Config"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
resource "google_pubsub_topic" "scc_notification" {
name = "{{index $.Vars "topic_name"}}"
}

resource "google_scc_notification_config" "{{$.PrimaryResourceId}}" {
config_id = "{{index $.Vars "config_id"}}"
organization = "{{index $.TestEnvVars "org_id"}}"
description = "My custom Cloud Security Command Center Finding Notification Configuration"
pubsub_topic = google_pubsub_topic.scc_notification.id

streaming_config {
filter = "category = \"OPEN_FIREWALL\" AND state = \"ACTIVE\""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_scc_organization_custom_module" "{{$.PrimaryResourceId}}" {
organization = "{{index $.TestEnvVars "org_id"}}"
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
description = "The rotation period of the identified cryptokey resource exceeds 30 days."
recommendation = "Set the rotation period to at most 30 days."
severity = "MEDIUM"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
resource "google_scc_organization_custom_module" "{{$.PrimaryResourceId}}" {
organization = "{{index $.TestEnvVars "org_id"}}"
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
custom_output {
properties {
name = "duration"
value_expression {
expression = "resource.rotationPeriod"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
}
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
severity = "LOW"
description = "Description of the custom module"
recommendation = "Steps to resolve violation"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "google_scc_project_custom_module" "{{$.PrimaryResourceId}}" {
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
description = "The rotation period of the identified cryptokey resource exceeds 30 days."
recommendation = "Set the rotation period to at most 30 days."
severity = "MEDIUM"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "google_scc_project_custom_module" "{{$.PrimaryResourceId}}" {
display_name = "{{index $.Vars "display_name"}}"
enablement_state = "ENABLED"
custom_config {
predicate {
expression = "resource.rotationPeriod > duration(\"2592000s\")"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
custom_output {
properties {
name = "duration"
value_expression {
expression = "resource.rotationPeriod"
title = "Purpose of the expression"
description = "description of the expression"
location = "location of the expression"
}
}
}
resource_selector {
resource_types = [
"cloudkms.googleapis.com/CryptoKey",
]
}
severity = "LOW"
description = "Description of the custom module"
recommendation = "Steps to resolve violation"
}
}
5 changes: 5 additions & 0 deletions mmv1/templates/terraform/examples/go/scc_source_basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "google_scc_source" "{{$.PrimaryResourceId}}" {
display_name = "{{index $.Vars "source_display_name"}}"
organization = "{{index $.TestEnvVars "org_id"}}"
description = "My custom Cloud Security Command Center Finding Source"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
resource "google_cloud_scheduler_job" "job" {
name = "{{index $.Vars "job_name"}}"
schedule = "*/4 * * * *"
description = "test app engine job"
time_zone = "Europe/London"
attempt_deadline = "320s"

retry_config {
min_backoff_duration = "1s"
max_retry_duration = "10s"
max_doublings = 2
retry_count = 3
}

app_engine_http_target {
http_method = "POST"

app_engine_routing {
service = "web"
version = "prod"
instance = "my-instance-001"
}

relative_uri = "/ping"
}
}
20 changes: 20 additions & 0 deletions mmv1/templates/terraform/examples/go/scheduler_job_http.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "google_cloud_scheduler_job" "job" {
name = "{{index $.Vars "job_name"}}"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"

retry_config {
retry_count = 1
}

http_target {
http_method = "POST"
uri = "https://example.com/"
body = base64encode("{\"foo\":\"bar\"}")
headers = {
"Content-Type" = "application/json"
}
}
}
19 changes: 19 additions & 0 deletions mmv1/templates/terraform/examples/go/scheduler_job_oauth.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
data "google_compute_default_service_account" "default" {
}

resource "google_cloud_scheduler_job" "job" {
name = "{{index $.Vars "job_name"}}"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"

http_target {
http_method = "GET"
uri = "https://cloudscheduler.googleapis.com/v1/projects/{{index $.TestEnvVars "project_name"}}/locations/{{index $.TestEnvVars "region"}}/jobs"

oauth_token {
service_account_email = data.google_compute_default_service_account.default.email
}
}
}
19 changes: 19 additions & 0 deletions mmv1/templates/terraform/examples/go/scheduler_job_oidc.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
data "google_compute_default_service_account" "default" {
}

resource "google_cloud_scheduler_job" "job" {
name = "{{index $.Vars "job_name"}}"
description = "test http job"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"

http_target {
http_method = "GET"
uri = "https://example.com/ping"

oidc_token {
service_account_email = data.google_compute_default_service_account.default.email
}
}
}
21 changes: 21 additions & 0 deletions mmv1/templates/terraform/examples/go/scheduler_job_paused.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "google_cloud_scheduler_job" "job" {
paused = true
name = "{{index $.Vars "job_name"}}"
description = "test http job with updated fields"
schedule = "*/8 * * * *"
time_zone = "America/New_York"
attempt_deadline = "320s"

retry_config {
retry_count = 1
}

http_target {
http_method = "POST"
uri = "https://example.com/ping"
body = base64encode("{\"foo\":\"bar\"}")
headers = {
"Content-Type" = "application/json"
}
}
}
15 changes: 15 additions & 0 deletions mmv1/templates/terraform/examples/go/scheduler_job_pubsub.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_pubsub_topic" "topic" {
name = "{{index $.Vars "topic_name"}}"
}

resource "google_cloud_scheduler_job" "job" {
name = "{{index $.Vars "job_name"}}"
description = "test job"
schedule = "*/2 * * * *"

pubsub_target {
# topic.id is the topic's full resource name.
topic_name = google_pubsub_topic.topic.id
data = base64encode("test")
}
}
18 changes: 18 additions & 0 deletions mmv1/templates/terraform/examples/go/secret_config_basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_secret_manager_secret" "{{$.PrimaryResourceId}}" {
secret_id = "{{index $.Vars "secret_id"}}"

labels = {
label = "my-label"
}

replication {
user_managed {
replicas {
location = "us-central1"
}
replicas {
location = "us-east1"
}
}
}
}
18 changes: 18 additions & 0 deletions mmv1/templates/terraform/examples/go/secret_version_basic.tf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_secret_manager_secret" "secret-basic" {
secret_id = "{{index $.Vars "secret_id"}}"

labels = {
label = "my-label"
}

replication {
auto {}
}
}


resource "google_secret_manager_secret_version" "{{$.PrimaryResourceId}}" {
secret = google_secret_manager_secret.secret-basic.id

secret_data = "{{index $.Vars "data"}}"
}
Loading

0 comments on commit 402af7f

Please sign in to comment.