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.
[ ] 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.
[x] I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.
Description
Fixing #16 - which happens due to the code below
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 theaws_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 foraws_wafv2_web_acl.cloudfront_waf
inside ofaws_wafv2_web_acl_logging_configuration.waf_logging
's count condition.Like this:
Context
Issue #16
Type of changes
Checklist
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.