> **Experimental**
>
> `@aws-cdk/aws-route53resolver-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# FirewallRule

A Firewall Rule.

Used as argument in: [FirewallRuleGroup.addRule](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-route53resolver-alpha.FirewallRuleGroup.html#addrule)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`lib/firewall-rule-group.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-route53resolver-alpha/lib/firewall-rule-group.ts#L47)

## Example

TypeScript:

```ts
declare const myBlockList: route53resolver.FirewallDomainList;
declare const ruleGroup: route53resolver.FirewallRuleGroup;

ruleGroup.addRule({
  priority: 10,
  firewallDomainList: myBlockList,
  // block and reply with NXDOMAIN
  action: route53resolver.FirewallRuleAction.block(route53resolver.DnsBlockResponse.nxDomain()),
});

ruleGroup.addRule({
  priority: 20,
  firewallDomainList: myBlockList,
  // block and override DNS response with a custom domain
  action: route53resolver.FirewallRuleAction.block(route53resolver.DnsBlockResponse.override('amazon.com')),
});
```

Python:

```python
# my_block_list: route53resolver.FirewallDomainList
# rule_group: route53resolver.FirewallRuleGroup

rule_group.add_rule(
    priority=10,
    firewall_domain_list=my_block_list,
    # block and reply with NXDOMAIN
    action=route53resolver.FirewallRuleAction.block(route53resolver.DnsBlockResponse.nx_domain())
)

rule_group.add_rule(
    priority=20,
    firewall_domain_list=my_block_list,
    # block and override DNS response with a custom domain
    action=route53resolver.FirewallRuleAction.block(route53resolver.DnsBlockResponse.override("amazon.com"))
)
```

Java:

```java
FirewallDomainList myBlockList;
FirewallRuleGroup ruleGroup;

ruleGroup.addRule(FirewallRule.builder()
        .priority(10)
        .firewallDomainList(myBlockList)
        // block and reply with NXDOMAIN
        .action(FirewallRuleAction.block(DnsBlockResponse.nxDomain()))
        .build());

ruleGroup.addRule(FirewallRule.builder()
        .priority(20)
        .firewallDomainList(myBlockList)
        // block and override DNS response with a custom domain
        .action(FirewallRuleAction.block(DnsBlockResponse.override("amazon.com")))
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Route53Resolver.Alpha
FirewallDomainList myBlockList;
FirewallRuleGroup ruleGroup;

ruleGroup.AddRule(new FirewallRule {
    Priority = 10,
    FirewallDomainList = myBlockList,
    // block and reply with NXDOMAIN
    Action = FirewallRuleAction.Block(DnsBlockResponse.NxDomain())
});

ruleGroup.AddRule(new FirewallRule {
    Priority = 20,
    FirewallDomainList = myBlockList,
    // block and override DNS response with a custom domain
    Action = FirewallRuleAction.Block(DnsBlockResponse.Override("amazon.com"))
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkroute53resolveralpha/v2
var myBlockList FirewallDomainList
var ruleGroup FirewallRuleGroup

ruleGroup.AddRule(&FirewallRule{
	Priority: jsii.Number(10),
	FirewallDomainList: myBlockList,
	// block and reply with NXDOMAIN
	Action: route53resolver.FirewallRuleAction_Block(route53resolver.DnsBlockResponse_NxDomain()),
})

ruleGroup.AddRule(&FirewallRule{
	Priority: jsii.Number(20),
	FirewallDomainList: myBlockList,
	// block and override DNS response with a custom domain
	Action: route53resolver.FirewallRuleAction_*Block(route53resolver.DnsBlockResponse_Override(jsii.String("amazon.com"))),
})
```

## Properties

- `action`: [FirewallRuleAction](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-route53resolver-alpha.FirewallRuleAction.html) (required) — The action for this rule.

- `firewallDomainList`: [IFirewallDomainList](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-route53resolver-alpha.IFirewallDomainList.html) (required) — The domain list for this rule.

- `priority`: number (required) — The priority of the rule in the rule group.

  This value must be unique within
  the rule group.
