Skip to content

Commit 9b29737

Browse files
move batch_image and batch_resource_requirement fields from job_definition to batch variables
1 parent da616ca commit 9b29737

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

infrastructure/batch/job_definition.tf

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,13 @@ resource "aws_batch_job_definition" "scpca_portal_project" {
88
container_properties = jsonencode({
99
# command definition expected in cotaninerOverrides when using this job definition
1010
command = []
11-
image = "${var.dockerhub_repo}/scpca_portal_api:latest"
11+
image = var.batch_image
1212
fargatePlatformConfiguration = {
1313
platformVersion = "LATEST"
1414
}
1515
environment = var.batch_environment
1616

17-
resourceRequirements = [
18-
# requirements match api requirements, which uses a t2.medium (2 vcpus and 4.0 GB of RAM)
19-
{
20-
type = "VCPU"
21-
value = "2.0"
22-
},
23-
{
24-
type = "MEMORY"
25-
value = "4096"
26-
}
27-
]
17+
resourceRequirements = var.batch_resource_requirements
2818

2919
# without this declaration, ephemeralStroage defaults to 20GB
3020
ephemeralStorage = {

infrastructure/batch/variables.tf

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,42 @@ variable "batch_environment" {
66

77
default = [
88
for pair in flatten([for line in split("\n", templatefile("$api-configuration/environment.tpl", {
9-
django_secret_key = var.django_secret_key
10-
database_host = aws_db_instance.postgres_db.address
11-
database_port = aws_db_instance.postgres_db.port
12-
database_user = aws_db_instance.postgres_db.username
13-
database_password = var.database_password
14-
aws_region = var.region
15-
aws_s3_bucket_name = aws_s3_bucket.scpca_portal_bucket.id
16-
sentry_dsn = var.sentry_dsn
17-
sentry_env = var.sentry_env
9+
django_secret_key = var.django_secret_key
10+
database_host = aws_db_instance.postgres_db.address
11+
database_port = aws_db_instance.postgres_db.port
12+
database_user = aws_db_instance.postgres_db.username
13+
database_password = var.database_password
14+
aws_region = var.region
15+
aws_s3_bucket_name = aws_s3_bucket.scpca_portal_bucket.id
16+
sentry_dsn = var.sentry_dsn
17+
sentry_env = var.sentry_env
1818
})) : split("=", line)]) :
1919
{
2020
name = pair[0]
2121
value = pair[1]
2222
}
2323
]
2424
}
25+
26+
variable "batch_image" {
27+
type = string
28+
default = "${var.dockerhub_repo}/scpca_portal_api:latest"
29+
}
30+
31+
variable "batch_resource_requirements" {
32+
type = list(object({
33+
type = string
34+
value = string
35+
}))
36+
# requirements match api requirements, which uses a t2.medium (2 vcpus and 4.0 GB of RAM)
37+
default = [
38+
{
39+
type = "VCPU"
40+
value = "2.0"
41+
},
42+
{
43+
type = "MEMORY"
44+
value = "4096"
45+
}
46+
]
47+
}

0 commit comments

Comments
 (0)