Terraform module to create AWS Spot instances for various purposes.
The module provide the following profiles:
- ECS node
- Common node
name
- project information, used for tags and unique iam role namesubnet_id
- placement subnetsecurity_group_id
- placement security group
ssh_key
- default ssh pair idcapacity
- amount of nodes (default1
)type
- type of launch configuration (default iscommon_node
, currently supported values arecommon_node
&ecs_node
)common_node_ami_id
- AMI image used forcommon_node
type of launch configuration (default is the most recent Amazon provided AMI)ecs_node_ami_id
- AMI image used forecs_node
type of launch configuration (default is the most recent Amazon provided AMI)iam_instance_profile
- IAM instance profile arn (required for ECS node, default is empty value)ec2_type
- AWS EC2 type (defaultt2.small
)userdata
- userdata script body (default is empty value)disk_size_root
- size of instance root partition (default is 8Gb)disk_size_docker
- size of instance docker partition, used forecs_node
type (default is 25Gb)valid_until
- the date until spot request is valid (default2033-01-01T01:00:00Z
)public_ip
- assign public IP on EC2 node (defaultfalse
)internet_access
- allow access to internet (defaulttrue
)
Example: One linux box
module "bastion_host" {
source = ""
name = "Bastion host"
subnet_id = "${aws_subnet.default.id}"
ssh_key = "${aws_key_pair.default.id}"
security_group_ids = ["${aws_security_group.myecs.id}"]
}
Example: Five ECS nodes of c5.large type
module "my_ecs_nodes" {
source = "github.com/jetbrains-infra/terraform-aws-spot-fleet"
name = "Example ECS cluster"
subnet_id = "${aws_subnet.default.id}"
security_group_ids = ["${aws_security_group.myecs.id}"]
iam_instance_profile_arn = "${aws_iam_instance_profile.ecs_node.arn}" // wtf
capacity = "5"
type = "ecs_node" // currently supported values are "common_node" & "ecs_node"
ec2_type = "c5.large"
userdata = <<EOT
#!/bin/bash
echo ECS_CLUSTER="${aws_ecs_cluster.example.name}" >> /etc/ecs/ecs.config
EOT
}