segmentio / stack

A set of Terraform modules for configuring production infrastructure with AWS
https://open.segment.com
MIT License
2.1k stars 420 forks source link

stack//web-service crash with big image string when name is not defined #123

Open wiliamsouza opened 7 years ago

wiliamsouza commented 7 years ago

When the image name is more than 32 characters we get the following error:

2017/04/25 10:40:18 [ERROR] root.accounts.elb: eval: *terraform.EvalValidateResource, err: Warnings: []. Errors: [only alphanumeric characters and hyphens allowed in "name": "554136634080.dkr.ecr.us-east-2.ama
zonaws.com-olist-dex:latest" "name" cannot be longer than 32 characters: "554136634080.dkr.ecr.us-east-2.amazonaws.com-olist-dex:latest"]
2017/04/25 10:40:18 [ERROR] root.accounts.elb: eval: *terraform.EvalSequence, err: Warnings: []. Errors: [only alphanumeric characters and hyphens allowed in "name": "554136634080.dkr.ecr.us-east-2.amazonaws.c
om-olist-dex:latest" "name" cannot be longer than 32 characters: "554136634080.dkr.ecr.us-east-2.amazonaws.com-olist-dex:latest"]

how to reproduce.

module "accounts" {                                                                                                                                                                                              
  source             = "github.com/segmentio/stack//web-service"                                                                                                                                                 
  image              = "554136634080.dkr.ecr.us-east-2.amazonaws.com/olist/dex:latest"                                                                                                                           
  port               = 5556                                                                                                                                                                                      

  environment      = "${module.stack.environment}"                                                                                                                                                               
  cluster          = "${module.stack.cluster}"                                                                                                                                                                   
  iam_role         = "${module.stack.iam_role}"                                                                                                                                                                  
  security_groups  = "${module.stack.external_elb}"                                                                                                                                                              
  subnet_ids       = "${module.stack.external_subnets}"                                                                                                                                                          
  log_bucket       = "${module.stack.log_bucket_id}"                                                                                                                                                             
  internal_zone_id = "${module.stack.zone_id}"                                                                                                                                                                   
  external_zone_id = "${module.domain.zone_id}"                                                                                                                                                                  

  env_vars = <<EOF                                                                                                                                                                                               
[                                                                                                                                                                                                                
  { "name": "AWS_REGION",            "value": "${module.stack.region}"        },                                                                                                                                 
  { "name": "AWS_ACCESS_KEY_ID",     "value": "${module.ses_user.access_key}" },                                                                                                                                 
  { "name": "AWS_SECRET_ACCESS_KEY", "value": "${module.ses_user.secret_key}" }                                                                                                                                  
]                                                                                                                                                                                                                
EOF                                                                                                                                                                                                              
}

Workaround add small name.

module "accounts" {                                                                                                                                                                                              

  name              = "smalname"
  source             = "github.com/segmentio/stack//web-service"                                                                                                                                                 
  image              = "554136634080.dkr.ecr.us-east-2.amazonaws.com/olist/dex:latest"   
...