Skip to content

Commit

Permalink
added ebs volumes and volume attachments for all non-root EBS volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmahmood72 committed Oct 9, 2023
1 parent 3d4d021 commit 1708fb2
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 22 deletions.
10 changes: 9 additions & 1 deletion terraform/environments/apex/application_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
"ec2instancetype": "t3.medium",
"mp_vpc_cidr": "10.26.56.0/21",
"lz_shared_nonprod_mgmt_vpc_cidr": "10.200.0.0/20",
"lz_shared_prod_mgmt_vpc_cidr": "10.200.16.0/20"
"lz_shared_prod_mgmt_vpc_cidr": "10.200.16.0/20",
"u01_orahome_size": "40",
"u01_orahome_snapshot": "snap-0fb84db7af842db4b",
"u02_oradata_size": "100",
"u02_oradata_snapshot": "snap-002a82aef2628b621",
"u03_redo_size": "50",
"u03_redo_snapshot": "snap-08499cdd392b9b7dc",
"u04_arch_size": "50",
"u04_arch_snapshot": "snap-03b6eb947cfe779d8"
},
"test": {
"example_var": "test-data"
Expand Down
102 changes: 81 additions & 21 deletions terraform/environments/apex/ec2.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_instance" "apex_db_instance" {
volume_type = "gp2"
tags = merge(
local.tags,
{ "Name" = "${local.application_name}-root-volume" },
{ "Name" = "${local.application_name}db-ec2-root" },
)
}

Expand Down Expand Up @@ -146,29 +146,89 @@ resource "aws_iam_role_policy" "ec2_instance_policy" {
})
}

# resource "aws_ebs_volume" "EC2ServerVolumeORAHOME" {
# availability_zone = "eu-west-2a"
# size = local.application_data.accounts[local.environment].orahomesize
# type = "gp3"
# encrypted = true
# kms_key_id = data.aws_kms_key.ebs_shared.key_id
# snapshot_id = local.application_data.accounts[local.environment].orahome_snapshot
resource "aws_ebs_volume" "u01-orahome" {
availability_zone = "eu-west-2a"
size = local.application_data.accounts[local.environment].u01_orahome_size
type = "gp3"
encrypted = true
kms_key_id = data.aws_kms_key.ebs_shared.key_id
snapshot_id = local.application_data.accounts[local.environment].u01_orahome_snapshot
lifecycle {
ignore_changes = [kms_key_id]
}
tags = merge(
local.tags,
{ "Name" = "${local.application_name}db-ec2-u01-orahome" },
)
}
resource "aws_volume_attachment" "u01-orahome" {
device_name = "/dev/sdb"
volume_id = aws_ebs_volume.u01-orahome.id
instance_id = aws_instance.apex_db_instance.id
}

# lifecycle {
# ignore_changes = [kms_key_id]
# }
resource "aws_ebs_volume" "u02-oradata" {
availability_zone = "eu-west-2a"
size = local.application_data.accounts[local.environment].u02_oradata_size
type = "gp3"
encrypted = true
kms_key_id = data.aws_kms_key.ebs_shared.key_id
snapshot_id = local.application_data.accounts[local.environment].u02_oradata_snapshot
lifecycle {
ignore_changes = [kms_key_id]
}
tags = merge(
local.tags,
{ "Name" = "${local.application_name}db-ec2-u02-oradata" },
)
}
resource "aws_volume_attachment" "u02-oradata" {
device_name = "/dev/sdc"
volume_id = aws_ebs_volume.u02-oradata.id
instance_id = aws_instance.apex_db_instance.id
}

# tags = merge(
# local.tags,
# { "Name" = "${local.application_name}-EC2ServerVolumeORAHOME" },
# )
# }
resource "aws_ebs_volume" "u03-redo" {
availability_zone = "eu-west-2a"
size = local.application_data.accounts[local.environment].u03_redo_size
type = "gp3"
encrypted = true
kms_key_id = data.aws_kms_key.ebs_shared.key_id
snapshot_id = local.application_data.accounts[local.environment].u03_redo_snapshot
lifecycle {
ignore_changes = [kms_key_id]
}
tags = merge(
local.tags,
{ "Name" = "${local.application_name}db-ec2-u03-redo" },
)
}
resource "aws_volume_attachment" "u03-redo" {
device_name = "/dev/sdd"
volume_id = aws_ebs_volume.u03-redo.id
instance_id = aws_instance.apex_db_instance.id
}

# resource "aws_volume_attachment" "oas_EC2ServerVolume01" {
# device_name = "/dev/sdb"
# volume_id = aws_ebs_volume.EC2ServerVolumeORAHOME.id
# instance_id = aws_instance.oas_app_instance.id
# }
resource "aws_ebs_volume" "u04-arch" {
availability_zone = "eu-west-2a"
size = local.application_data.accounts[local.environment].u04_arch_size
type = "gp3"
encrypted = true
kms_key_id = data.aws_kms_key.ebs_shared.key_id
snapshot_id = local.application_data.accounts[local.environment].u04_arch_snapshot
lifecycle {
ignore_changes = [kms_key_id]
}
tags = merge(
local.tags,
{ "Name" = "${local.application_name}db-ec2-u04-arch" },
)
}
resource "aws_volume_attachment" "u04-arch" {
device_name = "/dev/sde"
volume_id = aws_ebs_volume.u04-arch.id
instance_id = aws_instance.apex_db_instance.id
}

resource "aws_route53_record" "apex-db" {
provider = aws.core-vpc
Expand Down

0 comments on commit 1708fb2

Please sign in to comment.