Skip to content

cn-terraform/terraform-aws-nomad

Repository files navigation

Nomad Terraform Module for AWS

This Terraform module deploys Nomad Servers and Nodes in AWS.

Usage

Check valid versions on:

  • Github Releases: https://github.com/cn-terraform/terraform-aws-nomad/releases

  • Terraform Module Registry: https://registry.terraform.io/modules/cn-terraform/nomad

      module "nomad" {
          source  = "cn-terraform/nomad/aws"
          version = "2.0.2"
    
          names_prefix = ${terraform.workspace}
    
          profile         = var.profile
          region          = var.region
          vpc_id          = var.vpc_id
          subnets_ids     = var.subnets_ids
          route53_zone_id = var.private_hosted_zone_id
          domain_name     = var.domain_name
          ssh_key_name    = var.ssh_key_name
    
          cidrs_to_open_ports_on_security_groups = [ "XXX.XXX.XXX.XXX/XX" ]
    
          consul_version = "0.9.2"
          nomad_version  = "0.6.0"
          consul_address = "consul.${var.domain_name}"
    
          server_ami_id               = var.aws_linux_ami_id
          server_instance_type        = "t2.medium"
          server_asg_min_size         = 3
          server_asg_desired_capacity = 3
          server_asg_max_size         = 3
    
          client_ami_id               = var.aws_linux_ami_id
          client_instance_type        = "m4.xlarge"
          client_asg_min_size         = 1
          client_asg_desired_capacity = 3
          client_asg_max_size         = 25
      }
    

Install pre commit hooks.

Pleas run this command right after cloning the repository.

    pre-commit install

For that you may need to install the folowwing tools:

In order to run all checks at any point run the following command:

    pre-commit run --all-files

Requirements

Name Version
terraform >= 0.13
aws >= 4

Providers

Name Version
aws 4.0.0
template 2.2.0

Modules

No modules.

Resources

Name Type
aws_autoscaling_attachment.consul_asg_attachment resource
aws_autoscaling_attachment.nomad_asg_attachment resource
aws_autoscaling_group.nomad_client_asg resource
aws_autoscaling_group.server_asg resource
aws_elb.consul_elb resource
aws_elb.nomad_elb resource
aws_iam_instance_profile.ec2_describe_instance_profile resource
aws_iam_instance_profile.ecr_role_instance_profile resource
aws_iam_policy.ec2_describe_policy resource
aws_iam_policy.push_to_ecr_policy resource
aws_iam_policy_attachment.ec2_describe_attach_policy resource
aws_iam_policy_attachment.push_to_ecr_attach_policy resource
aws_iam_role.ec2_describe_role resource
aws_iam_role.push_to_ecr_role resource
aws_launch_configuration.nomad_client_lc resource
aws_launch_configuration.server_lc resource
aws_route53_record.consul_elb_dns resource
aws_route53_record.nomad_elb_dns resource
aws_security_group.elb_security_group resource
aws_security_group.instances_security_group resource
aws_security_group_rule.elb_security_group_allow_egress_traffic resource
aws_security_group_rule.elb_security_group_allow_ingress_open_ports_vpc resource
aws_security_group_rule.elb_security_group_allow_ingress_open_ports_vpn resource
aws_security_group_rule.instances_security_group_allow_egress_traffic resource
aws_security_group_rule.instances_security_group_allow_ingress_open_tcp_ports resource
aws_security_group_rule.instances_security_group_allow_ingress_open_udp_ports resource
aws_security_group_rule.instances_security_group_allow_ingress_self resource
aws_security_group_rule.instances_security_group_allow_ingress_subnets resource
aws_route53_zone.hosted_zone data source
aws_subnet.subnets data source
template_file.nomad_client_user_data data source
template_file.server_user_data data source

Inputs

Name Description Type Default Required
cidrs_to_open_ports_on_security_groups List of CIDRs to open ports on instances security group list(any) n/a yes
client_ami_id AMI ID to use on Clients string n/a yes
client_asg_desired_capacity Desired Number of Instances of Nomad Client to Create any n/a yes
client_asg_max_size Max Number of Instances of Nomad Client to Create any n/a yes
client_asg_min_size Min Number of Instances of Nomad Client to Create any n/a yes
client_instance_type AWS Instance type to use on clients string n/a yes
consul_address Consul Address any n/a yes
consul_version Consul Version string "0.9.2" no
domain_name Domain Name any n/a yes
names_prefix prefix for Resources Names any n/a yes
nomad_version Nomad Version string "0.6.0" no
ports_to_open_on_elb_security_group Ports to Open on ELB Security Group list(any)
[
"22",
"80",
"443"
]
no
profile AWS API key credentials to use any n/a yes
region AWS Region the infrastructure is hosted in any n/a yes
route53_zone_id Route53 Zone ID to fetch any n/a yes
server_ami_id AMI ID to use on servers string n/a yes
server_asg_desired_capacity Desired Number of Instances of PAAS Server to Create any n/a yes
server_asg_max_size Max Number of Instances of PAAS Server to Create any n/a yes
server_asg_min_size Min Number of Instances of PAAS Server to Create any n/a yes
server_instance_type AWS Instance type to use on servers string n/a yes
ssh_key_name SSH Key Name any n/a yes
subnets_ids Private Subnets list(any) n/a yes
tcp_ports_to_open_on_instances_security_group TCP Ports to Open on Instances Security Group list(any)
[
"22",
"4646",
"4647",
"4648",
"8300",
"8301",
"8302",
"8500",
"8600"
]
no
udp_ports_to_open_on_instances_security_group UDP Ports to Open on Instances Security Group list(any)
[
"4648",
"8301",
"8302",
"8600"
]
no
vpc_id VPC ID any n/a yes

Outputs

No outputs.