From 071853c6952407d554e7a41f1fe0613035f5ab96 Mon Sep 17 00:00:00 2001 From: Byungjin Park Date: Fri, 24 May 2024 15:00:20 +0900 Subject: [PATCH] Add cloudwatch sink configurations into region module --- modules/region/README.md | 7 ++++++- modules/region/cloudwatch.tf | 29 +++++++++++++++++++++++++++++ modules/region/outputs.tf | 10 ++++++++++ modules/region/variables.tf | 25 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 modules/region/cloudwatch.tf diff --git a/modules/region/README.md b/modules/region/README.md index 51afe79..42627c4 100644 --- a/modules/region/README.md +++ b/modules/region/README.md @@ -10,6 +10,8 @@ This module creates following resources. - `aws_guardduty_organization_admin_account` (optional) - `aws_inspector2_delegated_admin_account` (optional) - `aws_macie2_organization_admin_account` (optional) +- `aws_oam_sink` (optional) +- `aws_oam_sink_policy` (optional) - `aws_resourceexplorer2_index` (optional) - `aws_resourceexplorer2_view` (optional) - `aws_servicequotas_service_quota` (optional) @@ -26,12 +28,13 @@ This module creates following resources. | Name | Version | |------|---------| -| [aws](#provider\_aws) | 5.48.0 | +| [aws](#provider\_aws) | 5.51.0 | ## Modules | Name | Source | Version | |------|--------|---------| +| [cloudwatch\_oam\_sink](#module\_cloudwatch\_oam\_sink) | tedilabs/observability/aws//modules/cloudwatch-oam-sink | ~> 0.2.0 | | [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 | ## Resources @@ -56,6 +59,7 @@ This module creates following resources. | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| +| [cloudwatch](#input\_cloudwatch) | (Optional) The configuration of CloudWatch in the current AWS region. `cloudwatch` as defined below.
(Optional) `oam_sinks` - A list of CloudWatch OAM(Observability Access Manager) sinks. Each items of `oam_sinks` as defined below.
(Required) `name` - The name of the CloudWatch OAM sink.
(Optional) `telemetry_types` - A set of the telemetry types can be shared with it. Valid values are `AWS::CloudWatch::Metric`, `AWS::Logs::LogGroup`, `AWS::XRay::Trace`, `AWS::ApplicationInsights::Application`, `AWS::InternetMonitor::Monitor`.
(Optional) `allowed_source_accounts` - A list of the IDs of AWS accounts that will share data with this monitoring account.
(Optional) `allowed_source_organizations` - A list of the organization IDs of AWS accounts that will share data with this monitoring account.
(Optional) `allowed_source_organization_paths` - A list of the organization paths of the AWS accounts that will share data with this monitoring account.
(Optional) `tags` - A map of tags to add to the resource. |
object({
oam_sinks = optional(list(object({
name = string
telemetry_types = optional(set(string), [])
allowed_source_accounts = optional(list(string), [])
allowed_source_organizations = optional(list(string), [])
allowed_source_organization_paths = optional(list(string), [])
tags = optional(map(string), {})
})), [])
})
| `{}` | no | | [ebs\_default\_encryption](#input\_ebs\_default\_encryption) | (Optional) The configuration of the EBS default encryption. `ebs_default_encryption` as defined below.
(Optional) `enabled` - Whether or not default EBS encryption is enabled.
(Optional) `kms_key` - The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume. |
object({
enabled = optional(bool, false)
kms_key = optional(string)
})
| `{}` | no | | [ec2](#input\_ec2) | (Optional) The configuration of EC2 in the current AWS region. `ec2` as defined below.
(Optional) `ami_public_access_enabled` - Whether to allow or block public access for AMIs at the account level to prevent the public sharing of your AMIs in this region. Defaults to `false`.
(Optional) `instance_metadata_defaults` - The configuration of the regional instance metadata default settings. `instance_metadata_defaults` as defined below.
(Optional) `http_enabled` - Whether to enable or disable the HTTP metadata endpoint on your instances. Defaults to `null` (No preference).
(Optional) `http_token_required` - Whether or not the metadata service requires session tokens, also referred to as Instance Metadata Service Version 2 (IMDSv2). Defaults to `false`. Defaults to `null` (No preference).
(Optional) `http_put_response_hop_limit` - A desired HTTP PUT response hop limit for instance metadata requests. The larger the number, the further instance metadata requests can travel. Valid values are integer from `1` to `64`. Defaults to `null` (No preference).
(Optional) `instance_tags_enabled` - Whether to enable the access to instance tags from the instance metadata service. Defaults to `null` (No preference).
(Optional) `serial_console_enabled` - Whether serial console access is enabled for the current AWS region. Defaults to `false`. |
object({
ami_public_access_enabled = optional(bool, false)
instance_metadata_defaults = optional(object({
http_enabled = optional(bool)
http_token_required = optional(bool)
http_put_response_hop_limit = optional(number)
instance_tags_enabled = optional(bool)
}), {})
serial_console_enabled = optional(bool, false)
})
| `{}` | no | | [guardduty](#input\_guardduty) | (Optional) The configuration of GuardDuty in the current AWS region. `guardduty` as defined below.
(Optional) `delegated_administrator` - The AWS account ID for the account to designate as the delegated Amazon GuardDuty administrator account for the organization. The delegated administrator will be assigned the two GuardDuty roles required to administer GuardDuty policy in your organization. Can be used in only management account of the organization. |
object({
delegated_administrator = optional(string)
})
| `{}` | no | @@ -75,6 +79,7 @@ This module creates following resources. | Name | Description | |------|-------------| +| [cloudwdatch](#output\_cloudwdatch) | The region-level configurations of CloudWatch service.
`oam_sinks` - A list of CloudWatch OAM(Observability Access Manager) sinks. | | [code](#output\_code) | The short code of the current region. | | [description](#output\_description) | The description of the current region in this format: `Location (Region name)` | | [ebs](#output\_ebs) | The region-level configurations of EBS service.
`default_encryption` - The configurations for EBS Default Encryption. | diff --git a/modules/region/cloudwatch.tf b/modules/region/cloudwatch.tf new file mode 100644 index 0000000..5f79bc2 --- /dev/null +++ b/modules/region/cloudwatch.tf @@ -0,0 +1,29 @@ +################################################### +# CloudWatch OAM (Observability Access Manager) +################################################### + +module "cloudwatch_oam_sink" { + for_each = { + for sink in var.cloudwatch.oam_sinks : + sink.name => sink + } + + source = "tedilabs/observability/aws//modules/cloudwatch-oam-sink" + version = "~> 0.2.0" + + name = each.key + telemetry_types = each.value.telemetry_types + + allowed_source_accounts = each.value.allowed_source_accounts + allowed_source_organizations = each.value.allowed_source_organizations + allowed_source_organization_paths = each.value.allowed_source_organization_paths + + resource_group_enabled = false + module_tags_enabled = false + + tags = merge( + local.module_tags, + var.tags, + each.value.tags, + ) +} diff --git a/modules/region/outputs.tf b/modules/region/outputs.tf index e5b754e..5744166 100644 --- a/modules/region/outputs.tf +++ b/modules/region/outputs.tf @@ -18,6 +18,16 @@ output "description" { value = data.aws_region.this.description } +output "cloudwdatch" { + description = <