Home

Awesome

Modernisation Platform Terraform Module Template

Standards Icon Format Code Icon Scorecards IconSCA Icon Terraform SCA Icon

Usage


module "template" {

  source = "github.com/ministryofjustice/modernisation-platform-terraform-module-template"

  tags             = local.tags
  application_name = local.application_name

}

<!--- BEGIN_TF_DOCS ---> <!--- END_TF_DOCS --->

Looking for issues?

If you're looking to raise an issue with this module, please create a new issue in the Modernisation Platform repository.

<!-- BEGIN_TF_DOCS -->

Requirements

NameVersion
<a name="requirement_terraform"></a> terraform>= 1.1.7
<a name="requirement_aws"></a> aws~> 5.0
<a name="requirement_cloudinit"></a> cloudinit~> 2.3.5
<a name="requirement_random"></a> random~> 3.4
<a name="requirement_time"></a> time> 0.9.0

Providers

NameVersion
<a name="provider_aws"></a> aws~> 5.0
<a name="provider_cloudinit"></a> cloudinit~> 2.3.5
<a name="provider_random"></a> random~> 3.4

Modules

No modules.

Resources

NameType
aws_autoscaling_group.thisresource
aws_autoscaling_schedule.thisresource
aws_cloudwatch_metric_alarm.thisresource
aws_iam_instance_profile.thisresource
aws_iam_role.thisresource
aws_iam_role_policy.lifecycle_hooksresource
aws_iam_role_policy.ssm_params_and_secretsresource
aws_launch_template.thisresource
aws_lb_target_group.thisresource
aws_secretsmanager_secret.fixedresource
aws_secretsmanager_secret.placeholderresource
aws_secretsmanager_secret_version.fixedresource
aws_ssm_parameter.placeholderresource
aws_ssm_parameter.thisresource
random_password.secretsresource
random_password.thisresource
aws_ami.thisdata source
aws_caller_identity.currentdata source
aws_ec2_instance_type.thisdata source
aws_iam_policy_document.lifecycle_hooksdata source
aws_iam_policy_document.ssm_params_and_secretsdata source
cloudinit_config.thisdata source

Inputs

