Add group 1 audit logging encryption imports

This commit is contained in:
2026-11-14 13:31:59 +09:00
commit 3b54c4eb84
16 changed files with 607 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
# This file is maintained automatically by "terraform init".
# Manual edits may be lost in future updates.
provider "registry.terraform.io/hashicorp/aws" {
version = "6.73.0"
constraints = "~> 6.73"
hashes = [
"h1:87t8o/A0y2RE3PtCLx/BiASSrDrKSETYTF9jRvKc7aw=",
"zh:0f7403264fbfbcad526a5ddb9553be6ab12dba14e5901d0c2ccabc38d9ccf9a0",
"zh:26be4e8afc94ef29c98b8219dc49b19ce21a04d3f2b4e5be6116e9526ece0355",
"zh:2ba661a4a782fba053c411ce4d828dc148d7ed3998d073a28370a559400b1578",
"zh:2c422d0edd37bf7470c84f1d1f76487f30948768878204a65a18189bf878467a",
"zh:49f9d1486d48033d298977f7c288f8bbb22bb246f00926d1cb8b0bb98985451c",
"zh:4f946cf11667e1f3bce53fd5ad92eccf47fafaa1bbaa68c742173db61773a1da",
"zh:70beb5e13ddcdbeecb2a78be2b75d09a0fc6ce7e69b574c84a90924fd4262406",
"zh:8c5b974104ff9a887b29fdb2700cdbb5e6fd2eceef1cc3b28f523beda4fd8dfb",
"zh:9252068667bc6528ee6e83e837f3c2f901756136a33442455d61c6fa34e1160a",
"zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
"zh:9d086b792598b43e87502d47c4a3f388465b3a21a6a6b2783e48c89dee1f0543",
"zh:b5e6e77a43c1655285d99145b2cf0cc2da7a6c6ea3531d000cf8cca2c717693b",
"zh:b7ebe893e5ec76b362b61ffb28c67b40d890e0f59f5f2f8829765b16ee3e53b0",
"zh:c8c1e186839ad3cba37b427181af1e62eaf06c6daa5dca29105e1981dfaeb4c2",
"zh:e988377e7aea51e1fefe0b52c78bc725a11327051e20a71f81069191ee077d2d",
"zh:ee9188027919459a48bf9bac8f8f1dd172f5be198b88c2c47789b6daa8bb8bcb",
]
}
+8
View File
@@ -0,0 +1,8 @@
terraform {
backend "s3" {
key = "prod/terraform.tfstate"
region = "ap-northeast-1"
encrypt = true
use_lockfile = true
}
}
+80
View File
@@ -0,0 +1,80 @@
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket.this[each.key]
id = each.value
}
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket_versioning.this[each.key]
id = each.value
}
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket_server_side_encryption_configuration.this[each.key]
id = each.value
}
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket_public_access_block.this[each.key]
id = each.value
}
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket_ownership_controls.this[each.key]
id = each.value
}
import {
for_each = local.bucket_names
to = module.audit_logging_encryption.aws_s3_bucket_policy.this[each.key]
id = each.value
}
import {
for_each = {
cloudtrail = local.bucket_names.cloudtrail
flowlogs = local.bucket_names.flowlogs
}
to = module.audit_logging_encryption.aws_s3_bucket_lifecycle_configuration.this[each.key]
id = each.value
}
import {
to = module.audit_logging_encryption.aws_kms_key.vault
id = "46975f6d-881a-4188-8fdf-b641e1258a85"
}
import {
to = module.audit_logging_encryption.aws_kms_alias.vault
id = "alias/vault-kms"
}
import {
for_each = local.log_groups
to = module.audit_logging_encryption.aws_cloudwatch_log_group.this[each.key]
id = each.value.name
}
import {
to = module.audit_logging_encryption.aws_cloudwatch_dashboard.cost_check
id = "CostCheck"
}
import {
to = module.audit_logging_encryption.aws_sns_topic.notify_me
id = "arn:aws:sns:us-east-1:${var.account_id}:NotifyMe"
}
import {
to = module.audit_logging_encryption.aws_cloudwatch_metric_alarm.billing
id = "awsbilling-AWS-Service-Charges-total"
}
import {
to = module.audit_logging_encryption.aws_cloudtrail.management_events
id = "arn:aws:cloudtrail:${var.region}:${var.account_id}:trail/management-events"
}
+58
View File
@@ -0,0 +1,58 @@
locals {
bucket_names = {
obsidian = "${var.account_id}-obsidian-contents"
cloudtrail = "aws-cloudtrail-logs-${var.account_id}-97f3dbeb"
flowlogs = "kazu634-flowlogs"
}
log_groups = {
ecs_a49f = {
name = "/aws/ecs/default/nginx-a49f-48d8"
tags = {
AmazonECSManaged = "true"
category = "ecs-test"
}
}
ecs_d2a0 = {
name = "/aws/ecs/default/nginx-d2a0-c9dc"
tags = {
AmazonECSManaged = "true"
category = "ecs-test"
}
}
vpc_flowlogs = {
name = "nw-vpcflowlogs"
retention_in_days = 14
}
}
}
module "audit_logging_encryption" {
source = "../../modules/audit_logging_encryption"
providers = {
aws = aws
aws.us_east_1 = aws.us_east_1
}
region = var.region
name_prefix = var.name_prefix
account_id = var.account_id
bucket_names = local.bucket_names
bucket_tags = {
obsidian = {
Env = "Obsidian"
}
}
trail_name = "management-events"
kms_alias_name = "alias/vault-kms"
log_groups = local.log_groups
dashboard_name = "CostCheck"
dashboard_nat_gateway_id = "nat-13131172004a3e65b"
sns_topic_name = "NotifyMe"
billing_alarm_name = "awsbilling-AWS-Service-Charges-total"
}
+10
View File
@@ -0,0 +1,10 @@
provider "aws" {
profile = var.aws_profile
region = var.region
}
provider "aws" {
alias = "us_east_1"
profile = var.aws_profile
region = "us-east-1"
}
+27
View File
@@ -0,0 +1,27 @@
variable "aws_profile" {
description = "Read-only AWS CLI profile used for plan."
type = string
default = "aws-terraform-ro"
}
variable "region" {
description = "Primary production region."
type = string
default = "ap-northeast-1"
}
variable "name_prefix" {
description = "Name prefix passed to the reusable module."
type = string
default = "prod"
}
variable "account_id" {
description = "AWS account ID. Supply with TF_VAR_account_id; do not commit a tfvars file."
type = string
validation {
condition = can(regex("^[0-9]{12}$", var.account_id))
error_message = "account_id must contain exactly 12 digits."
}
}
+10
View File
@@ -0,0 +1,10 @@
terraform {
required_version = "= 1.17.2"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.73"
}
}
}