Skip to content

Latest commit

 

History

History
445 lines (244 loc) · 21.8 KB

API.md

File metadata and controls

445 lines (244 loc) · 21.8 KB

API Reference

Classes

Name Description
AntiHotlinking The Anti-Hotlinking extension.
Custom Custom extension sample.
DefaultDirIndex Default Directory Indexes in Amazon S3-backed Amazon CloudFront Origins.
Distribution No description
ModifyResponseHeader The modify response header extension.
SecurtyHeaders Security Headers extension.
SelectOriginByViwerCountry selective origin by viewer counry.
ServerlessApp No description
SimpleLambdaEdge Simple content generation.

Structs

Name Description
AntiHotlinkingProps Construct properties for AntiHotlinking.
CustomProps No description
DistributionProps No description
SelectOriginByViwerCountryProps No description
ServerlessAppProps Construct properties for ServerlessApp.

Interfaces

Name Description
IExtensions The Extension interface.

class AntiHotlinking

The Anti-Hotlinking extension.

Implements: IConstruct, IConstruct, IConstruct, IDependable, IExtensions Extends: ServerlessApp

Initializer

new AntiHotlinking(scope: Construct, id: string, props: AntiHotlinkingProps)
  • scope (Construct) No description
  • id (string) No description
  • props (AntiHotlinkingProps) No description
    • referer (Array) Referer allow list with wildcard(* and ?) support i.e. example.com or exa?ple.*.

Properties

Name Type Description
eventType LambdaEdgeEventType The Lambda edge event type for this extension.
functionArn string Lambda function ARN for this extension.
functionVersion Version Lambda function version for the function.

class Custom

Custom extension sample.

Implements: IConstruct, IConstruct, IConstruct, IDependable, ITaggable, IExtensions Extends: NestedStack

Initializer

new Custom(scope: Construct, id: string, props: CustomProps)
  • scope (Construct) No description
  • id (string) No description
  • props (CustomProps) No description
    • code (AssetCode) The source code of your Lambda function. Default: Code.fromAsset(path.join(__dirname, '../lambda/function'))
    • eventType (LambdaEdgeEventType) The type of event in response to which should the function be invoked. Default: LambdaEdgeEventType.ORIGIN_RESPONSE
    • func (Function) Specify your Lambda function. Optional
    • handler (string) The name of the method within your code that Lambda calls to execute your function. Default: index.lambda_handler
    • runtime (Runtime) The runtime environment for the Lambda function that you are uploading. Default: Runtime.PYTHON_3_8
    • solutionId (string) The solution identifier. Default: no identifier
    • templateDescription (string) The template description. Default: ''
    • timeout (Duration) The function execution time (in seconds) after which Lambda terminates the function. Default: Duration.seconds(5)

Properties

Name Type Description
eventType LambdaEdgeEventType The Lambda edge event type for this extension.
functionArn string Lambda function ARN for this extension.
functionVersion Version Lambda function version for the function.
props CustomProps

class DefaultDirIndex

Default Directory Indexes in Amazon S3-backed Amazon CloudFront Origins.

use case - see https://aws.amazon.com/tw/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/

Implements: IConstruct, IConstruct, IConstruct, IDependable, ITaggable, IExtensions Extends: Custom

Initializer

new DefaultDirIndex(scope: Construct, id: string)
  • scope (Construct) No description
  • id (string) No description

Properties

Name Type Description
lambdaFunction Version

class Distribution

Implements: IConstruct, IConstruct, IConstruct, IDependable Extends: Construct

Initializer