NameDescriptionTypeDefaultRequired
<a name="input_account_ids_lookup"></a> account_ids_lookupA map of account names to account ids that can be used for AMI ownermap(any){}no
<a name="input_ami_name"></a> ami_nameName of AMI to be used to launch the ec2 instancestringn/ayes
<a name="input_ami_owner"></a> ami_ownerOwner of AMI to be used to launch the ec2 instancestring"core-shared-services-production"no
<a name="input_application_name"></a> application_nameThe name of the application. This will be name of the environment in Modernisation Platformstringn/ayes
<a name="input_autoscaling_group"></a> autoscaling_groupSee aws_autoscaling_group documentation<pre>object({<br/> desired_capacity = number<br/> max_size = number<br/> min_size = number<br/> health_check_grace_period = optional(number)<br/> health_check_type = optional(string)<br/> force_delete = optional(bool)<br/> termination_policies = optional(list(string))<br/> target_group_arns = optional(list(string))<br/> wait_for_capacity_timeout = optional(string)<br/> initial_lifecycle_hooks = optional(map(object({<br/> default_result = string<br/> heartbeat_timeout = number<br/> lifecycle_transition = string<br/> })))<br/> instance_refresh = optional(object({<br/> strategy = string<br/> min_healthy_percentage = number<br/> instance_warmup = number<br/> }))<br/> warm_pool = optional(object({<br/> pool_state = optional(string)<br/> min_size = optional(number)<br/> max_group_prepared_capacity = optional(number)<br/> reuse_on_scale_in = bool<br/> }))<br/> })</pre>n/ayes
<a name="input_autoscaling_schedules"></a> autoscaling_schedulesSee aws_autoscaling_schedule documentation. Key=name. Values are taken from equivalent autoscaling_group value if null<pre>map(object({<br/> min_size = optional(number)<br/> max_size = optional(number)<br/> desired_capacity = optional(number)<br/> recurrence = string<br/> }))</pre>n/ayes
<a name="input_availability_zone"></a> availability_zoneOptionally associated the ASG with a single availability zonestringnullno
<a name="input_cloudwatch_metric_alarms"></a> cloudwatch_metric_alarmsMap of cloudwatch metric alarms. The alarm name is set to the autoscaling group name plus the map key.<pre>map(object({<br/> comparison_operator = string<br/> evaluation_periods = number<br/> metric_name = string<br/> namespace = string<br/> period = number<br/> statistic = string<br/> threshold = number<br/> alarm_actions = list(string)<br/> ok_actions = optional(list(string), [])<br/> actions_enabled = optional(bool, false)<br/> alarm_description = optional(string)<br/> datapoints_to_alarm = optional(number)<br/> treat_missing_data = optional(string, "missing")<br/> dimensions = optional(map(string), {})<br/> }))</pre>{}no
<a name="input_ebs_kms_key_id"></a> ebs_kms_key_idKMS Key to use for EBS volumes if not explicitly set in ebs_volumes variable. If null, uses the local account key or the corresponding AMI volume ebs keystringnullno
<a name="input_ebs_volume_config"></a> ebs_volume_configEC2 volume configurations, where key is a label, e.g. flash, which is assigned to the disk in ebs_volumes. All disks with same label have the same configuration. If not specified, use values from the AMI. If total_size specified, the volume size is this divided by the number of drives with the given label<pre>map(object({<br/> iops = optional(number)<br/> throughput = optional(number)<br/> total_size = optional(number)<br/> type = optional(string)<br/> kms_key_id = optional(string)<br/> }))</pre>n/ayes
<a name="input_ebs_volume_tags"></a> ebs_volume_tagsAdditional tags to apply to ebs volumesmap(string){}no
<a name="input_ebs_volumes"></a> ebs_volumesEC2 volumes, see aws_ebs_volume for documentation. key=volume name, value=ebs_volume_config key. label is used as part of the Name tag<pre>map(object({<br/> label = optional(string)<br/> snapshot_id = optional(string)<br/> iops = optional(number)<br/> throughput = optional(number)<br/> size = optional(number)<br/> type = optional(string)<br/> kms_key_id = optional(string)<br/> no_device = optional(bool)<br/> }))</pre>n/ayes
<a name="input_ebs_volumes_copy_all_from_ami"></a> ebs_volumes_copy_all_from_amiIf true, ensure all volumes in AMI are also present in EC2. If false, only create volumes specified in ebs_volumes varbooltrueno
<a name="input_iam_resource_names_prefix"></a> iam_resource_names_prefixPrefix IAM resources with this prefix, e.g. ec2-databasestring"ec2"no
<a name="input_instance"></a> instanceEC2 launch template / instance settings, see aws_instance documentation<pre>object({<br/> disable_api_termination = bool<br/> disable_api_stop = optional(bool, false)<br/> instance_type = string<br/> key_name = string<br/> monitoring = optional(bool, true)<br/> metadata_options_http_tokens = optional(string, "required")<br/> metadata_endpoint_enabled = optional(string, "enabled")<br/> vpc_security_group_ids = list(string)<br/> private_dns_name_options = optional(object({<br/> enable_resource_name_dns_aaaa_record = optional(bool)<br/> enable_resource_name_dns_a_record = optional(bool)<br/> hostname_type = string<br/> }))<br/> tags = optional(map(string), {})<br/> })</pre>n/ayes
<a name="input_instance_profile_policies"></a> instance_profile_policiesA list of managed IAM policy document ARNs to be attached to the instance profilelist(string)n/ayes
<a name="input_lb_target_groups"></a> lb_target_groupsMap of load balancer target groups, where key is the name. vpc_id needs setting if this is used<pre>map(object({<br/> port = optional(number)<br/> protocol = optional(string)<br/> deregistration_delay = optional(number)<br/> health_check = optional(object({<br/> enabled = optional(bool)<br/> interval = optional(number)<br/> healthy_threshold = optional(number)<br/> matcher = optional(string)<br/> path = optional(string)<br/> port = optional(number)<br/> protocol = optional(string)<br/> timeout = optional(number)<br/> unhealthy_threshold = optional(number)<br/> }))<br/> stickiness = optional(object({<br/> enabled = optional(bool)<br/> type = string<br/> cookie_duration = optional(number)<br/> cookie_name = optional(string)<br/> }))<br/> attachments = optional(list(object({<br/> target_id = string<br/> port = optional(number)<br/> availability_zone = optional(string)<br/> })), [])<br/> }))</pre>{}no
<a name="input_name"></a> nameProvide a unique name for the auto scale groupstringn/ayes
<a name="input_region"></a> regionDestination AWS Region for the infrastructurestring"eu-west-2"no
<a name="input_secretsmanager_secrets"></a> secretsmanager_secretsA map of secretsmanager secrets to create. Set a specific value or a randomly generated value. If neither random or value are set, a placeholder value is created which can be updated outside of terraform<pre>map(object({<br/> description = optional(string)<br/> kms_key_id = optional(string)<br/> recovery_window_in_days = optional(number)<br/> random = optional(object({<br/> length = number<br/> special = optional(bool)<br/> }))<br/> value = optional(string)<br/> tags = optional(map(string), {})<br/> }))</pre>nullno
<a name="input_secretsmanager_secrets_prefix"></a> secretsmanager_secrets_prefixOptionally prefix secretsmanager secrets with this prefix. Add a trailing /string""no
<a name="input_ssm_parameters"></a> ssm_parametersA map of SSM parameters to create. Set a specific value or a randomly generated value. If neither random or value are set, a placeholder value is created which can be updated outside of terraform<pre>map(object({<br/> description = optional(string)<br/> type = optional(string, "SecureString")<br/> kms_key_id = optional(string)<br/> random = optional(object({<br/> length = number<br/> special = optional(bool)<br/> }))<br/> value = optional(string)<br/> }))</pre>nullno
<a name="input_ssm_parameters_prefix"></a> ssm_parameters_prefixOptionally prefix ssm parameters with this prefix. Add a trailing /string""no
<a name="input_subnet_ids"></a> subnet_idsList of subnet ids given to the ASG to set the associated AZs (and therefore redundancy of the ASG instances)list(string)n/ayes
<a name="input_tags"></a> tagsDefault tags to be applied to resources. Additional tags can be added to EBS volumes or EC2s, see instance.tags and ebs_volume_tags variables.map(any)n/ayes
<a name="input_user_data_cloud_init"></a> user_data_cloud_initUse this instead of user_data_raw to run multiple scripts using cloud_init<pre>object({<br/> args = optional(map(string))<br/> scripts = optional(list(string))<br/> write_files = optional(map(object({<br/> path = string<br/> owner = string<br/> permissions = string<br/> })), {})<br/> })</pre>nullno
<a name="input_user_data_raw"></a> user_data_rawBase64 encoded user data, script or cloud formation templatestringnullno
<a name="input_vpc_id"></a> vpc_idvpc id which only needs populating if lb_target_groups is setstringnullno

Outputs

NameDescription
<a name="output_autoscaling_group"></a> autoscaling_groupmap of aws_autoscaling_group details
<a name="output_lb_target_groups"></a> lb_target_groupsmap of aws_lb_target_group resources
<!-- END_TF_DOCS -->