Skip to content

Commit

Permalink
Migrate AWS launch configurations to launch templates
Browse files Browse the repository at this point in the history
* Same features, but AWS will soon require launch templates
* Starting Dec 31, 2022 AWS will not add new instance types
(e.g. graviton 4) to launch configuration support

Rel: https://aws.amazon.com/blogs/compute/amazon-ec2-auto-scaling-will-no-longer-add-support-for-new-ec2-features-to-launch-configurations/
  • Loading branch information
dghubble committed Nov 30, 2022
1 parent f0e5982 commit da76d32
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Notable changes between versions.
* Update Cilium from v1.12.3 to [v1.12.4](https://github.com/cilium/cilium/releases/tag/v1.12.4)
* Update flannel from v0.15.1 to [v0.20.1](https://github.com/flannel-io/flannel/releases/tag/v0.20.1)

### AWS

* Migrate AWS launch configurations to launch templates
* Starting Dec 31, 2022 AWS won't add new instance types/families to launch configurations

### Addons

* Update Prometheus from v2.40.1 to [v2.40.2](https://github.com/prometheus/prometheus/releases/tag/v2.40.2)
Expand Down
1 change: 1 addition & 0 deletions aws/fedora-coreos/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ resource "aws_instance" "controllers" {
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
tags = {}
}

# network
Expand Down
48 changes: 34 additions & 14 deletions aws/fedora-coreos/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ resource "aws_autoscaling_group" "workers" {
vpc_zone_identifier = var.subnet_ids

# template
launch_configuration = aws_launch_configuration.worker.name
launch_template {
id = aws_launch_template.worker.id
version = aws_launch_template.worker.latest_version
}

# target groups to which instances should be added
target_group_arns = flatten([
Expand Down Expand Up @@ -49,25 +52,42 @@ resource "aws_autoscaling_group" "workers" {
}

# Worker template
resource "aws_launch_configuration" "worker" {
name_prefix = "${var.name}-worker"
image_id = local.ami_id
instance_type = var.instance_type
spot_price = var.spot_price > 0 ? var.spot_price : null
enable_monitoring = false
resource "aws_launch_template" "worker" {
name_prefix = "${var.name}-worker"
image_id = local.ami_id
instance_type = var.instance_type
monitoring {
enabled = false
}

user_data = data.ct_config.worker.rendered
user_data = sensitive(base64encode(data.ct_config.worker.rendered))

# storage
root_block_device {
volume_type = var.disk_type
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
ebs_optimized = true
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_type = var.disk_type
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
delete_on_termination = true
}
}

# network
security_groups = var.security_groups
vpc_security_group_ids = var.security_groups

# spot
dynamic "instance_market_options" {
for_each = var.spot_price > 0 ? [1] : []
content {
market_type = "spot"
spot_options {
max_price = var.spot_price
}
}
}

lifecycle {
// Override the default destroy and replace update behavior
Expand Down
1 change: 1 addition & 0 deletions aws/flatcar-linux/kubernetes/controllers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "aws_instance" "controllers" {
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
tags = {}
}

# network
Expand Down
48 changes: 34 additions & 14 deletions aws/flatcar-linux/kubernetes/workers/workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ resource "aws_autoscaling_group" "workers" {
vpc_zone_identifier = var.subnet_ids

# template
launch_configuration = aws_launch_configuration.worker.name
launch_template {
id = aws_launch_template.worker.id
version = aws_launch_template.worker.latest_version
}

# target groups to which instances should be added
target_group_arns = flatten([
Expand Down Expand Up @@ -49,25 +52,42 @@ resource "aws_autoscaling_group" "workers" {
}

# Worker template
resource "aws_launch_configuration" "worker" {
name_prefix = "${var.name}-worker"
image_id = local.ami_id
instance_type = var.instance_type
spot_price = var.spot_price > 0 ? var.spot_price : null
enable_monitoring = false
resource "aws_launch_template" "worker" {
name_prefix = "${var.name}-worker"
image_id = local.ami_id
instance_type = var.instance_type
monitoring {
enabled = false
}

user_data = data.ct_config.worker.rendered
user_data = sensitive(base64encode(data.ct_config.worker.rendered))

# storage
root_block_device {
volume_type = var.disk_type
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
ebs_optimized = true
block_device_mappings {
device_name = "/dev/xvda"
ebs {
volume_type = var.disk_type
volume_size = var.disk_size
iops = var.disk_iops
encrypted = true
delete_on_termination = true
}
}

# network
security_groups = var.security_groups
vpc_security_group_ids = var.security_groups

# spot
dynamic "instance_market_options" {
for_each = var.spot_price > 0 ? [1] : []
content {
market_type = "spot"
spot_options {
max_price = var.spot_price
}
}
}

lifecycle {
// Override the default destroy and replace update behavior
Expand Down

0 comments on commit da76d32

Please sign in to comment.