new Distribution(scope: Construct, id: string, props: DistributionProps)
  • scope (Construct) No description
  • id (string) No description
  • props (DistributionProps) No description
    • defaultBehavior (BehaviorOptions) The default behavior for the distribution.
    • additionalBehaviors (Map<string, BehaviorOptions>) Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to. Default: no additional behaviors are added.
    • certificate (ICertificate) A certificate to associate with the distribution. Default: the CloudFront wildcard certificate (*.cloudfront.net) will be used.
    • comment (string) Any comments you want to include about the distribution. Default: no comment
    • defaultRootObject (string) The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/). Default: no default root object
    • domainNames (Array) Alternative domain names for this distribution. Default: The distribution will only support the default generated name (e.g., d111111abcdef8.cloudfront.net)
    • enabled (boolean) Enable or disable the distribution. Default: true
    • enableIpv6 (boolean) Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address. Default: true
    • enableLogging (boolean) Enable access logging for the distribution. Default: false, unless logBucket is specified.
    • errorResponses (Array<ErrorResponse>) How CloudFront should handle requests that are not successful (e.g., PageNotFound). Default: No custom error responses.
    • geoRestriction (GeoRestriction) Controls the countries in which your content is distributed. Default: No geographic restrictions
    • httpVersion (HttpVersion) Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront. Default: HttpVersion.HTTP2
    • logBucket (IBucket) The Amazon S3 bucket to store the access logs in. Default: A bucket is created if enableLogging is true
    • logFilePrefix (string) An optional string that you want CloudFront to prefix to the access log filenames for this distribution. Default: no prefix
    • logIncludesCookies (boolean) Specifies whether you want CloudFront to include cookies in access logs. Default: false
    • minimumProtocolVersion (SecurityPolicyProtocol) The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections. Default: SecurityPolicyProtocol.TLS_V1_2_2019
    • priceClass (PriceClass) The price class that corresponds with the maximum price that you want to pay for CloudFront service. Default: PriceClass.PRICE_CLASS_ALL
    • webAclId (string) Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution. Default: No AWS Web Application Firewall web access control list (web ACL).

Properties

Name Type Description
extensions Array<IExtensions>

class ModifyResponseHeader

The modify response header extension.

Implements: IConstruct, IConstruct, IConstruct, IDependable, IExtensions Extends: ServerlessApp

Initializer

new ModifyResponseHeader(scope: Construct, id: string)
  • scope (Construct) No description
  • id (string) No description

Properties

Name Type Description
eventType LambdaEdgeEventType The Lambda edge event type for this extension.
functionArn string Lambda function ARN for this extension.
functionVersion Version Lambda function version for the function.

class SecurtyHeaders

Security Headers extension.

Implements: IConstruct, IConstruct, IConstruct, IDependable, IExtensions Extends: ServerlessApp

Initializer

new SecurtyHeaders(scope: Construct, id: string)
  • scope (Construct) No description
  • id (string) No description

Properties

Name Type Description
eventType LambdaEdgeEventType The Lambda edge event type for this extension.
functionArn string Lambda function ARN for this extension.
functionVersion Version Lambda function version for the function.

class SelectOriginByViwerCountry

selective origin by viewer counry.

Implements: IConstruct, IConstruct, IConstruct, IDependable, ITaggable, IExtensions Extends: Custom

Initializer

new SelectOriginByViwerCountry(scope: Construct, id: string, props: SelectOriginByViwerCountryProps)

class ServerlessApp

Implements: IConstruct, IConstruct, IConstruct, IDependable Extends: Construct

Initializer

new ServerlessApp(scope: Construct, id: string, props: ServerlessAppProps)
  • scope (Construct) No description
  • id (string) No description
  • props (ServerlessAppProps) No description
    • applicationId (string) No description
    • semanticVersion (string) No description
    • parameters (Map<string, string>) The parameters for the ServerlessApp. Optional

Properties

Name Type Description
resource CfnResource

class SimpleLambdaEdge

Simple content generation.

Implements: IConstruct, IConstruct, IConstruct, IDependable, ITaggable, IExtensions Extends: Custom

Initializer

new SimpleLambdaEdge(scope: Construct, id: string)
  • scope (Construct) No description
  • id (string) No description

struct AntiHotlinkingProps

Construct properties for AntiHotlinking.

