Skip to content

Commit

Permalink
fix tf module resource
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Oct 25, 2023
1 parent 5eebc3c commit 2157372
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
5 changes: 3 additions & 2 deletions terraform/aws-constellation/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module "aws_iam" {
source = "../iam/aws"
source = "../terraform/iam/aws"
name_prefix = var.name_prefix
region = var.region
}


module "aws" {
source = "../aws"
source = "../terraform/aws"
name = var.name
node_groups = var.node_groups
iam_instance_profile_worker_nodes = module.aws_iam.worker_nodes_instance_profile
Expand Down Expand Up @@ -36,4 +36,5 @@ module "constellation" {
region = var.region # TODO CSP specific
zone = var.zone # TODO CSP specific
node_groups = var.node_groups
dev = var.dev
}
7 changes: 7 additions & 0 deletions terraform/aws-constellation/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ variable "name_prefix" {
type = string
description = "Prefix for all resources"
}


variable "dev" {
type = bool
description = "Enable dev mode. This uses the current main branch for the CLI binary."
default = false
}
33 changes: 26 additions & 7 deletions terraform/constellation-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,31 @@ locals {
]))
}


// TODO make null_resource and execute every time?
resource "terraform_data" "ensure_cli" {
provisioner "local-exec" {
command = "${path.module}/install-constellation.sh && ./constellation config generate ${var.csp}"
command = <<EOT
if [ "${var.dev}" ]; then
bazel run //:devbuild
else
${path.module}/install-constellation.sh
fi
EOT
} # TODO bazel target to only build and link CLI?
}
# TODO ensure yq dependency?

resource "terraform_data" "config_generate" {
provisioner "local-exec" {
command = <<EOT
./constellation config generate ${var.csp}
EOT
}
// generate config here to only create it once (csp won't change)
depends_on = [
terraform_data.ensure_cli
]

}
# TODO ensure yq dependency

# TODO how to handle CSP specific config without CSP specific input?
resource "terraform_data" "csp_config" {
Expand All @@ -35,7 +52,7 @@ resource "terraform_data" "csp_config" {
}

depends_on = [
terraform_data.ensure_cli
terraform_data.config_generate
]
}

Expand All @@ -50,11 +67,10 @@ resource "terraform_data" "config" {
${local.yq_node_groups}
./constellation config fetch-measurements
EOT
# TODO use release constellation binary when 2.13.0 is released
}

depends_on = [
terraform_data.csp_config
terraform_data.config_generate
]
}

Expand All @@ -70,6 +86,9 @@ resource "terraform_data" "infra_state" {
yq eval '.infrastructure.name = "${var.name}"' -i constellation-state.yaml
EOT
}
depends_on = [
terraform_data.config_generate
]
}


Expand Down
6 changes: 6 additions & 0 deletions terraform/constellation-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,9 @@ variable "microservice_version" {
type = string
description = "Microservice version"
}

variable "dev" {
type = bool
description = "Enable dev mode. This uses the current main branch for the CLI binary."
default = false
}

0 comments on commit 2157372

Please sign in to comment.