message: Add examples for configuring defaultBehavior
diff: @@ -214,6 +214,61 @@ new StaticSite(this, "ReactSite", {
  });
  ```
  +### Configuring the default behavior
  +
  +The default behavior of the CloudFront distribution uses the internally created S3 bucket as the origin. You can configure this behavior.
  +
  +```js {8-11}
  +import { ViewerProtocolPolicy, AllowedMethods } from "@aws-cdk/aws-cloudfront";
  +
  +new StaticSite(this, "ReactSite", {
  + path: "path/to/src",
  + buildCommand: "npm run build",
  + buildOutput: "build",
  + cfDistribution: {
  + defaultBehavior: {
  + viewerProtocolPolicy: ViewerProtocolPolicy.HTTPS_ONLY,
  + allowedMethods: AllowedMethods.ALLOW_ALL,
  + },
  + },
  +});
  +```
  +
  +### Using Lambda@Edge
  +
  +```js {8-11}
  +import { LambdaEdgeEventType, experimental } from "@aws-cdk/aws-cloudfront";
  +
  +const edgeFunc = new experimental.EdgeFunction(this, "MyFunction", {
  + runtime: lambda.Runtime.NODEJS_12_X,
  + handler: "lambda.handler",
  + code: lambda.Code.fromAsset("path/to/dir"),
  + stackId: `${scope.logicalPrefixedName("edge-lambda")}`,
  +});
  +
  +new StaticSite(this, "ReactSite", {
  + path: "path/to/src",
  + buildCommand: "npm run build",
  + buildOutput: "build",
  + cfDistribution: {
  + defaultBehavior: {
  + edgeLambdas: [
  + {
  + functionVersion: edgeFunc.currentVersion,
  + eventType: LambdaEdgeEventType.VIEWER_RESPONSE,
  + },
  + ],
  + },
  + },
  +});
  +```
  +
  +Note that Lambda@Edge functions will be created in the `us-east-1` region, regardless of the region of your SST app. If the app is in `us-east-1`, the Lambda function is created directly in the stack. If the app is not in `us-east-1`, the Lambda function will be created in a new stack with the provided `stackId`. And the new stack will be deployed to `us-east-1`.
  +
  +:::caution
  +On `sst remove`, the Lambda@Edge functions cannot be removed right away as CloudFront needs to remove the function replicas from the edge locations. This can take up to a few hours. If the stack fails to remove, simply wait for sometime and retry.
  +:::
  +
  ## Properties
  An instance of `StaticSite` contains the following properties.
  @@ -368,6 +423,6 @@ Set this option if you have an existing certificate in the `us-east-1` region in
  ## StaticSiteCdkDistributionProps
  -`StaticSiteCdkDistributionProps` extends [`cdk.aws-cloudfront.DistributionProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudfront.DistributionProps.html) with the exception that the `defaultBehavior` field is **not required**.
  +`StaticSiteCdkDistributionProps` extends [`cdk.aws-cloudfront.DistributionProps`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudfront.DistributionProps.html) with the exception that the `defaultBehavior` field is **optional** and takes a [`cdk.aws-cloudfront.AddBehaviorOptions`](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-cloudfront.AddBehaviorOptions.html).
  You can use `StaticSiteCdkDistributionProps` to configure the CloudFront distribution properties.
  