Skip to content

[Bug]: new eks-cluster example fails when running in a region with only 3 az's #191

Open
@lewinkedrs

Description

@lewinkedrs

Welcome to the AWS Observability Accelerator

  • Yes, I've searched similar issues on GitHub and didn't find any.

AWS Observability Accelerator Release version

latest

What is your environment, configuration and the example used?

When running the eks-cluster-with-vpc example we use this in main.tf:

data "aws_availability_zones" "available" {}

locals {
  name         = basename(path.cwd)
  cluster_name = coalesce(var.cluster_name, local.name)
  region       = var.aws_region

  vpc_cidr = "10.0.0.0/16"
  azs      = slice(data.aws_availability_zones.available.names, 0, 3)

If you run this in a region with only 3 AZs like us-west-1 you get an error because the end value of the slice (3) exceeds the amount of items in the list (2) These are zero-indexed: If you change the above code to this:

data "aws_availability_zones" "available" {}

locals {
  name         = basename(path.cwd)
  cluster_name = coalesce(var.cluster_name, local.name)
  region       = var.aws_region

  vpc_cidr = "10.0.0.0/16"
  azs      = slice(data.aws_availability_zones.available.names, 0, 2)

You no longer get the error. We probably should read the amount of items in the 'aws_availability_zones' list and use that to set the end value of the slice.

What did you do and What did you see instead?

This worked in us-west-1 by manually changing slice index.

Additional Information

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions