generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9484 from ministryofjustice/CC-3081
Cc 3081
- Loading branch information
Showing
9 changed files
with
1,020 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
terraform/environments/ccms-ebs-upgrade/ccms-ec2-ftp-sg.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Security Group for FTP Server | ||
|
||
resource "aws_security_group" "ec2_sg_ftp" { | ||
count = local.is-test ? 1 : 0 | ||
name = "ec2_sg_ftp" | ||
description = "Security Group for FTP Server" | ||
vpc_id = data.aws_vpc.shared.id | ||
tags = merge(local.tags, | ||
{ Name = lower(format("sg-%s-%s-FTP", local.application_name, local.environment)) } | ||
) | ||
} | ||
|
||
# INGRESS Rules | ||
|
||
### FTP | ||
|
||
resource "aws_security_group_rule" "ingress_traffic_ftp_20" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "ingress" | ||
description = "FTP" | ||
protocol = "TCP" | ||
from_port = 20 | ||
to_port = 21 | ||
cidr_blocks = [data.aws_vpc.shared.cidr_block, | ||
local.application_data.accounts[local.environment].lz_aws_subnet_env] | ||
} | ||
|
||
### FTP Passive Ports | ||
|
||
resource "aws_security_group_rule" "ingress_traffic_ftp_3000" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "ingress" | ||
description = "FTP Passive Ports" | ||
protocol = "TCP" | ||
from_port = 3000 | ||
to_port = 3010 | ||
cidr_blocks = [data.aws_vpc.shared.cidr_block, | ||
local.application_data.accounts[local.environment].lz_aws_subnet_env] | ||
} | ||
|
||
### SSH | ||
|
||
resource "aws_security_group_rule" "ingress_traffic_ftp_22" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "ingress" | ||
description = "SSH" | ||
protocol = "TCP" | ||
from_port = 22 | ||
to_port = 22 | ||
cidr_blocks = [data.aws_vpc.shared.cidr_block, | ||
local.application_data.accounts[local.environment].lz_aws_subnet_env] | ||
} | ||
|
||
|
||
|
||
# EGRESS Rules | ||
|
||
### FTP | ||
|
||
resource "aws_security_group_rule" "egress_traffic_ftp_20" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "egress" | ||
description = "FTP" | ||
protocol = "TCP" | ||
from_port = 20 | ||
to_port = 21 | ||
cidr_blocks = [data.aws_vpc.shared.cidr_block, | ||
local.application_data.accounts[local.environment].lz_aws_subnet_env] | ||
} | ||
|
||
### SSH | ||
|
||
resource "aws_security_group_rule" "egress_traffic_ftp_22" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "egress" | ||
description = "SSH" | ||
protocol = "TCP" | ||
from_port = 22 | ||
to_port = 22 | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
### HTTPS | ||
|
||
resource "aws_security_group_rule" "egress_traffic_ftp_443" { | ||
count = local.is-test ? 1 : 0 | ||
security_group_id = aws_security_group.ec2_sg_ftp[count.index].id | ||
type = "egress" | ||
description = "HTTPS" | ||
protocol = "TCP" | ||
from_port = 443 | ||
to_port = 443 | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} |
105 changes: 105 additions & 0 deletions
105
terraform/environments/ccms-ebs-upgrade/ccms-ec2-ftp.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
resource "aws_instance" "ec2_ftp" { | ||
count = local.is-test ? 1 : 0 | ||
instance_type = local.application_data.accounts[local.environment].ec2_instance_type_ftp | ||
ami = local.application_data.accounts[local.environment].ftp_ami_id | ||
key_name = local.application_data.accounts[local.environment].key_name | ||
vpc_security_group_ids = [aws_security_group.ec2_sg_ftp[count.index].id] | ||
subnet_id = data.aws_subnet.private_subnets_a.id | ||
monitoring = true | ||
ebs_optimized = false | ||
associate_public_ip_address = false | ||
iam_instance_profile = aws_iam_instance_profile.iam_instace_profile_ccms_base.name | ||
|
||
# Due to a bug in terraform wanting to rebuild the ec2 if more than 1 ebs block is attached, we need the lifecycle clause below. | ||
lifecycle { | ||
ignore_changes = [ | ||
ebs_block_device, | ||
root_block_device, | ||
user_data, | ||
user_data_replace_on_change | ||
] | ||
} | ||
user_data_replace_on_change = false | ||
user_data = base64encode(templatefile("./templates/ec2_user_data_ftp.sh", { | ||
environment = "${local.environment}" | ||
lz_aws_account_id_env = "${local.application_data.accounts[local.environment].lz_aws_account_id_env}" | ||
lz_ftp_bucket_environment = "${local.application_data.accounts[local.environment].lz_ftp_bucket_environment}" | ||
hostname = "ftp" | ||
})) | ||
|
||
metadata_options { | ||
http_endpoint = "enabled" | ||
http_tokens = "required" | ||
} | ||
|
||
# Increase the volume size of the root volume | ||
root_block_device { | ||
volume_type = "gp3" | ||
volume_size = 50 | ||
iops = 3000 | ||
encrypted = true | ||
kms_key_id = data.aws_kms_key.ebs_shared.key_id | ||
tags = merge(local.tags, | ||
{ Name = lower(format("%s-%s", local.application_data.accounts[local.environment].instance_role_ftp, "root")) }, | ||
{ device-name = "/dev/sda1" } | ||
) | ||
} | ||
|
||
ebs_block_device { | ||
device_name = "/dev/sdb" | ||
volume_type = "gp3" | ||
volume_size = 20 | ||
// iops = 12000 | ||
encrypted = true | ||
kms_key_id = data.aws_kms_key.ebs_shared.key_id | ||
tags = merge(local.tags, | ||
{ Name = lower(format("%s-%s", local.application_data.accounts[local.environment].instance_role_ftp, "ftp")) }, | ||
{ device-name = "/dev/sda1" } | ||
) | ||
} | ||
|
||
tags = merge(local.tags, | ||
{ Name = lower(format("ec2-%s-%s-FTP", local.application_name, local.environment)) }, | ||
{ instance-role = local.application_data.accounts[local.environment].instance_role_ftp }, | ||
{ backup = "true" } | ||
) | ||
|
||
depends_on = [aws_security_group.ec2_sg_ftp] | ||
} | ||
|
||
module "cw-ftp-ec2" { | ||
count = local.is-test ? 1 : 0 | ||
source = "./modules/cw-ec2" | ||
|
||
short_env = local.application_data.accounts[local.environment].short_env | ||
name = "ec2-ftp" | ||
topic = aws_sns_topic.cw_alerts.arn | ||
instanceId = aws_instance.ec2_ftp[count.index].id | ||
imageId = local.application_data.accounts[local.environment].ftp_ami_id | ||
instanceType = local.application_data.accounts[local.environment].ec2_instance_type_ftp | ||
fileSystem = "xfs" # Linux root filesystem | ||
rootDevice = "nvme0n1p1" # This is used by default for root on all the ec2 images | ||
|
||
cpu_eval_periods = local.application_data.cloudwatch_ec2.cpu.eval_periods | ||
cpu_datapoints = local.application_data.cloudwatch_ec2.cpu.eval_periods | ||
cpu_period = local.application_data.cloudwatch_ec2.cpu.period | ||
cpu_threshold = local.application_data.cloudwatch_ec2.cpu.threshold | ||
|
||
mem_eval_periods = local.application_data.cloudwatch_ec2.mem.eval_periods | ||
mem_datapoints = local.application_data.cloudwatch_ec2.mem.eval_periods | ||
mem_period = local.application_data.cloudwatch_ec2.mem.period | ||
mem_threshold = local.application_data.cloudwatch_ec2.mem.threshold | ||
|
||
disk_eval_periods = local.application_data.cloudwatch_ec2.disk.eval_periods | ||
disk_datapoints = local.application_data.cloudwatch_ec2.disk.eval_periods | ||
disk_period = local.application_data.cloudwatch_ec2.disk.period | ||
disk_threshold = local.application_data.cloudwatch_ec2.disk.threshold | ||
|
||
insthc_eval_periods = local.application_data.cloudwatch_ec2.insthc.eval_periods | ||
insthc_period = local.application_data.cloudwatch_ec2.insthc.period | ||
insthc_threshold = local.application_data.cloudwatch_ec2.insthc.threshold | ||
|
||
syshc_eval_periods = local.application_data.cloudwatch_ec2.syshc.eval_periods | ||
syshc_period = local.application_data.cloudwatch_ec2.syshc.period | ||
syshc_threshold = local.application_data.cloudwatch_ec2.syshc.threshold | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#### This file can be used to store secrets specific to the member account #### | ||
|
||
resource "aws_secretsmanager_secret" "secret_ftp_s3" { | ||
count = local.is-test ? 1 : 0 | ||
name = "ftp-s3-${local.environment}-aws-key" | ||
description = "AWS credentials for mounting of s3 buckets for the FTP Service to access" | ||
|
||
tags = merge(local.tags, | ||
{ Name = "ftp-s3-${local.environment}-aws-key" } | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
terraform/environments/ccms-ebs-upgrade/scripts/cron-ftp-15-v2.ksh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# This job runs out of cron and sequentially runs jobs every 15 minutes. | ||
# | ||
# RBS Outbound | ||
#/export/home/aebsprod/scripts/curl-ftp-v2.ksh 001 | ||
# | ||
# Allpay Outbound | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 002 | ||
# | ||
# Eckoh Outbound | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 003 | ||
# | ||
# Rossendales Outbound | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 004 | ||
# | ||
#TDX Outbound | ||
# added this script to cope with files owned by oebsprod and unix2dos them | ||
# psb 14sep2016 | ||
/export/home/aebsprod/scripts/unix2dos.ksh | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 008 | ||
# | ||
# Microgen Bacway Outbound RBS | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 010 | ||
# | ||
# RBS Inbound | ||
/export/home/aebsprod/scripts/curl-ftp-v2.ksh 011 | ||
# | ||
# Citibank Inbound | ||
## js /export/home/aebsprod/scripts/curl-ftp-v2.ksh 012 | ||
# | ||
# LFFramework Inbound | ||
## js /export/home/aebsprod/scripts/curl-ftp-v2.ksh 013 | ||
# | ||
# Barclaycard Inbound | ||
## js /export/home/aebsprod/scripts/curl-ftp-v2.ksh 014 | ||
# | ||
# Barclaycard Outbound | ||
## js /export/home/aebsprod/scripts/curl-ftp-v2.ksh 007 | ||
# | ||
# Test Outbound | ||
##/export/home/aebsprod/scripts/curl-ftp-v2.ksh 098 | ||
# | ||
# Test Inbound | ||
##/export/home/aebsprod/scripts/curl-ftp-v2.ksh 099 |
Oops, something went wrong.