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

Fix initial deploy invalid count dependency error #17

Conversation

adam-carruthers
Copy link

Description

Fixing #16 - which happens due to the code below

# modules/opennext-cloudfront/waf.tf
resource "aws_wafv2_web_acl" "cloudfront_waf" {
  count = var.custom_waf == null ? 1 : 0
  ...
}

resouce "aws_wafv2_web_acl_logging_configuration" "waf_logging" {
  count = var.waf_logging_configuration == null || try(aws_wafv2_web_acl.cloudfront_waf[0], null) == null ? 0 : 1
  ...
}

If you reference another resource in the count argument, terraform will fail on initial deploy because that other resource won't exist yet, so the count argument is not yet defined, but terraform needs the count argument to be defined for a deploy.

All the code is trying to do is deploy aws_wafv2_web_acl_logging_configuration.waf_logging only if the aws_wafv2_web_acl.cloudfront_waf exists (has count > 0). We can do this without causing this terraform error by simply placing the condition in the count for aws_wafv2_web_acl.cloudfront_waf inside of aws_wafv2_web_acl_logging_configuration.waf_logging's count condition.

Like this:

resource "aws_wafv2_web_acl_logging_configuration" "waf_logging" {
  count = var.waf_logging_configuration == null || var.custom_waf != null ? 0 : 1
  
  ...
}

Context

Issue #16

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@Tomdango Tomdango merged commit 2570005 into nhs-england-tools:main Nov 30, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants