-
Notifications
You must be signed in to change notification settings - Fork 62
multi-arch-builders: extend AWS tofu bits to work for x86_64 or aarch64 #986
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # We are deploying for? aarch64 here | ||
| variable "arch" { | ||
| type = string | ||
| default = "aarch64" | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,11 +19,6 @@ provider "aws" {} | |||||||
| provider "ct" {} | ||||||||
| provider "http" {} | ||||||||
|
|
||||||||
| variable "project" { | ||||||||
| type = string | ||||||||
| default = "coreos-aarch64-builder" | ||||||||
| } | ||||||||
|
|
||||||||
| # Which distro are we deploying a builder for? Override the | ||||||||
| # default by setting the env var: TF_VAR_distro=rhcos | ||||||||
| variable "distro" { | ||||||||
|
|
@@ -40,6 +35,11 @@ check "health_check_distro" { | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| locals { | ||||||||
| project = "coreos-${var.arch}-builder" | ||||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
|
|
||||||||
| # Variables used for splunk deployment, which is only | ||||||||
| # for RHCOS builders. Define them in the environment with: | ||||||||
|
|
@@ -74,10 +74,10 @@ check "health_check_rhcos_splunk_vars" { | |||||||
|
|
||||||||
| locals { | ||||||||
| fcos_snippets = [ | ||||||||
| file("../../coreos-aarch64-builder.bu"), | ||||||||
| file("../../coreos-${var.arch}-builder.bu"), | ||||||||
| ] | ||||||||
| rhcos_snippets = [ | ||||||||
| file("../../coreos-aarch64-builder.bu"), | ||||||||
| file("../../coreos-${var.arch}-builder.bu"), | ||||||||
| templatefile("../../builder-splunk.bu", { | ||||||||
| SPLUNK_HOSTNAME = var.splunk_hostname | ||||||||
| SPLUNK_SIDECAR_REPO = var.splunk_sidecar_repo | ||||||||
|
|
@@ -95,15 +95,16 @@ data "aws_region" "aws_region" {} | |||||||
|
|
||||||||
| # Gather information about the AWS image for the current region | ||||||||
| data "http" "stream_metadata" { | ||||||||
| url = "https://builds.coreos.fedoraproject.org/streams/stable.json" | ||||||||
|
|
||||||||
| url = var.distro == "rhcos" ? "https://builds.coreos.fedoraproject.org/streams/stable.json" : "https://builds.coreos.fedoraproject.org/streams/testing.json" | ||||||||
| request_headers = { | ||||||||
| Accept = "application/json" | ||||||||
| } | ||||||||
| } | ||||||||
| # Lookup the aarch64 AWS image for the current AWS region | ||||||||
| # Lookup the AWS image for the current AWS region/architecture | ||||||||
| # Also set the instance_type based on the architecture | ||||||||
| locals { | ||||||||
| ami = lookup(jsondecode(data.http.stream_metadata.body).architectures.aarch64.images.aws.regions, data.aws_region.aws_region.name).image | ||||||||
| ami = lookup(lookup(jsondecode(data.http.stream_metadata.body).architectures, var.arch).images.aws.regions, data.aws_region.aws_region.name).image | ||||||||
| instance_type = var.arch == "aarch64" ? "m6g.metal" : "c6a.xlarge" | ||||||||
| } | ||||||||
|
|
||||||||
| variable "rhcos_aws_vpc_prod" { | ||||||||
|
|
@@ -122,22 +123,29 @@ locals { | |||||||
| } | ||||||||
|
|
||||||||
|
|
||||||||
| resource "aws_instance" "coreos-aarch64-builder" { | ||||||||
| resource "aws_instance" "coreos-builder" { | ||||||||
| tags = { | ||||||||
| Name = "${var.project}-${formatdate("YYYYMMDD", timestamp())}" | ||||||||
| Name = "${local.project}-${formatdate("YYYYMMDD", timestamp())}" | ||||||||
| } | ||||||||
| ami = local.ami | ||||||||
| user_data = data.ct_config.butane.rendered | ||||||||
| instance_type = "m6g.metal" | ||||||||
| instance_type = local.instance_type | ||||||||
| vpc_security_group_ids = [aws_security_group.sg.id] | ||||||||
| subnet_id = local.aws_subnet_id | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's add our fixed IPs here, so we do not need to update our othe confgs in case the IPs changing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or we can also pass them as we are passing the splunk part, maybe that's better |
||||||||
| root_block_device { | ||||||||
| volume_size = "200" | ||||||||
| volume_size = "300" | ||||||||
| volume_type = "gp3" | ||||||||
| } | ||||||||
| associate_public_ip_address = var.distro == "fcos" ? "true" : "false" | ||||||||
| associate_public_ip_address = "false" | ||||||||
| } | ||||||||
|
|
||||||||
| # associate the elastic IP | ||||||||
| resource "aws_eip_association" "aws_eip_association" { | ||||||||
| count = var.distro == "fcos" ? 1 : 0 | ||||||||
| instance_id = aws_instance.coreos-builder.id | ||||||||
| public_ip = var.arch == "aarch64" ? "18.233.54.49" : "34.199.112.205" | ||||||||
| } | ||||||||
|
|
||||||||
| output "instance_ip_addr" { | ||||||||
| value = var.distro == "rhcos" ? aws_instance.coreos-aarch64-builder.private_ip : aws_instance.coreos-aarch64-builder.public_ip | ||||||||
| value = var.distro == "rhcos" ? aws_instance.coreos-builder.private_ip : aws_eip_association.aws_eip_association[0].public_ip | ||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does TF support includes? I feel like it might be clearer to rename this file, move it one level up and have the aarch64 and x86_64 bits just define the arch and include this one?