cn-terraform / terraform-aws-ecs-fargate

AWS ECS Fargate Terraform Module
https://registry.terraform.io/modules/cn-terraform/ecs-fargate
Apache License 2.0
87 stars 57 forks source link

Reference to networking module in README.md is not working as expected #3

Closed ff6347 closed 5 years ago

ff6347 commented 5 years ago

Hi, I'm trying to use your module (see #2 ) and the example in the README is using the values created by the networking module wrong.

It shows the following snippet

…
public_subnets_ids  = [ "${module.networking.public_subnets_ids}" ]
private_subnets_ids = [ "${module.networking.private_subnets_ids}" ]
…

Which did not work for me and gave me the error:

Error: Incorrect attribute value type
  on .terraform/modules/ecs-fargate/jnonino-terraform-aws-ecs-fargate-4abc83f/load_balancing.tf line 8, in resource "aws_lb" "lb":
   8:   subnets                          = var.public_subnets_ids

Inappropriate value for attribute "subnets": incorrect set element type:
string required.

After assigning them to an output I realized that it is a list in a list.

Outputs:

subnets = [
  [
    "subnet-0e357963e91738337",
  ],
]

So I'm using this config now which is working.

module "networking" {
  source  = "jnonino/networking/aws"
  version = "2.0.1"
  # insert the 7 required variables here
  availability_zones                          = var.availability_zones
  name_preffix                                = "${var.name_preffix}"
  private_subnets_cidrs_per_availability_zone = ["192.168.128.0/19","192.168.160.0/19"]
  public_subnets_cidrs_per_availability_zone  = ["192.168.0.0/19", "192.168.32.0/19"]
  profile                                     = "${var.profile}"
  region                                      = "${var.region}"
  vpc_cidr_block                              = "192.168.0.0/16"

}

module "ecs-fargate" {
  source  = "jnonino/ecs-fargate/aws"
  version = "2.0.1"
  # insert the 10 required variables here
  name_preffix                 = "${var.name_preffix}"
  profile                      = "${var.profile}"
  region                       = "${var.region}"
  vpc_id                       = "${module.networking.vpc_id}"
  availability_zones           = ["${var.availability_zones}"]
  public_subnets_ids           = module.networking.public_subnets_ids[0]
  private_subnets_ids          = module.networking.private_subnets_ids[0]
  container_name               = "${var.name_preffix}-task-test"
  container_image              = "${var.image}"
  container_cpu                = 256
  container_memory             = 512
  container_memory_reservation = 512
  essential                    = true
  container_port               = 3000

  environment = [
    {
      name  = "FOO"
      value = "${var.foo}"
      }, {

  ]
}

provider "aws" {
  profile = "${var.profile}"
  region  = "${var.region}"
}
jnonino commented 5 years ago

Can you check if it works as expected on version 2.0.3

https://registry.terraform.io/modules/jnonino/ecs-fargate/aws/2.0.3

ff6347 commented 5 years ago

I’ll test this in around 2.5h. Currently AFK

ff6347 commented 5 years ago

Works with networking/aws 2.0.3 and ecs-fargate/aws 2.0.3 🚀 Thanks you.