spotinst / terraform-spotinst-modules

[DEPRECATED] Terraform modules for Spotinst resources.
https://registry.terraform.io/modules/spotinst
Apache License 2.0
6 stars 17 forks source link

Controller terraform issue #16

Closed amitaymolko closed 5 years ago

amitaymolko commented 5 years ago

Terraform version: Terraform v0.12.8 Spotinst plugin installed manually via https://api.spotinst.com/provisioning-ci-cd-sdk/provisioning-tools/terraform/installation/installation-links/

I am trying to set up the Spotinst k8s controller. I've successfully created the EKS cluster and Spotinst Elastigroup with terraform. Now I am trying to get the Spotinst k8 controller to deploy via terraform. I've added:

module "spotinst_ocean_controller" {
    source = "github.com/spotinst/terraform-spotinst-modules//spotinst_ocean_controller"
    spotinst_token   = "${var.spotinst_token}"
    spotinst_account = "${var.spotinst_account}"
    spotinst_cluster_identifier = "${var.spotinst_cluster_identifier}"
}

When I run terraform init I get the following error:

There are some problems with the configuration, described below.

The Terraform configuration must be valid before initialization so that
Terraform can determine which modules and providers need to be installed.

Error: Argument or block definition required

  on .terraform/modules/eks_sites.spotinst_ocean_controller/spotinst_ocean_controller/main.tf line 8, in resource "kubernetes_config_map" "configmap":
   8:     spotinst.token = "${var.spotinst_token}"

An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.

Error: Argument or block definition required

  on .terraform/modules/eks_sites.spotinst_ocean_controller/spotinst_ocean_controller/main.tf line 9, in resource "kubernetes_config_map" "configmap":
   9:     spotinst.account  = "${var.spotinst_account}"

An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.

Error: Argument or block definition required

  on .terraform/modules/eks_sites.spotinst_ocean_controller/spotinst_ocean_controller/main.tf line 10, in resource "kubernetes_config_map" "configmap":
  10:     spotinst.cluster-identifier = "${var.spotinst_cluster_identifier}"

An argument or block definition is required here. To set an argument, use the
equals sign "=" to introduce the argument value.
amirmisgav commented 5 years ago

in terraform-spotinst-modules/spotinst_ocean_controller/main.tf

try to fix by adding "" to variable name spotinst.token --> "spotinst.token"

fixed code: resource "kubernetes_config_map" "configmap" { metadata { name = "spotinst-kubernetes-cluster-controller-config" namespace = "kube-system" }

data { "spotinst.token" = "${var.spotinst_token}" "spotinst.account" = "${var.spotinst_account}" "spotinst.cluster-identifier" = "${var.spotinst_cluster_identifier}" } }

amitaymolko commented 5 years ago

I ended up implementing it with helm provider as so:

data "helm_repository" "spotinst" {
    name = "spotinst"
    url  = "https://spotinst.github.io/spotinst-kubernetes-helm-charts"
}
resource "helm_release" "spotinst-controller" {
    name       = "spotinst-controller"
    repository = "${data.helm_repository.spotinst.metadata.0.name}"
    chart      = "spotinst-kubernetes-cluster-controller"

    values = [<<EOF
spotinst:
    token: ${var.spotinst_token}
    account: ${var.spotinst_account}
    clusterIdentifier: ${var.spotinst_cluster_identifier}
EOF
  ]
}
liranp commented 5 years ago

Thank you for letting us know. Fixed by #18 and #20. Closing for now.