Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid count argument on read/write_target_index with multiple dynamodb tables #70

Closed
leevs opened this issue Nov 19, 2020 · 1 comment · Fixed by #87
Closed

invalid count argument on read/write_target_index with multiple dynamodb tables #70

leevs opened this issue Nov 19, 2020 · 1 comment · Fixed by #87
Labels
bug 🐛 An issue with the system

Comments

@leevs
Copy link

leevs commented Nov 19, 2020

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Error: Invalid count argument for read_target_index & write_target_index with running plan or apply.

  on .terraform/modules/dynamodb_table_randomname.dynamodb_autoscaler/main.tf line 92, in resource "aws_appautoscaling_target" "read_target_index":
  92:   count              = var.enabled ? length(var.dynamodb_indexes) : 0

Code is:

resource "aws_kms_key" "kms_random" {
  description                 = "KMS key for inbox project"
} 

module "dynamodb_table_random1" {
  source                              = "git::https://github.com/cloudposse/terraform-aws-dynamodb.git?ref=tags/0.22.0"
  server_side_encryption_kms_key_arn  = aws_kms_key.kms_random.arn
  namespace                           = var.company
  stage                                     = var.aws_env
  name                                     = "random1"
  hash_key                               = "random1"
  autoscale_write_target              = 50
  autoscale_read_target               = 50
  autoscale_min_read_capacity         = 10
  autoscale_max_read_capacity         = 200
  autoscale_min_write_capacity        = 10
  autoscale_max_write_capacity        = 200
  enable_autoscaler                   = true

  dynamodb_attributes = [
    {
      name = "random1"
      type = "S"
    }
  ]
}

module "dynamodb_table_random2" {
  source                              = "git::https://github.com/cloudposse/terraform-aws-dynamodb.git?ref=tags/0.22.0"
  server_side_encryption_kms_key_arn  = aws_kms_key.kms_random.arn
  namespace                           = var.company
  stage                                     = var.aws_env
  name                                     = "random2"
  hash_key                               = "random2"
  autoscale_write_target              = 50
  autoscale_read_target               = 50
  autoscale_min_read_capacity         = 10
  autoscale_max_read_capacity         = 200
  autoscale_min_write_capacity        = 10
  autoscale_max_write_capacity        = 200
  enable_autoscaler                   = true

  dynamodb_attributes = [
    {
      name = "random2"
      type = "S"
    }
  ]
}

Expected Behavior

It should be able to run a plan and apply with local state without specifying a -out at the plan phase and apply with the output.
OR
by doing staged plan & apply with -target

Steps to Reproduce

Steps to reproduce the behavior:

  1. terraform plan (will work)
  2. terraform apply (will fail because of the count)

Works for me once

  1. terraform plan -out plan
  2. terraform apply "plan"
  3. terraform plan (does not work anymore)

Or it also works with -target but this is not the way we would want to work.

Environment (please complete the following information):

Terraform v0.13.5

  • provider registry.terraform.io/hashicorp/aws v3.16.0
  • provider registry.terraform.io/hashicorp/null v2.1.2

Additional Context

@leevs leevs added the bug 🐛 An issue with the system label Nov 19, 2020
@github-actions
Copy link

Thank you for reporting the issue! If you haven't already joined our slack community, then we invite you to do so.

This is a great place to get help and ask questions from our AMAZING community.

Slack Community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant