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

Two errors when trying to plan 'Invalid count argument' and 'Incorrect attribute value type' #66

Open
ElvenSpellmaker opened this issue Nov 5, 2023 · 0 comments
Labels
bug 🐛 An issue with the system

Comments

@ElvenSpellmaker
Copy link

Describe the Bug

╷
│ Error: Invalid count argument
│
│   on .terraform\modules\foo.vpc_flow_logs.s3_log_storage_bucket.aws_s3_bucket\main.tf line 64, in resource "aws_s3_bucket_logging" "default":
│   64:   count  = local.enabled && var.logging != null ? 1 : 0
│
│ The "count" value depends on resource attributes that cannot be determined until
│ apply, so Terraform cannot predict how many instances will be created. To work
│ around this, use the -target argument to first apply only the resources that the
│ count depends on.
╵
╷
│ Error: Incorrect attribute value type
│
│   on .terraform\modules\foo.vpc_flow_logs.s3_log_storage_bucket\sqs_notifications.tf line 36, in data "aws_iam_policy_document" "sqs_policy":
│   36:       values   = module.aws_s3_bucket.bucket_arn
│     ├────────────────
│     │ module.aws_s3_bucket.bucket_arn is a string
│
│ Inappropriate value for attribute "values": list of string required.

local.enabled seems to reference module.this.enabled which seems to not be around at plan time.

Expected Behavior

Plan should work

Steps to Reproduce

module "vpc_flow_logs" {
  source  = "cloudposse/vpc-flow-logs-s3-bucket/aws"
  version = "~> 1.0"

  name = "${var.cluster_name}-vpc-flow-logs"

  lifecycle_configuration_rules = [
    {
      enabled                                = true
      id                                     = "lifecycle-policy"
      abort_incomplete_multipart_upload_days = 5

      transition = [
        {
          days          = var.standard_transition_days
          storage_class = "STANDARD_IA"
        },
        {
          days          = var.glacier_transition_days
          storage_class = "GLACIER"
        }
      ]

      noncurrent_version_transition = [
        {
          noncurrent_days = var.noncurrent_version_transition_days
          storage_class   = "GLACIER"
        }
      ]

      noncurrent_version_expiration = {
        noncurrent_days = var.noncurrent_version_expiry_days
      }

      expiration = {
        days = var.flow_log_expiry_days
      }
    }
  ]

  force_destroy           = var.flow_log_force_destroy
  allow_ssl_requests_only = var.flow_log_allow_ssl_requests_only
  vpc_id                  = module.vpc.vpc_id

  access_log_bucket_name       = module.logging_bucket.s3_bucket_id
  access_log_bucket_prefix     = "bucket_access_logs/"
  bucket_notifications_enabled = true

  tags = var.tags
}

Screenshots

No response

Environment

  • Windows
  • 11 23H2
  • 1.0.1
  • 1.6.3 (although seems irrelevant

Additional Context

This happens for both 1.0 and 1.0.1 and I can't continue using 0.18.x because of the provider changes which break the older version.

@ElvenSpellmaker ElvenSpellmaker added the bug 🐛 An issue with the system label Nov 5, 2023
@ElvenSpellmaker ElvenSpellmaker changed the title Two errors when trying to plan Two errors when trying to plan 'Invalid count argument' and 'Incorrect attribute value type' Nov 5, 2023
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

No branches or pull requests

1 participant