Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
backend.tf
.terraform*
*.swp
*tfvars
credentials.json
*.pem
75 changes: 75 additions & 0 deletions terraform/aws/examples/alb/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
data "aws_vpc" "mng_intranet" {
tags = {
Name = "mng-vpc-intranet01"
}
}

data "aws_subnet" "trusted_a" {
vpc_id = data.aws_vpc.mng_intranet.id

tags = {
Name = "mng-vpc-subnet-trusteda01"
}
}

data "aws_subnet" "trusted_c" {
vpc_id = data.aws_vpc.mng_intranet.id

tags = {
Name = "mng-vpc-subnet-trustedc01"
}
}

data "aws_security_group" "alb" {
filter {
name = "tag:Name"
values = ["mng-vpc-sg-default01"]
}

vpc_id = data.aws_vpc.mng_intranet.id
}

data "aws_acm_certificate" "this" {
domain = "cloudmigration-poc.internal"
most_recent = true
statuses = ["ISSUED"]
}

module "alb" {
source = "../../modules/alb"

name = "mng-alb-cloudmigration-poc01"
vpc_id = data.aws_vpc.mng_intranet.id

subnet_ids = [
data.aws_subnet.trusted_a.id,
data.aws_subnet.trusted_c.id,
]

security_group_ids = [
data.aws_security_group.alb.id,
]

idle_timeout = 60

target_group_name = "cloudmigration-poc-tg01"
target_group_port = 8080
target_type = "ip"

health_check_path = "/health"
health_check_healthy_threshold = 3
health_check_unhealthy_threshold = 3
health_check_timeout = 5
health_check_interval = 30
health_check_matcher = "200"

ssl_policy = "ELBSecurityPolicy-TLS-1-2-2017-01"
certificate_arn = data.aws_acm_certificate.this.arn

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}

22 changes: 22 additions & 0 deletions terraform/aws/examples/alb/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_version = ">= 1.0.0"
}

provider "aws" {
region = var.region

default_tags {
tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
}

variable "region" {
type = string
description = "The default region to use"
default = "ap-northeast-1"
}

23 changes: 23 additions & 0 deletions terraform/aws/examples/cloudwatch-log-groups/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data "aws_kms_key" "logs" {
key_id = "alias/mng-kms-logs01"
}

module "cloudwatch_log_groups" {
source = "../../modules/cloudwatch-log-groups"

log_group_names = [
"/ecs/cloudmigration-poc-app",
"/rds/aurora-postgres/cloudmigration-poc",
"/dms/cloudmigration-poc",
]

kms_key_arn = data.aws_kms_key.logs.arn
retention_in_days = 30

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}

22 changes: 22 additions & 0 deletions terraform/aws/examples/cloudwatch-log-groups/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_version = ">= 1.0.0"
}

