2021-05-21 18:34:30 +02:00
|
|
|
include::../description.adoc[]
|
|
|
|
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
|
|
|
|
== Sensitive Code Example
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket[S3 access requests]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-05-21 18:34:30 +02:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_s3_bucket" "example" { # Sensitive
|
|
|
|
bucket = "example"
|
2021-05-21 18:34:30 +02:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_stage[API Gateway stages]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:53:43 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_api_gateway_stage" "example" { # Sensitive
|
2021-11-10 10:53:43 +01:00
|
|
|
xray_tracing_enabled = false # Sensitive
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/msk_cluster[MSK Broker logs]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:44:44 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_msk_cluster" "example" {
|
|
|
|
cluster_name = "example"
|
|
|
|
kafka_version = "2.7.1"
|
|
|
|
number_of_broker_nodes = 3
|
2021-11-10 10:42:46 +01:00
|
|
|
|
|
|
|
logging_info {
|
|
|
|
broker_logs { # Sensitive
|
|
|
|
firehose {
|
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
s3 {
|
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker[MQ Brokers]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:41:13 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_mq_broker" "example" {
|
2021-11-10 10:41:13 +01:00
|
|
|
logs { # Sensitive
|
2022-06-01 17:19:35 +02:00
|
|
|
audit = false
|
2021-11-10 10:41:13 +01:00
|
|
|
general = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2021-11-10 10:25:14 +01:00
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster[Amazon DocumentDB]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:17:50 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_docdb_cluster" "example" { # Sensitive
|
|
|
|
cluster_identifier = "example"
|
2021-11-10 10:17:50 +01:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Azure https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service[App Services]:
|
2022-03-07 11:45:11 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:16:04 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "azurerm_app_service" "example" {
|
|
|
|
logs {
|
|
|
|
application_logs {
|
|
|
|
file_system_level = "Off" # Sensitive
|
|
|
|
azure_blob_storage {
|
|
|
|
level = "Off" # Sensitive
|
|
|
|
}
|
|
|
|
}
|
2021-11-10 10:16:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-03-07 11:45:11 +01:00
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork/[VPC Subnetwork]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
|
|
|
resource "google_compute_subnetwork" "example" { # Sensitive
|
|
|
|
name = "example"
|
|
|
|
ip_cidr_range = "10.2.0.0/16"
|
|
|
|
region = "us-central1"
|
2022-06-01 17:19:35 +02:00
|
|
|
network = google_compute_network.example.id
|
2022-03-07 11:45:11 +01:00
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance/[SQL Database Instance]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
|
|
|
resource "google_sql_database_instance" "example" {
|
2022-06-01 17:19:35 +02:00
|
|
|
name = "example"
|
2022-03-07 11:45:11 +01:00
|
|
|
|
|
|
|
settings { # Sensitive
|
|
|
|
tier = "db-f1-micro"
|
|
|
|
ip_configuration {
|
|
|
|
require_ssl = true
|
|
|
|
ipv4_enabled = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster/[Kubernetes Engine (GKE) cluster]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "google_container_cluster" "example" {
|
2022-03-07 11:45:11 +01:00
|
|
|
name = "example"
|
|
|
|
logging_service = "none" # Sensitive
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-05-21 18:34:30 +02:00
|
|
|
== Compliant Solution
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket[S3 access requests]:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-05-21 18:34:30 +02:00
|
|
|
----
|
2022-11-07 11:38:54 +01:00
|
|
|
resource "aws_s3_bucket" "example-logs" {
|
2022-06-01 17:19:35 +02:00
|
|
|
bucket = "example_logstorage"
|
2021-05-21 18:34:30 +02:00
|
|
|
acl = "log-delivery-write"
|
|
|
|
}
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_s3_bucket" "example" {
|
|
|
|
bucket = "example"
|
2021-05-21 18:34:30 +02:00
|
|
|
|
2022-11-07 11:38:54 +01:00
|
|
|
logging { # AWS provider <= 3
|
|
|
|
target_bucket = aws_s3_bucket.example-logs.id
|
2022-06-01 17:19:35 +02:00
|
|
|
target_prefix = "log/example"
|
2021-05-21 18:34:30 +02:00
|
|
|
}
|
|
|
|
}
|
2022-11-07 11:38:54 +01:00
|
|
|
|
|
|
|
resource "aws_s3_bucket_logging" "example" { # AWS provider >= 4
|
|
|
|
bucket = aws_s3_bucket.example.id
|
|
|
|
|
|
|
|
target_bucket = aws_s3_bucket.example-logs.id
|
|
|
|
target_prefix = "log/example"
|
|
|
|
}
|
2021-05-21 18:34:30 +02:00
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/api_gateway_stage[API Gateway stages]:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:53:43 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_api_gateway_stage" "example" {
|
2021-11-10 10:53:43 +01:00
|
|
|
xray_tracing_enabled = true
|
2022-06-01 17:19:35 +02:00
|
|
|
|
2021-11-10 10:53:43 +01:00
|
|
|
access_log_settings {
|
2022-06-01 17:19:35 +02:00
|
|
|
destination_arn = "arn:aws:logs:eu-west-1:123456789:example"
|
2021-11-10 10:53:43 +01:00
|
|
|
format = "..."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2021-11-10 10:24:04 +01:00
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/msk_cluster[MSK Broker logs]:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:44:44 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_msk_cluster" "example" {
|
|
|
|
cluster_name = "example"
|
|
|
|
kafka_version = "2.7.1"
|
|
|
|
number_of_broker_nodes = 3
|
2021-11-10 10:42:46 +01:00
|
|
|
|
|
|
|
logging_info {
|
|
|
|
broker_logs {
|
2022-06-01 17:19:35 +02:00
|
|
|
firehose {
|
2021-11-10 10:42:46 +01:00
|
|
|
enabled = false
|
|
|
|
}
|
|
|
|
s3 {
|
|
|
|
enabled = true
|
2022-06-01 17:19:35 +02:00
|
|
|
bucket = "example"
|
2021-11-10 10:42:46 +01:00
|
|
|
prefix = "log/msk-"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/mq_broker[MQ Brokers], enable `audit` or `general`:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:41:13 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_mq_broker" "example" {
|
2021-11-10 10:41:13 +01:00
|
|
|
logs {
|
2022-06-01 17:19:35 +02:00
|
|
|
audit = true
|
2021-11-10 10:41:13 +01:00
|
|
|
general = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Amazon https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster[Amazon DocumentDB]:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:25:14 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "aws_docdb_cluster" "example" {
|
|
|
|
cluster_identifier = "example"
|
2021-11-10 10:25:14 +01:00
|
|
|
enabled_cloudwatch_logs_exports = ["audit"]
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
For Azure https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/app_service[App Services]:
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,terraform]
|
2021-11-10 10:16:04 +01:00
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "azurerm_app_service" "example" {
|
|
|
|
logs {
|
|
|
|
http_logs {
|
|
|
|
file_system {
|
|
|
|
retention_in_days = 90
|
|
|
|
retention_in_mb = 100
|
|
|
|
}
|
|
|
|
}
|
2021-11-10 10:12:33 +01:00
|
|
|
|
2022-06-01 17:19:35 +02:00
|
|
|
application_logs {
|
|
|
|
file_system_level = "Error"
|
|
|
|
azure_blob_storage {
|
|
|
|
retention_in_days = 90
|
|
|
|
level = "Error"
|
|
|
|
}
|
|
|
|
}
|
2022-03-07 11:45:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_subnetwork/[VPC Subnetwork]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
|
|
|
resource "google_compute_subnetwork" "example" {
|
|
|
|
name = "example"
|
|
|
|
ip_cidr_range = "10.2.0.0/16"
|
|
|
|
region = "us-central1"
|
2022-06-01 17:19:35 +02:00
|
|
|
network = google_compute_network.example.id
|
2022-03-07 11:45:11 +01:00
|
|
|
|
|
|
|
log_config {
|
|
|
|
aggregation_interval = "INTERVAL_10_MIN"
|
|
|
|
flow_sampling = 0.5
|
|
|
|
metadata = "INCLUDE_ALL_METADATA"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance/[SQL Database Instance]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
|
|
|
resource "google_sql_database_instance" "example" {
|
|
|
|
name = "example"
|
|
|
|
|
|
|
|
settings {
|
|
|
|
ip_configuration {
|
|
|
|
require_ssl = true
|
|
|
|
ipv4_enabled = true
|
|
|
|
}
|
|
|
|
database_flags {
|
|
|
|
name = "log_connections"
|
|
|
|
value = "on"
|
|
|
|
}
|
|
|
|
database_flags {
|
|
|
|
name = "log_disconnections"
|
|
|
|
value = "on"
|
|
|
|
}
|
|
|
|
database_flags {
|
|
|
|
name = "log_checkpoints"
|
|
|
|
value = "on"
|
|
|
|
}
|
|
|
|
database_flags {
|
|
|
|
name = "log_lock_waits"
|
|
|
|
value = "on"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
For GCP https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster/[Kubernetes Engine (GKE) cluster]:
|
|
|
|
[source,terraform]
|
|
|
|
----
|
2022-06-01 17:19:35 +02:00
|
|
|
resource "google_container_cluster" "example" {
|
2022-03-07 11:45:11 +01:00
|
|
|
name = "example"
|
|
|
|
logging_service = "logging.googleapis.com/kubernetes"
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-05-21 18:34:30 +02:00
|
|
|
include::../see.adoc[]
|
2023-06-22 10:38:01 +02:00
|
|
|
|
2021-09-20 15:38:42 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|