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.
hmpps domain: DSOS-2890: terraform alignment v1 (#7147)
* refactor * fix
- Loading branch information
1 parent
415846c
commit 7a8f320
Showing
10 changed files
with
447 additions
and
325 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
101 changes: 101 additions & 0 deletions
101
terraform/environments/hmpps-domain-services/locals_ec2_autoscaling_groups.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,101 @@ | ||
locals { | ||
|
||
ec2_autoscaling_groups = { | ||
base_linux = { | ||
autoscaling_group = { | ||
desired_capacity = 1 | ||
max_size = 1 | ||
force_delete = true | ||
vpc_zone_identifier = module.environment.subnets["private"].ids | ||
} | ||
autoscaling_schedules = { | ||
scale_up = { recurrence = "0 7 * * Mon-Fri" } | ||
scale_down = { recurrence = "0 19 * * Mon-Fri", desired_capacity = 0 } | ||
} | ||
config = { | ||
iam_resource_names_prefix = "ec2-instance" | ||
instance_profile_policies = [ | ||
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore", | ||
"EC2Default", | ||
"EC2S3BucketWriteAndDeleteAccessPolicy", | ||
"ImageBuilderS3BucketWriteAndDeleteAccessPolicy", | ||
"SSMPolicy", | ||
"PatchBucketAccessPolicy", | ||
] | ||
secretsmanager_secrets_prefix = "ec2/" # TODO | ||
ssm_parameters_prefix = "ec2/" | ||
subnet_name = "private" | ||
} | ||
instance = { | ||
disable_api_termination = false | ||
instance_type = "t3.medium" | ||
key_name = "ec2-user" | ||
metadata_options_http_tokens = "required" | ||
monitoring = false | ||
vpc_security_group_ids = ["rds-ec2s"] | ||
} | ||
user_data_cloud_init = { | ||
args = { | ||
lifecycle_hook_name = "ready-hook" | ||
branch = "main" | ||
ansible_repo = "modernisation-platform-configuration-management" | ||
ansible_repo_basedir = "ansible" | ||
ansible_args = "--tags ec2provision" | ||
} | ||
scripts = [ | ||
"install-ssm-agent.sh.tftpl", | ||
"ansible-ec2provision.sh.tftpl", | ||
"post-ec2provision.sh.tftpl" | ||
] | ||
} | ||
tags = { | ||
component = "test" | ||
os-type = "Linux" | ||
} | ||
} | ||
|
||
base_windows = { | ||
autoscaling_group = { | ||
desired_capacity = 1 | ||
max_size = 1 | ||
force_delete = true | ||
vpc_zone_identifier = module.environment.subnets["private"].ids | ||
} | ||
autoscaling_schedules = { | ||
scale_up = { recurrence = "0 7 * * Mon-Fri" } | ||
scale_down = { recurrence = "0 19 * * Mon-Fri", desired_capacity = 0 } | ||
} | ||
config = { | ||
ebs_volumes_copy_all_from_ami = false | ||
iam_resource_names_prefix = "ec2-instance" | ||
instance_profile_policies = [ | ||
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore", | ||
"EC2Default", | ||
"EC2S3BucketWriteAndDeleteAccessPolicy", | ||
"ImageBuilderS3BucketWriteAndDeleteAccessPolicy", | ||
"SSMPolicy", | ||
"PatchBucketAccessPolicy", | ||
] | ||
secretsmanager_secrets_prefix = "ec2/" # TODO | ||
ssm_parameters_prefix = "ec2/" | ||
subnet_name = "private" | ||
user_data_raw = base64encode(file("./templates/windows_server_2022-user-data.yaml")) | ||
} | ||
ebs_volumes = { | ||
"/dev/sda1" = { type = "gp3", size = 128 } | ||
} | ||
instance = { | ||
disable_api_termination = false | ||
instance_type = "t3.medium" | ||
key_name = "ec2-user" | ||
metadata_options_http_tokens = "required" | ||
monitoring = false | ||
vpc_security_group_ids = ["rds-ec2s"] | ||
} | ||
tags = { | ||
component = "test" | ||
os-type = "Windows" | ||
} | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
terraform/environments/hmpps-domain-services/locals_ec2_instances.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,80 @@ | ||
locals { | ||
|
||
ec2_instances = { | ||
rdgw = { | ||
config = { | ||
ami_name = "hmpps_windows_server_2022_release_2024-01-16T09-48-13.663Z" | ||
availability_zone = "eu-west-2a" | ||
ebs_volumes_copy_all_from_ami = false | ||
iam_resource_names_prefix = "ec2-instance" | ||
instance_profile_policies = [ | ||
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore", | ||
"EC2Default", | ||
"EC2S3BucketWriteAndDeleteAccessPolicy", | ||
"ImageBuilderS3BucketWriteAndDeleteAccessPolicy", | ||
"SSMPolicy", | ||
"PatchBucketAccessPolicy", | ||
] | ||
secretsmanager_secrets_prefix = "ec2/" # TODO | ||
ssm_parameters_prefix = "ec2/" | ||
subnet_name = "private" | ||
user_data_raw = module.baseline_presets.ec2_instance.user_data_raw["user-data-pwsh"] | ||
# user_data_raw = base64encode(file("./templates/windows_server_2022-user-data.yaml")) | ||
} | ||
instance = { | ||
disable_api_termination = false | ||
instance_type = "t3.medium" | ||
key_name = "ec2-user" | ||
metadata_options_http_tokens = "required" | ||
monitoring = false | ||
vpc_security_group_ids = ["rds-ec2s"] | ||
} | ||
ebs_volumes = { | ||
"/dev/sda1" = { type = "gp3", size = 100 } | ||
} | ||
tags = { | ||
os-type = "Windows" | ||
component = "remotedesktop" | ||
backup-plan = "daily-and-weekly" # TODO | ||
} | ||
} | ||
rds = { | ||
config = { | ||
ami_name = "hmpps_windows_server_2022_release_2024-01-16T09-48-13.663Z" | ||
availability_zone = "eu-west-2a" | ||
ebs_volumes_copy_all_from_ami = false | ||
iam_resource_names_prefix = "ec2-instance" | ||
instance_profile_policies = [ | ||
"arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore", | ||
"EC2Default", | ||
"EC2S3BucketWriteAndDeleteAccessPolicy", | ||
"ImageBuilderS3BucketWriteAndDeleteAccessPolicy", | ||
"SSMPolicy", | ||
"PatchBucketAccessPolicy", | ||
] | ||
secretsmanager_secrets_prefix = "ec2/" # TODO | ||
ssm_parameters_prefix = "ec2/" | ||
subnet_name = "private" | ||
user_data_raw = module.baseline_presets.ec2_instance.user_data_raw["user-data-pwsh"] | ||
# user_data_raw = base64encode(file("./templates/windows_server_2022-user-data.yaml")) | ||
} | ||
instance = { | ||
disable_api_termination = false | ||
instance_type = "t3.medium" | ||
key_name = "ec2-user" | ||
metadata_options_http_tokens = "required" | ||
monitoring = false | ||
vpc_security_group_ids = ["rds-ec2s"] | ||
} | ||
ebs_volumes = { | ||
"/dev/sda1" = { type = "gp3", size = 100 } | ||
} | ||
tags = { | ||
os-type = "Windows" | ||
component = "remotedesktop" | ||
backup-plan = "daily-and-weekly" # TODO | ||
} | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.