Name Type Description
referer Array Referer allow list with wildcard(* and ?) support i.e. example.com or exa?ple.*.

struct CustomProps

Name Type Description
code? AssetCode The source code of your Lambda function.
Default: Code.fromAsset(path.join(__dirname, '../lambda/function'))
eventType? LambdaEdgeEventType The type of event in response to which should the function be invoked.
Default: LambdaEdgeEventType.ORIGIN_RESPONSE
func? Function Specify your Lambda function.
Optional
handler? string The name of the method within your code that Lambda calls to execute your function.
Default: index.lambda_handler
runtime? Runtime The runtime environment for the Lambda function that you are uploading.
Default: Runtime.PYTHON_3_8
solutionId? string The solution identifier.
Default: no identifier
templateDescription? string The template description.
Default: ''
timeout? Duration The function execution time (in seconds) after which Lambda terminates the function.
Default: Duration.seconds(5)

struct DistributionProps

Name Type Description
defaultBehavior BehaviorOptions The default behavior for the distribution.
additionalBehaviors? Map<string, BehaviorOptions> Additional behaviors for the distribution, mapped by the pathPattern that specifies which requests to apply the behavior to.
Default: no additional behaviors are added.
certificate? ICertificate A certificate to associate with the distribution.
Default: the CloudFront wildcard certificate (*.cloudfront.net) will be used.
comment? string Any comments you want to include about the distribution.
Default: no comment
defaultRootObject? string The object that you want CloudFront to request from your origin (for example, index.html) when a viewer requests the root URL for your distribution. If no default object is set, the request goes to the origin's root (e.g., example.com/).
Default: no default root object
domainNames? Array Alternative domain names for this distribution.
Default: The distribution will only support the default generated name (e.g., d111111abcdef8.cloudfront.net)
enableIpv6? boolean Whether CloudFront will respond to IPv6 DNS requests with an IPv6 address.
Default: true
enableLogging? boolean Enable access logging for the distribution.
Default: false, unless logBucket is specified.
enabled? boolean Enable or disable the distribution.
Default: true
errorResponses? Array<ErrorResponse> How CloudFront should handle requests that are not successful (e.g., PageNotFound).
Default: No custom error responses.
geoRestriction? GeoRestriction Controls the countries in which your content is distributed.
Default: No geographic restrictions
httpVersion? HttpVersion Specify the maximum HTTP version that you want viewers to use to communicate with CloudFront.
Default: HttpVersion.HTTP2
logBucket? IBucket The Amazon S3 bucket to store the access logs in.
Default: A bucket is created if enableLogging is true
logFilePrefix? string An optional string that you want CloudFront to prefix to the access log filenames for this distribution.
Default: no prefix
logIncludesCookies? boolean Specifies whether you want CloudFront to include cookies in access logs.
Default: false
minimumProtocolVersion? SecurityPolicyProtocol The minimum version of the SSL protocol that you want CloudFront to use for HTTPS connections.
Default: SecurityPolicyProtocol.TLS_V1_2_2019
priceClass? PriceClass The price class that corresponds with the maximum price that you want to pay for CloudFront service.
Default: PriceClass.PRICE_CLASS_ALL
webAclId? string Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.
Default: No AWS Web Application Firewall web access control list (web ACL).

interface IExtensions

Implemented by: AntiHotlinking, Custom, DefaultDirIndex, ModifyResponseHeader, SecurtyHeaders, SelectOriginByViwerCountry, SimpleLambdaEdge

The Extension interface.

Properties

Name Type Description
eventType LambdaEdgeEventType The Lambda edge event type for this extension.
functionArn string Lambda function ARN for this extension.
functionVersion Version Lambda function version for the function.

struct SelectOriginByViwerCountryProps

Name Type Description
countryTable Map<string, string> The pre-defined country code table.

struct ServerlessAppProps

Construct properties for ServerlessApp.

Name Type Description
applicationId string
semanticVersion string
parameters? Map<string, string> The parameters for the ServerlessApp.
Optional