provider "aws" {
region = var.region

default_tags {
tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
}

variable "region" {
type = string
description = "The default region to use"
default = "ap-northeast-1"
}

95 changes: 95 additions & 0 deletions terraform/aws/examples/dms-migration/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
data "aws_kms_key" "dms" {
key_id = "alias/mng-kms-dms01"
}

data "aws_dms_replication_subnet_group" "trusted" {
replication_subnet_group_id = "mng-dms-subnet-group-trusted01"
}

data "aws_security_group" "dms" {
filter {
name = "tag:Name"
values = ["mng-vpc-sg-default01"]
}
}

locals {
table_mappings = jsonencode({
rules = [
{
rule-type = "selection"
rule-id = "1"
rule-name = "include-all"
object-locator = {
schema-name = "%"
table-name = "%"
}
rule-action = "include"
}
]
})

task_settings = jsonencode({
FullLoadSettings = {
TargetTablePrepMode = "DO_NOTHING"
}
})
}

# DMS migration: on-prem PostgreSQL (source) -> Aurora PostgreSQL in AWS (target).
# Endpoints are created by the module from the connection details below.
module "dms_migration" {
source = "../../modules/dms-migration"

replication_instance_id = "mng-dms-replication-instance01"
replication_instance_class = "dms.t3.medium"

allocated_storage = 100
engine_version = "3.5.0"
multi_az = false

replication_subnet_group_id = data.aws_dms_replication_subnet_group.trusted.replication_subnet_group_id
vpc_security_group_ids = [data.aws_security_group.dms.id]

kms_key_arn = data.aws_kms_key.dms.arn

maintenance_window = "sun:04:00-sun:05:00"
auto_minor_version_upgrade = true
allow_major_version_upgrade = false
apply_immediately = false

replication_task_id = "mng-dms-task-cloudmigration-poc01"
migration_type = "full-load-and-cdc"
table_mappings = local.table_mappings
replication_task_settings = local.task_settings

# Source: on-prem PostgreSQL
source_endpoint_id = "mng-dms-endpoint-source-onprem-postgres01"
source_engine_name = "postgres"
source_server_name = "onprem-db.example.internal"
source_port = 5432
source_database_name = "myapp"
source_username = "dms_user"
source_password = "ChangeMeOnPrem123"
source_ssl_mode = "require"
source_extra_connection_attributes = ""

# Target: Aurora PostgreSQL in AWS (use your Aurora cluster endpoint in production)
target_endpoint_id = "mng-dms-endpoint-target-aurora01"
target_engine_name = "aurora-postgresql"
target_server_name = "mng-aurora-postgres-cloudmigration-poc01.xxxxx.ap-northeast-1.rds.amazonaws.com"
target_port = 5432
target_database_name = "cloudmigration"
target_username = "cloudmigration_admin"
target_password = "ChangeMeAurora123"
target_ssl_mode = "require"
target_extra_connection_attributes = ""

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}


22 changes: 22 additions & 0 deletions terraform/aws/examples/dms-migration/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_version = ">= 1.0.0"
}

provider "aws" {
region = var.region

default_tags {
tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
}

variable "region" {
type = string
description = "The default region to use"
default = "ap-northeast-1"
}

20 changes: 20 additions & 0 deletions terraform/aws/examples/ecr-repository/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
data "aws_kms_key" "ecr" {
key_id = "alias/mng-kms-ecr01"
}

module "ecr_repository" {
source = "../../modules/ecr-repository"

name = "mng-ecr-cloudmigration-poc-app01"
kms_key_arn = data.aws_kms_key.ecr.arn

scan_on_push = true
image_tag_mutability = "IMMUTABLE"

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}

22 changes: 22 additions & 0 deletions terraform/aws/examples/ecr-repository/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_version = ">= 1.0.0"
}

provider "aws" {
region = var.region

default_tags {
tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
}

variable "region" {
type = string
description = "The default region to use"
default = "ap-northeast-1"
}

14 changes: 14 additions & 0 deletions terraform/aws/examples/ecs-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module "ecs_cluster" {
source = "../../modules/ecs-cluster"

name = "mng-ecs-cluster-fargate01"

enable_container_insights = true

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}

22 changes: 22 additions & 0 deletions terraform/aws/examples/ecs-cluster/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
terraform {
required_version = ">= 1.0.0"
}

provider "aws" {
region = var.region

default_tags {
tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
}

variable "region" {
type = string
description = "The default region to use"
default = "ap-northeast-1"
}

38 changes: 38 additions & 0 deletions terraform/aws/examples/rds-postgres/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module "rds_postgres" {
source = "../../modules/rds-postgres"

identifier = "mng-aurora-postgres-cloudmigration-poc01"

engine_version = "16.5"
engine_mode = "provisioned"

instance_class = "db.t4g.micro"
instance_count = 2

db_name = "cloudmigration"
username = "cloudmigration_admin"
password = "ChangeMe123!"

subnet_ids = ["subnet-123", "subnet-234"]
vpc_security_group_ids = ["sec-grp-5432"]

kms_key_id = "arn:aws:kms:ap-northeast-1:123456789012:key/key-id"

backup_retention_period = 7
backup_window = "03:00-04:00"
maintenance_window = "sun:04:00-sun:05:00"
multi_az = false

deletion_protection = true
skip_final_snapshot = false
final_snapshot_identifier = "mng-aurora-postgres-cloudmigration-poc01-final"

auto_minor_version_upgrade = true
apply_immediately = false

tags = {
ManagedBy = "terraform"
Project = "CloudMigration-PoC"
Environment = "Type-Int"
}
}
Loading