waf-http-api
Version:
A CDK construct that fronts an HTTP API with a CloudFront distribution and protects it with AWS WAF.
203 lines (120 loc) • 6.31 kB
Markdown
# API Reference <a name="API Reference" id="api-reference"></a>
## Constructs <a name="Constructs" id="Constructs"></a>
### WafHttpApi <a name="WafHttpApi" id="waf-http-api.WafHttpApi"></a>
#### Initializers <a name="Initializers" id="waf-http-api.WafHttpApi.Initializer"></a>
```typescript
import { WafHttpApi } from 'waf-http-api'
new WafHttpApi(scope: Construct, id: string, props: WafHttpApiProps)
```
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#waf-http-api.WafHttpApi.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | The scope in which to define this construct (e.g., a CDK Stack). |
| <code><a href="#waf-http-api.WafHttpApi.Initializer.parameter.id">id</a></code> | <code>string</code> | The unique identifier for this construct within its scope. |
| <code><a href="#waf-http-api.WafHttpApi.Initializer.parameter.props">props</a></code> | <code><a href="#waf-http-api.WafHttpApiProps">WafHttpApiProps</a></code> | The properties required to configure this construct, including the target HTTP API and optional WAF rules. |
##### `scope`<sup>Required</sup> <a name="scope" id="waf-http-api.WafHttpApi.Initializer.parameter.scope"></a>
- *Type:* constructs.Construct
The scope in which to define this construct (e.g., a CDK Stack).
##### `id`<sup>Required</sup> <a name="id" id="waf-http-api.WafHttpApi.Initializer.parameter.id"></a>
- *Type:* string
The unique identifier for this construct within its scope.
##### `props`<sup>Required</sup> <a name="props" id="waf-http-api.WafHttpApi.Initializer.parameter.props"></a>
- *Type:* <a href="#waf-http-api.WafHttpApiProps">WafHttpApiProps</a>
The properties required to configure this construct, including the target HTTP API and optional WAF rules.
#### Methods <a name="Methods" id="Methods"></a>
| **Name** | **Description** |
| --- | --- |
| <code><a href="#waf-http-api.WafHttpApi.toString">toString</a></code> | Returns a string representation of this construct. |
##### `toString` <a name="toString" id="waf-http-api.WafHttpApi.toString"></a>
```typescript
public toString(): string
```
Returns a string representation of this construct.
#### Static Functions <a name="Static Functions" id="Static Functions"></a>
| **Name** | **Description** |
| --- | --- |
| <code><a href="#waf-http-api.WafHttpApi.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. |
##### ~~`isConstruct`~~ <a name="isConstruct" id="waf-http-api.WafHttpApi.isConstruct"></a>
```typescript
import { WafHttpApi } from 'waf-http-api'
WafHttpApi.isConstruct(x: any)
```
Checks if `x` is a construct.
###### `x`<sup>Required</sup> <a name="x" id="waf-http-api.WafHttpApi.isConstruct.parameter.x"></a>
- *Type:* any
Any object.
#### Properties <a name="Properties" id="Properties"></a>
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#waf-http-api.WafHttpApi.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. |
| <code><a href="#waf-http-api.WafHttpApi.property.distribution">distribution</a></code> | <code>aws-cdk-lib.aws_cloudfront.Distribution</code> | *No description.* |
| <code><a href="#waf-http-api.WafHttpApi.property.secretHeaderValue">secretHeaderValue</a></code> | <code>string</code> | *No description.* |
##### `node`<sup>Required</sup> <a name="node" id="waf-http-api.WafHttpApi.property.node"></a>
```typescript
public readonly node: Node;
```
- *Type:* constructs.Node
The tree node.
##### `distribution`<sup>Required</sup> <a name="distribution" id="waf-http-api.WafHttpApi.property.distribution"></a>
```typescript
public readonly distribution: Distribution;
```
- *Type:* aws-cdk-lib.aws_cloudfront.Distribution
##### `secretHeaderValue`<sup>Required</sup> <a name="secretHeaderValue" id="waf-http-api.WafHttpApi.property.secretHeaderValue"></a>
```typescript
public readonly secretHeaderValue: string;
```
- *Type:* string
#### Constants <a name="Constants" id="Constants"></a>
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#waf-http-api.WafHttpApi.property.SECRET_HEADER_NAME">SECRET_HEADER_NAME</a></code> | <code>string</code> | *No description.* |
##### `SECRET_HEADER_NAME`<sup>Required</sup> <a name="SECRET_HEADER_NAME" id="waf-http-api.WafHttpApi.property.SECRET_HEADER_NAME"></a>
```typescript
public readonly SECRET_HEADER_NAME: string;
```
- *Type:* string
## Structs <a name="Structs" id="Structs"></a>
### WafHttpApiProps <a name="WafHttpApiProps" id="waf-http-api.WafHttpApiProps"></a>
#### Initializer <a name="Initializer" id="waf-http-api.WafHttpApiProps.Initializer"></a>
```typescript
import { WafHttpApiProps } from 'waf-http-api'
const wafHttpApiProps: WafHttpApiProps = { ... }
```
#### Properties <a name="Properties" id="Properties"></a>
| **Name** | **Type** | **Description** |
| --- | --- | --- |
| <code><a href="#waf-http-api.WafHttpApiProps.property.httpApi">httpApi</a></code> | <code>aws-cdk-lib.aws_apigatewayv2.HttpApi</code> | The HTTP API to be protected by the WAF and CloudFront. |
| <code><a href="#waf-http-api.WafHttpApiProps.property.wafRules">wafRules</a></code> | <code>aws-cdk-lib.aws_wafv2.CfnWebACL.RuleProperty[]</code> | Optional: Custom WAF rules to apply to the WebACL. |
##### `httpApi`<sup>Required</sup> <a name="httpApi" id="waf-http-api.WafHttpApiProps.property.httpApi"></a>
```typescript
public readonly httpApi: HttpApi;
```
- *Type:* aws-cdk-lib.aws_apigatewayv2.HttpApi
The HTTP API to be protected by the WAF and CloudFront.
This should be an instance of `aws-cdk-lib/aws-apigatewayv2.HttpApi`.
##### `wafRules`<sup>Optional</sup> <a name="wafRules" id="waf-http-api.WafHttpApiProps.property.wafRules"></a>
```typescript
public readonly wafRules: RuleProperty[];
```
- *Type:* aws-cdk-lib.aws_wafv2.CfnWebACL.RuleProperty[]
- *Default:* AWS Managed Rules (AmazonIpReputationList, CommonRuleSet)
Optional: Custom WAF rules to apply to the WebACL.
If not provided, a default set of AWS Managed Rules will be used,
specifically "AWSManagedRulesAmazonIpReputationList" and "AWSManagedRulesCommonRuleSet".
These rules help protect against common web exploits and unwanted traffic.