Skip to content

Commit 5b6d994

Browse files
authored
Merge pull request #24 from masterpointio/feat/upgrade-al2023-and-ebs-encryption
feat: upgrade to AL2023 + EBS encryption by default
2 parents 7611ba9 + 8c20030 commit 5b6d994

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Use [the awesome `gossm` project](https://github.com/gjbae1212/gossm).
120120
|------|-------------|------|---------|:--------:|
121121
| <a name="input_additional_security_group_ids"></a> [additional\_security\_group\_ids](#input\_additional\_security\_group\_ids) | Security groups that will be attached to the app instances | `list(string)` | `[]` | no |
122122
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
123-
| <a name="input_ami"></a> [ami](#input\_ami) | The AMI to use for the SSM Agent EC2 Instance. If not provided, the latest Amazon Linux 2 AMI will be used. Note: This will update periodically as AWS releases updates to their AL2 AMI. Pin to a specific AMI if you would like to avoid these updates. | `string` | `""` | no |
123+
| <a name="input_ami"></a> [ami](#input\_ami) | The AMI to use for the SSM Agent EC2 Instance. If not provided, the latest Amazon Linux 2023 AMI will be used. Note: This will update periodically as AWS releases updates to their AL2023 AMI. Pin to a specific AMI if you would like to avoid these updates. | `string` | `""` | no |
124124
| <a name="input_associate_public_ip_address"></a> [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Associate public IP address | `bool` | `null` | no |
125125
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
126126
| <a name="input_cloudwatch_retention_in_days"></a> [cloudwatch\_retention\_in\_days](#input\_cloudwatch\_retention\_in\_days) | The number of days to retain session logs in CloudWatch. This is only relevant if the session\_logging\_enabled variable is `true`. | `number` | `365` | no |

data.tf

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
data "aws_region" "current" {}
22
data "aws_caller_identity" "current" {}
33

4-
# Most recent Amazon Linux 2 AMI
5-
data "aws_ami" "amazon_linux_2" {
4+
# Most recent Amazon Linux 2023 AMI
5+
data "aws_ami" "amazon_linux_2023" {
66
most_recent = true
77
owners = ["amazon"]
88

99
filter {
1010
name = "name"
11-
values = ["amzn2-ami-hvm*"]
11+
values = ["al2023-ami*"]
1212
}
1313

1414
filter {
1515
name = "architecture"
1616
values = ["x86_64"]
1717
}
18+
19+
filter {
20+
name = "virtualization-type"
21+
values = ["hvm"]
22+
}
1823
}

main.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ DOC
271271

272272
resource "aws_launch_template" "default" {
273273
name_prefix = module.this.id
274-
image_id = length(var.ami) > 0 ? var.ami : data.aws_ami.amazon_linux_2.id
274+
image_id = coalesce(var.ami, data.aws_ami.amazon_linux_2023.id)
275275
instance_type = var.instance_type
276276
key_name = var.key_pair_name
277277
user_data = base64encode(var.user_data)
@@ -306,6 +306,13 @@ resource "aws_launch_template" "default" {
306306
create_before_destroy = true
307307
}
308308

309+
block_device_mappings {
310+
device_name = "/dev/xvda"
311+
ebs {
312+
encrypted = true
313+
}
314+
}
315+
309316
metadata_options {
310317
http_endpoint = var.metadata_http_endpoint_enabled ? "enabled" : "disabled"
311318
http_tokens = var.metadata_imdsv2_enabled ? "required" : "optional"

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ variable "instance_type" {
2727
variable "ami" {
2828
default = ""
2929
type = string
30-
description = "The AMI to use for the SSM Agent EC2 Instance. If not provided, the latest Amazon Linux 2 AMI will be used. Note: This will update periodically as AWS releases updates to their AL2 AMI. Pin to a specific AMI if you would like to avoid these updates."
30+
description = "The AMI to use for the SSM Agent EC2 Instance. If not provided, the latest Amazon Linux 2023 AMI will be used. Note: This will update periodically as AWS releases updates to their AL2023 AMI. Pin to a specific AMI if you would like to avoid these updates."
3131
}
3232

3333
variable "user_data" {

0 commit comments

Comments
 (0)