Skip to content

Commit

Permalink
feat: arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sugdyzhekov committed Oct 4, 2021
1 parent 7509f01 commit 9501c4e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 6 deletions.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Features:
* Default ECS task role allows creating a log group.
* Default security group for ECS nodes allow inbound connections from configurable list of network CIDRs.
* It's possible to specify additional security groups for ECS nodes.
* Latest ECS Optimized AMI.
* Latest ECS Optimized AMI with `amd64` or `arm64` architectures.
* Additional EBS disks.
* ASG lifecycle hooks.

## Usage

Expand All @@ -21,10 +22,13 @@ module "example_ecs_cluster" {
source = "github.com/jetbrains-infra/terraform-aws-ecs-cluster?ref=vX.X.X" // see https://github.com/jetbrains-infra/terraform-aws-ecs-cluster/releases
cluster_name = "FooBar"
spot = true
arm64 = true
instance_types = {
"t3a.large" = 1
"t3a.xlarge" = 2
}
target_capacity = 100
// subnets with ALB and bastion host e.g..
Expand All @@ -36,10 +40,27 @@ module "example_ecs_cluster" {
ebs_disks = {
"/dev/sda" = 100
}
subnets_ids = [
subnets_ids = [
aws_subnet.private_subnet_1.id,
aws_subnet.private_subnet_2.id
]
lifecycle_hooks = [
{
name = "Example"
lifecycle_transition = "autoscaling:EC2_INSTANCE_LAUNCHING"
default_result = "CONTINUE"
heartbeat_timeout = 2000
role_arn = aws_iam_role.example.arn
notification_target_arn = "arn:aws:sqs:us-east-1:444455556666:queue1"
notification_metadata = <<EOF
{
"foo": "bar"
}
EOF
}
]
}
```

Expand All @@ -49,13 +70,18 @@ module "example_ecs_cluster" {
source = "github.com/jetbrains-infra/terraform-aws-ecs-cluster?ref=vX.X.X" // see https://github.com/jetbrains-infra/terraform-aws-ecs-cluster/releases
cluster_name = "FooBar"
spot = false
arm64 = false
instance_types = {
"t3a.small" = 2
}
target_capacity = 100
security_group_ids = []
target_capacity = 100
security_group_ids = []
// subnets with ALB and bastion host e.g..
trusted_cidr_blocks = []
lifecycle_hooks = []
subnets_ids = [
aws_subnet.private_subnet_1.id,
aws_subnet.private_subnet_2.id
Expand All @@ -74,4 +100,5 @@ module "example_ecs_cluster" {
* `iam_instance_profile_name` - IAM instance profile name
* `iam_instance_role_name` - IAM instance role name
* `security_group_id` - security group id
* `security_group_name` - security group name
* `security_group_name` - security group name
* `capacity_provider_name` - capacity provider name (the same name for ASG)
10 changes: 9 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ variable "protect_from_scale_in" {
data "aws_ssm_parameter" "ecs_ami" {
name = "/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id"
}
data "aws_ssm_parameter" "ecs_ami_arm64" {
name = "/aws/service/ecs/optimized-ami/amazon-linux-2/arm64/recommended/image_id"
}
variable "spot" {
description = "Choose should we use spot instances or on-demand to poulate ECS cluster."
type = bool
Expand Down Expand Up @@ -66,6 +69,11 @@ variable "lifecycle_hooks" {
}))
default = []
}
variable "arm64" {
description = "ECS node architecture"
default = false
type = bool
}

locals {
vpc_id = data.aws_subnet.default.vpc_id
Expand All @@ -74,7 +82,7 @@ locals {
trusted_cidr_blocks = var.trusted_cidr_blocks
instance_types = var.instance_types
sg_ids = distinct(concat(var.security_group_ids, [aws_security_group.ecs_nodes.id]))
ami_id = data.aws_ssm_parameter.ecs_ami.value
ami_id = var.arm64 ? data.aws_ssm_parameter.ecs_ami_arm64.value : data.aws_ssm_parameter.ecs_ami.value
spot = var.spot == true ? 0 : 100
lifecycle_hooks = var.lifecycle_hooks
target_capacity = var.target_capacity
Expand Down

0 comments on commit 9501c4e

Please sign in to comment.