-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a new feature in P0's Google Gcloud installation. Add supporting resource.
- Loading branch information
Showing
7 changed files
with
406 additions
and
6 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
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,110 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "p0_gcp_organization_access_logs Resource - p0" | ||
subcategory: "" | ||
description: |- | ||
An installation of P0, on an entire Google Cloud organization, for access-log collection, | ||
which enhances IAM assessment. Note that P0 will have access to logs from all your projects, not just those | ||
configured for IAM assessment. | ||
To use this resource, you must also: | ||
create a Pub/Sub topic,create an organization logging sink, publishing to this topic,grant your logging service account permissions to publish to this Pub/Sub topic, andgrant P0 the ability to subscribe to this Pub/Sub topic. | ||
Use the read-only attributes defined on p0_gcp to create the requisite Google Cloud infrastructure. | ||
P0 recommends defining this infrastructure according to the example usage pattern. | ||
--- | ||
|
||
# p0_gcp_organization_access_logs (Resource) | ||
|
||
An installation of P0, on an entire Google Cloud organization, for access-log collection, | ||
which enhances IAM assessment. Note that P0 will have access to logs from all your projects, not just those | ||
configured for IAM assessment. | ||
|
||
To use this resource, you must also: | ||
- create a Pub/Sub topic, | ||
- create an organization logging sink, publishing to this topic, | ||
- grant your logging service account permissions to publish to this Pub/Sub topic, and | ||
- grant P0 the ability to subscribe to this Pub/Sub topic. | ||
|
||
Use the read-only attributes defined on `p0_gcp` to create the requisite Google Cloud infrastructure. | ||
|
||
P0 recommends defining this infrastructure according to the example usage pattern. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
resource "p0_gcp" "example" { | ||
organization_id = "123456789012" | ||
} | ||
locals { | ||
logs_topic_project = "my-logs-project" | ||
} | ||
resource "google_organization_iam_audit_config" "example" { | ||
org_id = p0_gcp.example.org_id | ||
service = "allServices" | ||
audit_log_config { | ||
log_type = "ADMIN_READ" | ||
} | ||
audit_log_config { | ||
log_type = "DATA_READ" | ||
} | ||
audit_log_config { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
# Data access logs are sent to P0 using this Pub/Sub topic | ||
resource "google_pubsub_topic" "example" { | ||
project = locals.logs_topic_project | ||
name = p0_gcp.example.access_logs.pub_sub.topic_id | ||
} | ||
# The log sink that writes to the P0 access-logging Pub/Sub topic | ||
resource "google_logging_organization_sink" "example" { | ||
org_id = p0_gcp.example.org_id | ||
name = p0_gcp.example.access_logs.logging.sink_id | ||
destination = "pubsub.googleapis.com/projects/${locals.logs_topic_project}/topics/${google_pubsub_topic.example.name}" | ||
description = "P0 data access log sink" | ||
filter = p0_gcp.example.access_logs.logging.filter | ||
} | ||
# Grants the logging service account permission to write to the access-logging Pub/Sub topic | ||
resource "google_pubsub_topic_iam_member" "logging_example" { | ||
project = locals.logs_topic_project | ||
role = p0_gcp.example.access_logs.logging.role | ||
topic = google_pubsub_topic.example.name | ||
member = google_logging_organization_sink.example.writer_identity | ||
} | ||
# Grants P0 permission to read from the access-logging Pub/Sub topic | ||
resource "google_pubsub_topic_iam_member" "p0_example" { | ||
project = locals.logs_topic_project | ||
role = p0_gcp.example.access_logs.predefined_role | ||
topic = google_pubsub_topic.example.name | ||
member = "serviceAccount:${p0_gcp.example.serviceAccountEmail}" | ||
} | ||
# Install organization access logging in P0 | ||
resource "p0_gcp_access_logs" "example" { | ||
topic_project_id = locals.logs_topic_project | ||
depends_on = [ | ||
google_logging_project_sink.example, | ||
google_pubsub_topic_iam_member.p0_example | ||
] | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `topic_project_id` (String) The project identifier where the access-logs Pub/Sub topic should reside | ||
|
||
### Read-Only | ||
|
||
- `state` (String) This item's install progress in the P0 application: | ||
- 'stage': The item has been staged for installation | ||
- 'configure': The item is available to be added to P0, and may be configured | ||
- 'installed': The item is fully installed |
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
62 changes: 62 additions & 0 deletions
62
examples/resources/p0_gcp_organization_access_logs/resource.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,62 @@ | ||
resource "p0_gcp" "example" { | ||
organization_id = "123456789012" | ||
} | ||
|
||
locals { | ||
logs_topic_project = "my-logs-project" | ||
} | ||
|
||
resource "google_organization_iam_audit_config" "example" { | ||
org_id = p0_gcp.example.org_id | ||
service = "allServices" | ||
audit_log_config { | ||
log_type = "ADMIN_READ" | ||
} | ||
audit_log_config { | ||
log_type = "DATA_READ" | ||
} | ||
audit_log_config { | ||
log_type = "DATA_WRITE" | ||
} | ||
} | ||
|
||
# Data access logs are sent to P0 using this Pub/Sub topic | ||
resource "google_pubsub_topic" "example" { | ||
project = locals.logs_topic_project | ||
name = p0_gcp.example.access_logs.pub_sub.topic_id | ||
} | ||
|
||
# The log sink that writes to the P0 access-logging Pub/Sub topic | ||
resource "google_logging_organization_sink" "example" { | ||
org_id = p0_gcp.example.org_id | ||
name = p0_gcp.example.access_logs.logging.sink_id | ||
destination = "pubsub.googleapis.com/projects/${locals.logs_topic_project}/topics/${google_pubsub_topic.example.name}" | ||
description = "P0 data access log sink" | ||
|
||
filter = p0_gcp.example.access_logs.logging.filter | ||
} | ||
|
||
# Grants the logging service account permission to write to the access-logging Pub/Sub topic | ||
resource "google_pubsub_topic_iam_member" "logging_example" { | ||
project = locals.logs_topic_project | ||
role = p0_gcp.example.access_logs.logging.role | ||
topic = google_pubsub_topic.example.name | ||
member = google_logging_organization_sink.example.writer_identity | ||
} | ||
|
||
# Grants P0 permission to read from the access-logging Pub/Sub topic | ||
resource "google_pubsub_topic_iam_member" "p0_example" { | ||
project = locals.logs_topic_project | ||
role = p0_gcp.example.access_logs.predefined_role | ||
topic = google_pubsub_topic.example.name | ||
member = "serviceAccount:${p0_gcp.example.serviceAccountEmail}" | ||
} | ||
|
||
# Install organization access logging in P0 | ||
resource "p0_gcp_access_logs" "example" { | ||
topic_project_id = locals.logs_topic_project | ||
depends_on = [ | ||
google_logging_project_sink.example, | ||
google_pubsub_topic_iam_member.p0_example | ||
] | ||
} |
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
Oops, something went wrong.