Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change terraform to use minimal ami #712

Merged
merged 2 commits into from
Jan 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions testing/terraform/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ locals {
}

data "aws_ami" "ami" {
executable_users = ["self"]
owners = ["amazon"]
most_recent = true
filter {
name = "name"
values = ["al20*-ami-minimal-*-x86_64"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB comment: Do we need to specify x86_64 in the name even though we have additional filter on the architecture down below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, how have we verified that the AMI identified here will always be usable?

Copy link
Contributor Author

@harrryr harrryr Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prashant: I believe it's redundant, is this something we prefer to have removed?
Mahad: There is a depreciation date for each ami around ~3 month after it's been created. It looks like a new version of this minimal AMI is released every ~2 weeks (Period is kind of infrequent) and I can see it going back to Oct 2023. (Further back was probably depreciated so I can't see). I think this AMI is being maintained for a while and we can expect newer versions to keep getting released.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AMI name is defined by convention. I find one public doc talked about it here

al2023-[ami || ami-minimal]-2023.0.[release build date].[build number]-kernel-[version number]-[arm64 || x86_64]

I think we can mostly assume the convention will be kept. Though no perfect solution here.

}
filter {
name = "state"
values = ["available"]
}
filter {
name = "architecture"
values = ["x86_64"]
Expand Down Expand Up @@ -81,8 +89,8 @@ resource "null_resource" "main_service_setup" {

provisioner "remote-exec" {
inline = [
# Install Java 11 and tmux
"yes | sudo amazon-linux-extras install java-openjdk11",
# Install Java 11 and wget
"sudo yum install wget java-11-amazon-corretto -y",

# Copy in CW Agent configuration
"agent_config='${replace(replace(file("./amazon-cloudwatch-agent.json"), "/\\s+/", ""), "$REGION", var.aws_region)}'",
Expand Down Expand Up @@ -142,8 +150,8 @@ resource "null_resource" "remote_service_setup" {

provisioner "remote-exec" {
inline = [
# Install Java 11 and tmux
"yes | sudo amazon-linux-extras install java-openjdk11",
# Install Java 11 and wget
"sudo yum install wget java-11-amazon-corretto -y",

# Copy in CW Agent configuration
"agent_config='${replace(replace(file("./amazon-cloudwatch-agent.json"), "/\\s+/", ""), "$REGION", var.aws_region)}'",
Expand Down