Skip to content

Commit

Permalink
Make the task architecture configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
amarouane-ABDELHAK committed Jul 17, 2024
1 parent 3ba2ff7 commit adb9b56
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion infrastructure/ecs_services/airflow_metrics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "aws_ecs_task_definition" "airflow_metrics" {
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
cpu_architecture = var.task_cpu_architecture
}
requires_compatibilities = ["FARGATE"]
container_definitions = jsonencode([
Expand Down
3 changes: 2 additions & 1 deletion infrastructure/ecs_services/airflow_scheduler.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "aws_ssm_parameter" "airflow_ecs_cloudwatch_agent_config" {
}



resource "aws_ecs_task_definition" "airflow_scheduler" {
family = "${var.prefix}-scheduler"
cpu = var.scheduler_cpu
Expand All @@ -45,7 +46,7 @@ resource "aws_ecs_task_definition" "airflow_scheduler" {
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
cpu_architecture = var.task_cpu_architecture
}
requires_compatibilities = ["FARGATE"]

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/ecs_services/airflow_server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ resource "aws_ecs_task_definition" "airflow_webserver" {
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
cpu_architecture = var.task_cpu_architecture
}
requires_compatibilities = ["FARGATE"]
container_definitions = jsonencode([
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/ecs_services/airflow_standalone_task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ resource "aws_ecs_task_definition" "airflow_standalone_task" {
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
cpu_architecture = var.task_cpu_architecture
}
requires_compatibilities = ["FARGATE"]

Expand Down
2 changes: 1 addition & 1 deletion infrastructure/ecs_services/airflow_worker.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_ecs_task_definition" "airflow_worker" {
network_mode = "awsvpc"
runtime_platform {
operating_system_family = "LINUX"
cpu_architecture = "X86_64"
cpu_architecture = var.task_cpu_architecture
}
requires_compatibilities = ["FARGATE"]
container_definitions = jsonencode([
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/ecs_services/ecr.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "null_resource" "build_ecr_image" {
command = <<EOF
cd ../${path.root}
aws ecr get-login-password --region ${var.aws_region} | docker login --username AWS --password-stdin ${var.account_id}.dkr.ecr.${var.aws_region}.amazonaws.com
docker buildx build --platform linux/amd64,linux/arm64 -t ${aws_ecr_repository.airflow.repository_url}:latest -f airflow_services/Dockerfile .
docker buildx build -t ${aws_ecr_repository.airflow.repository_url}:latest -f airflow_services/Dockerfile .
docker push ${aws_ecr_repository.airflow.repository_url}:latest
cd -
EOF
Expand Down
3 changes: 3 additions & 0 deletions infrastructure/ecs_services/varaibles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ variable "subdomain" {
variable "workers_logs_retention_days" {
type = number
}
variable "task_cpu_architecture" {

}
12 changes: 12 additions & 0 deletions infrastructure/varaibles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,16 @@ variable "airflow_custom_variables" {

variable "infrastructure_foldername"{
default = "infrastructure"
}


variable "task_cpu_architecture" {
description = "The architecture type for the instance. Valid options are 'ARM64' or 'X86_64'."
type = string
default = "X86_64"

validation {
condition = contains(["ARM64", "X86_64"], var.task_cpu_architecture)
error_message = "The architecture type must be either 'ARM64' or 'X86_64'."
}
}

0 comments on commit adb9b56

Please sign in to comment.