nhs-england-tools / terraform-aws-opennext

🧱 💻 ☁️ A Terraform module for deploying a Next.js application built with OpenNext to AWS
MIT License
75 stars 10 forks source link

Initial deploy fails because of invalid count argument #16

Closed adam-carruthers closed 7 months ago

adam-carruthers commented 7 months ago

Is there an existing issue for this?

Current Behavior

Error on initial deploy

│ Error: Invalid count argument │ │ on .terraform/modules/opennext/modules/opennext-cloudfront/waf.tf line 125, in resource "aws_wafv2_web_acl_logging_configuration" "waf_logging": │ 125: count = var.waf_logging_configuration == null || try(aws_wafv2_web_acl.cloudfront_waf[0], null) == null ? 0 : 1 │ │ 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.

Expected Behavior

No error

Steps To Reproduce

Run the module with the following settings

module "opennext" {
  source  = "nhs-england-tools/opennext/aws"
  version = "1.0.3" # Use the latest release from https://github.com/nhs-england-tools/terraform-aws-opennext/releases

  prefix              = "ease-ealing-opennext"        # Prefix for all created resources
  opennext_build_path = "../../../.open-next"         # Path to your .open-next folder
  hosted_zone_id      = aws_route53_zone.main.zone_id # The Route53 hosted zone ID for your domain name

  cloudfront = {
    aliases                   = [local.domain_name]          # Your domain name
    acm_certificate_arn       = aws_acm_certificate.main.arn # The ACM (SSL) certificate for your domain
    waf_logging_configuration = null
  }
}

Output

No response

Code of Conduct

Sensitive Information Declaration

trustyoo86 commented 7 months ago

It hasn't been resolved yet?

Tomdango commented 7 months ago

Closing as fixed in #17