Skip to content

Commit

Permalink
update docker image to use git sha (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
morsecodist authored Oct 19, 2021
1 parent 955b88d commit b29c477
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
21 changes: 15 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ terraform {
aws = {
version = "~> 3.37"
}

git = {
source = "innovationnorway/git"
version = "~> 0.1.3"
}
}
// backend "s3" {
// region = "us-west-2"
// }
}

data "git_repository" "self" {
path = path.module
}

resource "aws_key_pair" "swipe_batch" {
key_name = "${var.APP_NAME}-${var.DEPLOYMENT_ENVIRONMENT}"
public_key = var.BATCH_SSH_PUBLIC_KEY
Expand All @@ -32,12 +41,12 @@ module "batch_queue" {
}

module "sfn" {
source = "./terraform/modules/swipe-sfn"
app_name = var.APP_NAME
deployment_environment = var.DEPLOYMENT_ENVIRONMENT
batch_job_docker_image_name = "swipe:latest"
batch_spot_job_queue_arn = module.batch_queue.batch_spot_job_queue_arn
batch_ec2_job_queue_arn = module.batch_queue.batch_ec2_job_queue_arn
source = "./terraform/modules/swipe-sfn"
app_name = var.APP_NAME
deployment_environment = var.DEPLOYMENT_ENVIRONMENT
batch_job_docker_image = "ghcr.io/chanzuckerberg/swipe:sha-${substr(data.git_repository.self.commit_sha, 0, 7)}"
batch_spot_job_queue_arn = module.batch_queue.batch_spot_job_queue_arn
batch_ec2_job_queue_arn = module.batch_queue.batch_ec2_job_queue_arn
}

output "sfn_arn" {
Expand Down
7 changes: 2 additions & 5 deletions terraform/modules/swipe-sfn-batch-job/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ locals {
container_config = yamldecode(templatefile("${path.module}/batch_job_container_properties.yml", {
app_name = var.app_name,
batch_job_role_arn = aws_iam_role.swipe_batch_main_job.arn,

# TODO: fix docker image
# batch_docker_image = var.use_ecr_private_registry ? "${local.ecr_url}/${var.batch_job_docker_image_name}" : var.batch_job_docker_image_name,
batch_docker_image = "ghcr.io/chanzuckerberg/swipe:sha-c145a0ab"
batch_docker_image = var.batch_job_docker_image,
}))
batch_env_vars = merge(var.extra_env_vars, {
"WDL_INPUT_URI" = "Set this variable to the S3 URI of the WDL input JSON",
Expand All @@ -21,7 +18,7 @@ locals {
"SFN_CURRENT_STATE" = "Set this variable to the current step function state name, like HostFilterEC2 or HostFilterSPOT",
"DEPLOYMENT_ENVIRONMENT" = var.deployment_environment,
"AWS_DEFAULT_REGION" = data.aws_region.current.name,
"MINIWDL__S3PARCP__DOCKER_IMAGE" = var.use_ecr_private_registry ? "${local.ecr_url}/${var.batch_job_docker_image_name}" : var.batch_job_docker_image_name,
"MINIWDL__S3PARCP__DOCKER_IMAGE" = var.batch_job_docker_image,
"MINIWDL__DOWNLOAD_CACHE__PUT" = "true",
"MINIWDL__DOWNLOAD_CACHE__GET" = "true",
"MINIWDL__DOWNLOAD_CACHE__DIR" = "/mnt/download_cache",
Expand Down
8 changes: 1 addition & 7 deletions terraform/modules/swipe-sfn-batch-job/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ variable "extra_env_vars" {
default = {}
}

variable "batch_job_docker_image_name" {
variable "batch_job_docker_image" {
description = "Docker image (name or name:tag) that will be used for Batch jobs"
type = string
}

variable "use_ecr_private_registry" {
description = "If true (default), batch_job_docker_image_name is expected to be found in the private registry for the host AWS account. If false, the name is passed verbatim (as a Docker Hub or other registry URL)"
type = bool
default = true
}

variable "batch_job_timeout_seconds" {
description = "Timeout after which Batch will terminate jobs (Step Functions has a separate timeout for the SFN execution)"
type = number
Expand Down
12 changes: 6 additions & 6 deletions terraform/modules/swipe-sfn/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ resource "aws_iam_role_policy_attachment" "swipe_sfn_service" {
}

module "batch_job" {
source = "../swipe-sfn-batch-job"
app_name = var.app_name
batch_job_docker_image_name = var.batch_job_docker_image_name
batch_job_timeout_seconds = var.batch_job_timeout_seconds
deployment_environment = var.deployment_environment
tags = var.tags
source = "../swipe-sfn-batch-job"
app_name = var.app_name
batch_job_docker_image = var.batch_job_docker_image
batch_job_timeout_seconds = var.batch_job_timeout_seconds
deployment_environment = var.deployment_environment
tags = var.tags
}

module "sfn_io_helper" {
Expand Down
2 changes: 1 addition & 1 deletion terraform/modules/swipe-sfn/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "sfn_template_file" {
default = ""
}

variable "batch_job_docker_image_name" {
variable "batch_job_docker_image" {
description = "Docker image (name or name:tag) that will be used for Batch jobs (expected to be in the private registry for the host AWS account)"
type = string
}
Expand Down

0 comments on commit b29c477

Please sign in to comment.