(WAFv2): Missing CfnWebACL.IPSetReferenceStatementProperty implementation in Java.
When I was trying to implement an IP whitelisting rule within AWS WAFv2 CDK construct I ran into an impediment that necessary Builder for CfnWebACL.IPSetReferenceStatementProperty was non existent.
Reproduction Steps
// Creating a sample list of allowed IP set.
CfnIPSet allowedIpSet = CfnIPSet.Builder.create(this, "allowedIpSet")
.name("my-sample-ip-set")
.scope("REGIONAL")
.ipAddressVersion("IPV4")
.addresses(List.of(
"1.1.1.1/32",
"2.2.2.2/32",
"3.3.3.3/32"
))
.build();
// Creating a visibility property to track traffic around the rule.
CfnWebACL.VisibilityConfigProperty allowedIpSetVisibilityProperty = CfnWebACL.VisibilityConfigProperty.builder()
.cloudWatchMetricsEnabled(true)
.metricName("WAF-AllowedIpSet")
.sampledRequestsEnabled(true)
.build();
// Creating action property associated with the rule
CfnWebACL.RuleActionProperty ipSetActionRuleProperty = CfnWebACL.RuleActionProperty.builder()
.allow(Collections.emptyMap())
.build();
// Setting up RuleProperty where problesm arise with the statement() Builder method call.
// ipSetReferenceStatemnt takes param of IpSetReferenceStatementProperty type, that is missing concrete impl.
// Custom workaround is implemntation of custom class IpSetReferenceStatementPropertyImpl overriding IpSetReferenceStatementProperty method.
CfnWebACL.RuleProperty ipSetRuleProperty = CfnWebACL.RuleProperty.builder()
.name("AllowedIPSet")
.action(ipSetActionRuleProperty)
.visibilityConfig(allowedIpSetVisibilityProperty)
.priority(10)
.statement(
CfnWebACL.StatementOneProperty.builder().ipSetReferenceStatement(
new IpSetReferenceStatementPropertyImpl(allowedIpSet.getAttrArn()) // <-- problematic line with custom workaround
).build())
.build();
What did you expect to happen?
When I would try to implement the above steps, I would have expected that there is a Builder class associated with the IpSetReferenceStatementProperty interface that would enable me to implement the CfnWebACL.RuleProperty statement() completely.
What actually happened?
Environment
- CDK CLI Version : 1.95.1 (build ed2bbe6)
- Framework Version: 1.101.0
- Node.js Version:v12.18.4
- OS :MacOS 10.15.7
- Language (Version): Java (maven.compiler.target/source = 11)
Other
My custom implementation of the CfnWebACL.IpSetReferenceStatementProperty interface.
public class IpSetReferenceStatementPropertyImpl implements CfnWebACL.IPSetReferenceStatementProperty {
private String arn;
public IpSetReferenceStatementPropertyImpl(String arn) {
this.arn = arn;
}
@Override
public @NotNull String getArn() {
return this.arn;
}
}
Looking for the respective JavaDocs page also ends up with an "Looking for something?" error even though I followed the link from the CDK docs page.
This is :bug: Bug Report
Thanks for the bug report, @hgrgic !
This is a duplicate of #6643. There is a bug with jsii naming conventions and our CloudFormation spec generation that causes this to be misinterpreted as an interface and not generate the builder. Please go :+1: and track the status of the fix on the related issue.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.