Skip to content

Commit

Permalink
Add cloudwatch sink configurations into region module
Browse files Browse the repository at this point in the history
  • Loading branch information
posquit0 committed May 24, 2024
1 parent 9c87514 commit 071853c
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/region/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -26,12 +28,13 @@ This module creates following resources.

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.48.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.51.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_cloudwatch_oam_sink"></a> [cloudwatch\_oam\_sink](#module\_cloudwatch\_oam\_sink) | tedilabs/observability/aws//modules/cloudwatch-oam-sink | ~> 0.2.0 |
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 |

## Resources
Expand All @@ -56,6 +59,7 @@ This module creates following resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cloudwatch"></a> [cloudwatch](#input\_cloudwatch) | (Optional) The configuration of CloudWatch in the current AWS region. `cloudwatch` as defined below.<br> (Optional) `oam_sinks` - A list of CloudWatch OAM(Observability Access Manager) sinks. Each items of `oam_sinks` as defined below.<br> (Required) `name` - The name of the CloudWatch OAM sink.<br> (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`.<br> (Optional) `allowed_source_accounts` - A list of the IDs of AWS accounts that will share data with this monitoring account.<br> (Optional) `allowed_source_organizations` - A list of the organization IDs of AWS accounts that will share data with this monitoring account.<br> (Optional) `allowed_source_organization_paths` - A list of the organization paths of the AWS accounts that will share data with this monitoring account.<br> (Optional) `tags` - A map of tags to add to the resource. | <pre>object({<br> oam_sinks = optional(list(object({<br> name = string<br> telemetry_types = optional(set(string), [])<br> allowed_source_accounts = optional(list(string), [])<br> allowed_source_organizations = optional(list(string), [])<br> allowed_source_organization_paths = optional(list(string), [])<br> tags = optional(map(string), {})<br> })), [])<br> })</pre> | `{}` | no |
| <a name="input_ebs_default_encryption"></a> [ebs\_default\_encryption](#input\_ebs\_default\_encryption) | (Optional) The configuration of the EBS default encryption. `ebs_default_encryption` as defined below.<br> (Optional) `enabled` - Whether or not default EBS encryption is enabled.<br> (Optional) `kms_key` - The ARN of the AWS Key Management Service (AWS KMS) customer master key (CMK) to use to encrypt the EBS volume. | <pre>object({<br> enabled = optional(bool, false)<br> kms_key = optional(string)<br> })</pre> | `{}` | no |
| <a name="input_ec2"></a> [ec2](#input\_ec2) | (Optional) The configuration of EC2 in the current AWS region. `ec2` as defined below.<br> (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`.<br> (Optional) `instance_metadata_defaults` - The configuration of the regional instance metadata default settings. `instance_metadata_defaults` as defined below.<br> (Optional) `http_enabled` - Whether to enable or disable the HTTP metadata endpoint on your instances. Defaults to `null` (No preference).<br> (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).<br> (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).<br> (Optional) `instance_tags_enabled` - Whether to enable the access to instance tags from the instance metadata service. Defaults to `null` (No preference).<br> (Optional) `serial_console_enabled` - Whether serial console access is enabled for the current AWS region. Defaults to `false`. | <pre>object({<br> ami_public_access_enabled = optional(bool, false)<br> instance_metadata_defaults = optional(object({<br> http_enabled = optional(bool)<br> http_token_required = optional(bool)<br> http_put_response_hop_limit = optional(number)<br> instance_tags_enabled = optional(bool)<br> }), {})<br> serial_console_enabled = optional(bool, false)<br> })</pre> | `{}` | no |
| <a name="input_guardduty"></a> [guardduty](#input\_guardduty) | (Optional) The configuration of GuardDuty in the current AWS region. `guardduty` as defined below.<br> (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. | <pre>object({<br> delegated_administrator = optional(string)<br> })</pre> | `{}` | no |
Expand All @@ -75,6 +79,7 @@ This module creates following resources.

| Name | Description |
|------|-------------|
| <a name="output_cloudwdatch"></a> [cloudwdatch](#output\_cloudwdatch) | The region-level configurations of CloudWatch service.<br> `oam_sinks` - A list of CloudWatch OAM(Observability Access Manager) sinks. |
| <a name="output_code"></a> [code](#output\_code) | The short code of the current region. |
| <a name="output_description"></a> [description](#output\_description) | The description of the current region in this format: `Location (Region name)` |
| <a name="output_ebs"></a> [ebs](#output\_ebs) | The region-level configurations of EBS service.<br> `default_encryption` - The configurations for EBS Default Encryption. |
Expand Down
29 changes: 29 additions & 0 deletions modules/region/cloudwatch.tf
Original file line number Diff line number Diff line change
@@ -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,
)
}
10 changes: 10 additions & 0 deletions modules/region/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ output "description" {
value = data.aws_region.this.description
}

output "cloudwdatch" {
description = <<EOF
The region-level configurations of CloudWatch service.
`oam_sinks` - A list of CloudWatch OAM(Observability Access Manager) sinks.
EOF
value = {
oam_sinks = module.cloudwatch_oam_sink
}
}

output "ebs" {
description = <<EOF
The region-level configurations of EBS service.
Expand Down
25 changes: 25 additions & 0 deletions modules/region/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
variable "cloudwatch" {
description = <<EOF
(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.
EOF
type = 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), {})
})), [])
})
default = {}
nullable = false
}

variable "ebs_default_encryption" {
description = <<EOF
(Optional) The configuration of the EBS default encryption. `ebs_default_encryption` as defined below.
Expand Down

0 comments on commit 071853c

Please sign in to comment.