cloudposse/terraform-aws-ec2-bastion-server

Error: expected length of name to be in the range (1 - 64), got

sfc-gh-pkommini opened this issue · 2 comments

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

module "bastion" {
  source                        = "cloudposse/ec2-bastion-server/aws"
  version                       = "0.17.0"

  ami                           = "ami-03130878b60947df3"
  instance_type                 = "t2.micro"
  id_length_limit               = 0

  vpc_id                        = aws_vpc.main.id
  associate_public_ip_address   = true
  subnets                       = aws_subnet.public.*.id
  allowed_cidr_blocks           = var.allowed_cidr_blocks

  ssh_user                      = "ec2-user"
  key_name                      = module.dispatch_key_pair.this_key_pair_key_name
  user_data                     = ["sudo amazon-linux-extras enable postgresql11"]

  tags = {
    name        = "${var.app_name}-bastion"
    environment = var.env
  }
}

This is the code.

Expected Behavior

We expect the bastion instance to be created successfully but instead the get the following error message:

Error: expected length of name to be in the range (1 - 64), got 

  on .terraform/modules/bastion/main.tf line 9, in resource "aws_iam_role" "default":
   9:   name  = module.this.id

Steps to Reproduce

Steps to reproduce the behavior:

  1. Use the code above
  2. With terraform 0.14.2
  3. Run terraform plan

Screenshots

Error: expected length of name to be in the range (1 - 64), got 

  on .terraform/modules/bastion/main.tf line 9, in resource "aws_iam_role" "default":
   9:   name  = module.this.id

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: macOS
  • Version: 10.15.7

Did you set name, namespace and stage?

I was able to fix this after passing name, enabled = true.