feat(redis): add basic msk module and dev-kafka environment
This commit is contained in:
parent
e3ecb5083e
commit
cbef46792a
@ -0,0 +1,16 @@
|
||||
name_prefix: "dev-kafka"
|
||||
|
||||
kafka_version: "3.6.0"
|
||||
|
||||
brokers:
|
||||
instance_type: "kafka.t3.small"
|
||||
number_of_broker_nodes: 2
|
||||
|
||||
ebs:
|
||||
volume_size: 50
|
||||
|
||||
vpc_id: "vpc-0d0d8d822fa215104"
|
||||
|
||||
subnet_ids:
|
||||
- "subnet-0c370f7ff7311388e"
|
||||
- "subnet-0b609b5773fe957fa"
|
||||
25
iac-template/terraform-standard/envs/dev-kafka/.gitignore
vendored
Normal file
25
iac-template/terraform-standard/envs/dev-kafka/.gitignore
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# Local terraform files
|
||||
.terraform/
|
||||
.terraform.lock.hcl
|
||||
terraform.tfstate
|
||||
terraform.tfstate.backup
|
||||
|
||||
# Auto tfvars generated by CI/CD or sensitive data
|
||||
*.tfvars
|
||||
*.auto.tfvars
|
||||
*.tfvars.json
|
||||
|
||||
# IDE / editor files
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
|
||||
# AWS credentials — never commit
|
||||
.aws/
|
||||
credentials
|
||||
config
|
||||
|
||||
# OS-specific
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
12
iac-template/terraform-standard/envs/dev-kafka/Makefile
Normal file
12
iac-template/terraform-standard/envs/dev-kafka/Makefile
Normal file
@ -0,0 +1,12 @@
|
||||
init:
|
||||
terraform init --upgrade
|
||||
|
||||
plan:
|
||||
terraform plan
|
||||
|
||||
apply:
|
||||
terraform apply -auto-approve
|
||||
|
||||
destroy:
|
||||
terraform destroy -auto-approve
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
terraform {
|
||||
backend "s3" {
|
||||
bucket = "svc-plus-iac-state"
|
||||
key = "account/dev/kafka/terraform.tfstate"
|
||||
region = "ap-northeast-1"
|
||||
dynamodb_table = "svc-plus-iac-state-dynamodb-lock"
|
||||
}
|
||||
}
|
||||
|
||||
26
iac-template/terraform-standard/envs/dev-kafka/main.tf
Normal file
26
iac-template/terraform-standard/envs/dev-kafka/main.tf
Normal file
@ -0,0 +1,26 @@
|
||||
locals {
|
||||
account = yamldecode(
|
||||
file("${path.root}/../../config/accounts/dev.yaml")
|
||||
)
|
||||
|
||||
kafka_conf = yamldecode(
|
||||
file("${path.root}/../../config/resources/dev-kafka/msk.yaml")
|
||||
)
|
||||
}
|
||||
|
||||
module "kafka" {
|
||||
source = "../../modules/msk"
|
||||
|
||||
name_prefix = local.kafka_conf.name_prefix
|
||||
kafka_version = local.kafka_conf.kafka_version
|
||||
|
||||
instance_type = local.kafka_conf.brokers.instance_type
|
||||
number_of_broker_nodes = local.kafka_conf.brokers.number_of_broker_nodes
|
||||
|
||||
volume_size = local.kafka_conf.ebs.volume_size
|
||||
|
||||
vpc_id = local.kafka_conf.vpc_id
|
||||
subnet_ids = local.kafka_conf.subnet_ids
|
||||
|
||||
tags = local.account.tags
|
||||
}
|
||||
11
iac-template/terraform-standard/envs/dev-kafka/outputs.tf
Normal file
11
iac-template/terraform-standard/envs/dev-kafka/outputs.tf
Normal file
@ -0,0 +1,11 @@
|
||||
output "cluster_arn" {
|
||||
value = module.kafka.cluster_arn
|
||||
}
|
||||
|
||||
output "bootstrap_brokers" {
|
||||
value = module.kafka.bootstrap_brokers
|
||||
}
|
||||
|
||||
output "zookeeper_connect_string" {
|
||||
value = module.kafka.zookeeper_connect_string
|
||||
}
|
||||
20
iac-template/terraform-standard/envs/dev-kafka/provider.tf
Normal file
20
iac-template/terraform-standard/envs/dev-kafka/provider.tf
Normal file
@ -0,0 +1,20 @@
|
||||
terraform {
|
||||
required_version = ">= 1.2"
|
||||
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 5.92.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = local.account.region
|
||||
|
||||
assume_role {
|
||||
role_arn = "arn:aws:iam::730335654753:role/TerraformDeployRole-Dev"
|
||||
session_name = "TerraformDevSession"
|
||||
}
|
||||
}
|
||||
|
||||
16
iac-template/terraform-standard/modules/msk/main.tf
Normal file
16
iac-template/terraform-standard/modules/msk/main.tf
Normal file
@ -0,0 +1,16 @@
|
||||
resource "aws_msk_cluster" "this" {
|
||||
cluster_name = var.name_prefix
|
||||
kafka_version = var.kafka_version
|
||||
number_of_broker_nodes = var.number_of_broker_nodes
|
||||
|
||||
broker_node_group_info {
|
||||
instance_type = var.instance_type
|
||||
client_subnets = var.subnet_ids
|
||||
ebs_volume_size = var.volume_size
|
||||
security_groups = []
|
||||
}
|
||||
|
||||
tags = merge(var.tags, {
|
||||
Name = var.name_prefix
|
||||
})
|
||||
}
|
||||
15
iac-template/terraform-standard/modules/msk/outputs.tf
Normal file
15
iac-template/terraform-standard/modules/msk/outputs.tf
Normal file
@ -0,0 +1,15 @@
|
||||
output "cluster_arn" {
|
||||
value = aws_msk_cluster.this.arn
|
||||
description = "MSK cluster ARN"
|
||||
}
|
||||
|
||||
output "bootstrap_brokers" {
|
||||
value = aws_msk_cluster.this.bootstrap_brokers
|
||||
description = "Bootstrap brokers connection string"
|
||||
}
|
||||
|
||||
output "zookeeper_connect_string" {
|
||||
value = aws_msk_cluster.this.zookeeper_connect_string
|
||||
description = "Zookeeper connection string"
|
||||
}
|
||||
|
||||
34
iac-template/terraform-standard/modules/msk/variables.tf
Normal file
34
iac-template/terraform-standard/modules/msk/variables.tf
Normal file
@ -0,0 +1,34 @@
|
||||
variable "name_prefix" {
|
||||
description = "Prefix for the MSK cluster name"
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "kafka_version" {
|
||||
type = string
|
||||
description = "Kafka version (e.g. 3.6.0)"
|
||||
}
|
||||
|
||||
variable "instance_type" {
|
||||
type = string
|
||||
description = "MSK broker instance type"
|
||||
}
|
||||
|
||||
variable "number_of_broker_nodes" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "volume_size" {
|
||||
type = number
|
||||
}
|
||||
|
||||
variable "vpc_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "subnet_ids" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "tags" {
|
||||
type = map(string)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user