Skip to content

Commit

Permalink
Merge pull request #28 from aodn/allow_existing_cluster
Browse files Browse the repository at this point in the history
tg: capture cluster_arn and create_cluster values from environment
  • Loading branch information
digorgonzola authored Dec 15, 2023
2 parents 7de7f31 + f7de3f5 commit 7814f0b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions deploy/tf/service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ locals {
resource "null_resource" "cluster_arn_precondition_check" {
lifecycle {
precondition {
condition = (var.create_cluster == false && var.existing_cluster_arn != "" || var.create_cluster && var.existing_cluster_arn == "")
condition = (var.create_cluster == false && var.cluster_arn != "" || var.create_cluster && var.cluster_arn == "")
error_message = "The cluster ARN must be provided if 'create_cluster' is false. If you mean to create the cluster, set 'create_cluster' to true."
}
}
Expand All @@ -85,7 +85,7 @@ module "service" {
depends_on = [module.s3.wrapper]

name = "${var.app_name}-${var.environment}"
cluster_arn = var.create_cluster ? module.cluster.arn : var.existing_cluster_arn
cluster_arn = var.create_cluster ? module.cluster.arn : var.cluster_arn
capacity_provider_strategy = {
env_strategy = {
base = 0
Expand Down
4 changes: 2 additions & 2 deletions deploy/tf/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ variable "app_hostnames" {
type = list(string)
}

variable "existing_cluster_arn" {
variable "cluster_arn" {
description = "ARN of the existing cluster to deploy the service/tasks to."
type = string
default = ""
Expand All @@ -45,7 +45,7 @@ variable "cpu" {
variable "create_cluster" {
description = "Whether or not to create a separate cluster for this deployment. If false, the name of an existing cluster must be provided."
type = bool
default = false
default = true
}

variable "ecr_registry" {
Expand Down
6 changes: 4 additions & 2 deletions deploy/tg/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ include "global" {

inputs = {
app_name = get_env("APP_NAME")
create_cluster = true
environment = local.global.environment
cluster_arn = get_env("CLUSTER_ARN", "")
create_cluster = get_env("CREATE_CLUSTER", true)

environment = local.global.environment

# fetch the ssm parameter names
alb_parameter_name = get_env("ALB_PARAMETER_NAME")
Expand Down

0 comments on commit 7814f0b

Please sign in to comment.