Narrow group 1 managed resources
This commit is contained in:
@@ -7,35 +7,6 @@ resource "aws_cloudwatch_log_group" "this" {
|
||||
tags = each.value.tags
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_dashboard" "cost_check" {
|
||||
dashboard_name = var.dashboard_name
|
||||
dashboard_body = jsonencode({
|
||||
widgets = [{
|
||||
type = "metric"
|
||||
x = 0
|
||||
y = 0
|
||||
width = 23
|
||||
height = 7
|
||||
properties = {
|
||||
view = "timeSeries"
|
||||
stacked = true
|
||||
metrics = [
|
||||
["AWS/NATGateway", "BytesOutToSource", "AvailabilityZone", "ap-northeast-1a", "NatGatewayId", var.dashboard_nat_gateway_id],
|
||||
[".", "BytesOutToDestination", ".", ".", ".", "."],
|
||||
[".", "BytesInFromDestination", ".", ".", ".", "."],
|
||||
[".", "BytesInFromSource", ".", ".", ".", "."],
|
||||
[".", "BytesInFromDestination", ".", "ap-northeast-1c", ".", "."],
|
||||
[".", "BytesInFromSource", ".", ".", ".", "."],
|
||||
[".", "BytesOutToDestination", ".", ".", ".", "."],
|
||||
[".", "BytesOutToSource", ".", ".", ".", "."],
|
||||
]
|
||||
region = var.region
|
||||
title = "NAT Gayeway通信量"
|
||||
}
|
||||
}]
|
||||
})
|
||||
}
|
||||
|
||||
resource "aws_cloudwatch_metric_alarm" "billing" {
|
||||
provider = aws.us_east_1
|
||||
|
||||
@@ -49,7 +20,7 @@ resource "aws_cloudwatch_metric_alarm" "billing" {
|
||||
statistic = "Maximum"
|
||||
threshold = 16
|
||||
actions_enabled = true
|
||||
alarm_actions = [aws_sns_topic.notify_me.arn]
|
||||
alarm_actions = var.billing_alarm_action_arns
|
||||
|
||||
dimensions = {
|
||||
Currency = "USD"
|
||||
|
||||
@@ -1,29 +1,12 @@
|
||||
locals {
|
||||
buckets = {
|
||||
obsidian = coalesce(var.bucket_names.obsidian, "${var.name_prefix}-obsidian-contents")
|
||||
cloudtrail = coalesce(var.bucket_names.cloudtrail, "${var.name_prefix}-cloudtrail-logs")
|
||||
flowlogs = coalesce(var.bucket_names.flowlogs, "${var.name_prefix}-flowlogs")
|
||||
}
|
||||
|
||||
trail_arn = "arn:aws:cloudtrail:${var.region}:${var.account_id}:trail/${var.trail_name}"
|
||||
sns_topic_arn = "arn:aws:sns:us-east-1:${var.account_id}:${var.sns_topic_name}"
|
||||
trail_arn = "arn:aws:cloudtrail:${var.region}:${var.account_id}:trail/${var.trail_name}"
|
||||
|
||||
bucket_policies = {
|
||||
obsidian = jsonencode({
|
||||
Version = "2012-10-17"
|
||||
Statement = [{
|
||||
Effect = "Allow"
|
||||
Principal = {
|
||||
AWS = "arn:aws:iam::${var.account_id}:user/${var.account_id}-obsidian-contents"
|
||||
}
|
||||
Action = "s3:*"
|
||||
Resource = [
|
||||
"arn:aws:s3:::${local.buckets.obsidian}",
|
||||
"arn:aws:s3:::${local.buckets.obsidian}/*",
|
||||
]
|
||||
}]
|
||||
})
|
||||
|
||||
cloudtrail = jsonencode({
|
||||
Version = "2012-10-17"
|
||||
Statement = [
|
||||
|
||||
@@ -3,7 +3,6 @@ resource "aws_s3_bucket" "this" {
|
||||
|
||||
bucket = each.value
|
||||
force_destroy = false
|
||||
tags = lookup(var.bucket_tags, each.key, {})
|
||||
|
||||
lifecycle {
|
||||
prevent_destroy = true
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
resource "aws_sns_topic" "notify_me" {
|
||||
provider = aws.us_east_1
|
||||
|
||||
name = var.sns_topic_name
|
||||
}
|
||||
@@ -16,19 +16,12 @@ variable "account_id" {
|
||||
variable "bucket_names" {
|
||||
description = "Optional existing bucket names. Omitted values are derived from name_prefix for isolated tests."
|
||||
type = object({
|
||||
obsidian = optional(string)
|
||||
cloudtrail = optional(string)
|
||||
flowlogs = optional(string)
|
||||
})
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "bucket_tags" {
|
||||
description = "Existing tags keyed by the logical bucket name."
|
||||
type = map(map(string))
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "trail_name" {
|
||||
description = "CloudTrail trail name."
|
||||
type = string
|
||||
@@ -48,22 +41,12 @@ variable "log_groups" {
|
||||
}))
|
||||
}
|
||||
|
||||
variable "dashboard_name" {
|
||||
description = "CloudWatch dashboard name."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "dashboard_nat_gateway_id" {
|
||||
description = "NAT Gateway ID referenced by the existing dashboard widget."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "sns_topic_name" {
|
||||
description = "SNS topic name in us-east-1."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "billing_alarm_name" {
|
||||
description = "CloudWatch billing alarm name in us-east-1."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "billing_alarm_action_arns" {
|
||||
description = "Existing notification target ARNs for the billing alarm. The targets themselves are not managed by this module."
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user