azavea/terraform-aws-ecs-cluster

ECS Cluster won't launch

Kgirthofer opened this issue · 6 comments

Getting errors across the board - am I missing a crucial file?

Thanks!

Hey Kyle.

Do you have any examples of the error messages?

Starts with the invalidation of the params

kgirthofer@SR191:~/terraform/tst-cluster$ terraform plan
provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Default: us-east-1
  Enter a value: us-east-1

1 error(s) occurred:

* module root: 
    module container_service_cluster: root_block_device_type is not a valid parameter
    module container_service_cluster: root_block_Device_size is not a valid parameter

and if I remove those to go with standard defaults

kgirthofer@SR191:~/terraform/tst-cluster$ terraform plan 
provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Default: us-east-1
  Enter a value: us-east-1

There are warnings related to your configuration. If no errors occurred,
Terraform will continue despite these warnings. It is a good idea to resolve
these warnings in the near future.

Warnings:

  * module.container_service_cluster.aws_iam_instance_profile.container_instance: "roles": [DEPRECATED] Use `role` instead. Only a single role can be passed to an IAM Instance Profile

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.template_file.container_instance_cloud_config: Refreshing state...
data.aws_iam_policy_document.container_instance_ec2_assume_role: Refreshing state...
Error refreshing state: 1 error(s) occurred:

* data.template_file.container_instance_cloud_config: 1 error(s) occurred:

* data.template_file.container_instance_cloud_config: data.template_file.container_instance_cloud_config: failed to render : 5:25: unknown variable accessed: ecs_cluster_name

It seems like you may have an older version of the module sourced and are trying to supply it parameters added in later versions. For example, root_block_device_type and root_block_device_size were added in version 0.3.0.

Also, the roles -> role deprecation warning was fixed in 0.2.0.

That's what I thought as well - because your readme references v.1 but I changed it to v.4

kgirthofer@SR191:~/terraform/terraform-aws-ecs-cluster$ terraform get
Get: git::https://github.com/azavea/terraform-aws-ecs-cluster.git?ref=0.4.0
kgirthofer@SR191:~/terraform/terraform-aws-ecs-cluster$ terraform plan
var.ami_id
  Enter a value: ami-********

var.cloud_config
  Enter a value: ${data.template_file.container_instance_cloud_config.rendered}

var.key_name
  Enter a value: prod

var.private_subnet_ids
  Enter a value: ["subnet-********", "subnet-********", "subnet-********"]

var.vpc_id
  Enter a value: vpc-********

provider.aws.region
  The region where AWS operations will take place. Examples
  are us-east-1, us-west-2, etc.

  Default: us-east-1
  Enter a value: us-east-1

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.template_file.container_instance_cloud_config: Refreshing state...
data.aws_iam_policy_document.ecs_assume_role: Refreshing state...
data.aws_iam_policy_document.ecs_autoscale_assume_role: Refreshing state...
data.aws_iam_policy_document.container_instance_ec2_assume_role: Refreshing state...
data.aws_iam_policy_document.ecs_autoscale_assume_role: Refreshing state...
data.aws_iam_policy_document.container_instance_ec2_assume_role: Refreshing state...
data.aws_iam_policy_document.ecs_assume_role: Refreshing state...
Error refreshing state: 1 error(s) occurred:

* data.template_file.container_instance_cloud_config: 1 error(s) occurred:

* data.template_file.container_instance_cloud_config: data.template_file.container_instance_cloud_config: failed to render : 5:25: unknown variable accessed: ecs_cluster_name
kgirthofer@SR191:~/terraform/terraform-aws-ecs-cluster$

Here's my config

data "template_file" "container_instance_cloud_config" {
  template = "${file("cloud-config/base-container-instance.yml.tpl")}"

  vars {
    environment = "${var.environment}"
  }
}

module "container_service_cluster" {
  source = "github.com/azavea/terraform-aws-ecs-cluster?ref=0.4.0"

  vpc_id        = "vpc-********"
  ami_id        = "ami-********"
  instance_type = "m4.large"
  key_name      = "prod"
  cloud_config  = "${data.template_file.container_instance_cloud_config.rendered}"

  root_block_device_type = "gp2"
  root_block_device_size = "10"

  health_check_grace_period = "600"
  desired_capacity          = "1"
  min_size                  = "0"
  max_size                  = "1"

  enabled_metrics = [
    "GroupMinSize",
    "GroupMaxSize",
    "GroupDesiredCapacity",
    "GroupInServiceInstances",
    "GroupPendingInstances",
    "GroupStandbyInstances",
    "GroupTerminatingInstances",
    "GroupTotalInstances",
  ]

  private_subnet_ids = [
    "subnet-********",
    "subnet-********",
    "subnet-********"
  ]
  project     = "Something"
  environment = "tst"
}

Do you have your own base-container-instance.yml.tpl?

The template_cloudinit_config resource inside of the module is defined to be multipart. The one inside of the module is minimal and only tries to connect the compute nodes with an ECS cluster. The module parameter cloud_config is an opportunity for you to supply your own directives (with their own set of template variables).

Oh man - I feel dumb. I never set the variable ecs_cluster_name in the cloudconfig. Thanks for your help!