cloudposse / terraform-aws-vpc-flow-logs-s3-bucket

Terraform module to provision s3-backed flow logs for VPC and subnets

Home Page:https://cloudposse.com/accelerate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ElvenSpellmaker opened this issue · comments

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.