Skip to content

Commit

Permalink
Merge pull request #24 from masterpointio/feat/upgrade-al2023-and-ebs…
Browse files Browse the repository at this point in the history
…-encryption

feat: upgrade to AL2023 + EBS encryption by default
  • Loading branch information
oycyc authored Jul 4, 2024
2 parents 7611ba9 + 8c20030 commit 5b6d994
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Use [the awesome `gossm` project](https://github.com/gjbae1212/gossm).
|------|-------------|------|---------|:--------:|
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_associate_public_ip_address"></a> [associate\_public\_ip\_address](#input\_associate\_public\_ip\_address) | Associate public IP address | `bool` | `null` | no |
| <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 |
| <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 |
Expand Down
11 changes: 8 additions & 3 deletions data.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
data "aws_region" "current" {}
data "aws_caller_identity" "current" {}

# Most recent Amazon Linux 2 AMI
data "aws_ami" "amazon_linux_2" {
# Most recent Amazon Linux 2023 AMI
data "aws_ami" "amazon_linux_2023" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn2-ami-hvm*"]
values = ["al2023-ami*"]
}

filter {
name = "architecture"
values = ["x86_64"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}
}
9 changes: 8 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ DOC

resource "aws_launch_template" "default" {
name_prefix = module.this.id
image_id = length(var.ami) > 0 ? var.ami : data.aws_ami.amazon_linux_2.id
image_id = coalesce(var.ami, data.aws_ami.amazon_linux_2023.id)
instance_type = var.instance_type
key_name = var.key_pair_name
user_data = base64encode(var.user_data)
Expand Down Expand Up @@ -306,6 +306,13 @@ resource "aws_launch_template" "default" {
create_before_destroy = true
}

block_device_mappings {
device_name = "/dev/xvda"
ebs {
encrypted = true
}
}

metadata_options {
http_endpoint = var.metadata_http_endpoint_enabled ? "enabled" : "disabled"
http_tokens = var.metadata_imdsv2_enabled ? "required" : "optional"
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variable "instance_type" {
variable "ami" {
default = ""
type = string
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."
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."
}

variable "user_data" {
Expand Down

0 comments on commit 5b6d994

Please sign in to comment.