construct

package module
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: MIT Imports: 20 Imported by: 0

README

Astro Construct Library

---

The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


Introduction

Astro is the all-in-one web framework designed for speed. This library is supported modes, static, lambda and edge, to deploy astro website to AWS.

Usage

Static Hosting

Static Hosting

For developing, it's not recommended to deploy with CloudFront, because setup CloudFront is really too slow, at least takes 5min.

import "github.com/helbing/astrojs-aws-go/construct"


site := construct.NewStaticAstroSite(this, jsii.String("Site"), &StaticAstroSiteProps{
	SiteDir: jsii.String("/path/to/dist"),
})

awscdk.NewCfnOutput(this, jsii.String("Domains"), &CfnOutputProps{
	Value: site.Domains.join(jsii.String(", ")),
})

It's recommended to deploy with CloudFront in production environment.

import "github.com/helbing/astrojs-aws-go/construct"


site := construct.NewStaticAstroSite(this, jsii.String("Site"), &StaticAstroSiteProps{
	SiteDir: jsii.String("/path/to/dist"),
	CfOptions: &CfOptions{
		Domain: jsii.String("example.com"),
		CertificateArn: jsii.String("arn:aws:acm:us-east-1:xxx-xxx-xxx"),
	},
})

awscdk.NewCfnOutput(this, jsii.String("Domains"), &CfnOutputProps{
	Value: site.Domains.join(jsii.String(", ")),
})
Lambda Hosting

Lambda Hosting

import "github.com/helbing/astrojs-aws-go/construct"


site := construct.NewLambdaAstroSite(this, jsii.String("Site"), &LambdaAstroSiteProps{
	ServerEntry: jsii.String("/path/to/server/entry.mjs"),
	StaticDir: jsii.String("/path/to/client"),
})

awscdk.NewCfnOutput(this, jsii.String("Domains"), &CfnOutputProps{
	Value: site.Domains.join(jsii.String(", ")),
})

Deploy with CloudFront.

import "github.com/helbing/astrojs-aws-go/construct"


site := construct.NewLambdaAstroSite(this, jsii.String("Site"), &LambdaAstroSiteProps{
	ServerEntry: jsii.String("/path/to/server/entry.mjs"),
	StaticDir: jsii.String("/path/to/client"),
	CfOptions: &CfOptions{
		Domain: jsii.String("example.com"),
		CertificateArn: jsii.String("arn:aws:acm:us-east-1:xxx-xxx-xxx"),
	},
})

awscdk.NewCfnOutput(this, jsii.String("Domains"), &CfnOutputProps{
	Value: site.Domains.join(jsii.String(", ")),
})
Edge Hosting

Edge Hosting

As we known that, edge function working in Edge node. But for developing, setup CloudFront is really too slow. We can only deploy the Lambda function, and use AWS SAM for testing and debuging.

import "github.com/helbing/astrojs-aws-go/construct"


construct.NewEdgeAstroSite(this, jsii.String("Site"), &EdgeAstroSiteProps{
	ServerEntry: jsii.String("/path/to/server/entry.mjs"),
	StaticDir: jsii.String("/path/to/client"),
	OnlyLambda: jsii.Boolean(true),
})

Deploy to production environment.

import "github.com/helbing/astrojs-aws-go/construct"


site := construct.NewEdgeAstroSite(this, jsii.String("Site"), &EdgeAstroSiteProps{
	ServerEntry: jsii.String("/path/to/server/entry.mjs"),
	StaticDir: jsii.String("/path/to/client"),
	CfOptions: &CfOptions{
		Domain: jsii.String("example.com"),
		CertificateArn: jsii.String("arn:aws:acm:us-east-1:xxx-xxx-xxx"),
	},
})

awscdk.NewCfnOutput(this, jsii.String("Domains"), &CfnOutputProps{
	Value: site.Domains.join(jsii.String(", ")),
})

Documentation

Overview

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

The CDK Construct Library of Astro

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AstroSiteConstruct_IsConstruct

func AstroSiteConstruct_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func EdgeAstroSite_IsConstruct

func EdgeAstroSite_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func LambdaAstroSite_IsConstruct

func LambdaAstroSite_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

func NewAstroSiteConstruct_Override

func NewAstroSiteConstruct_Override(a AstroSiteConstruct, scope constructs.Construct, id *string)

Experimental.

func NewEdgeAstroSite_Override

func NewEdgeAstroSite_Override(e EdgeAstroSite, scope constructs.Construct, id *string, props *EdgeAstroSiteProps)

Experimental.

func NewLambdaAstroSite_Override

func NewLambdaAstroSite_Override(l LambdaAstroSite, scope constructs.Construct, id *string, props *LambdaAstroSiteProps)

Experimental.

func NewStaticAstroSite_Override

func NewStaticAstroSite_Override(s StaticAstroSite, scope constructs.Construct, id *string, props *StaticAstroSiteProps)

Experimental.

func StaticAstroSite_IsConstruct

func StaticAstroSite_IsConstruct(x interface{}) *bool

Checks if `x` is a construct.

Use this method instead of `instanceof` to properly detect `Construct` instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the `constructs` library on disk are seen as independent, completely different libraries. As a consequence, the class `Construct` in each copy of the `constructs` library is seen as a different class, and an instance of one class will not test as `instanceof` the other class. `npm install` will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the `constructs` library can be accidentally installed, and `instanceof` will behave unpredictably. It is safest to avoid using `instanceof`, and using this type-testing method instead.

Returns: true if `x` is an object created from a class which extends `Construct`. Experimental.

Types

type AssetsOptions added in v0.0.10

type AssetsOptions struct {
	// The CORS configuration of this bucket.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors.html
	//
	// Experimental.
	Cors *[]*awss3.CorsRule `field:"optional" json:"cors" yaml:"cors"`
	// Error document for the website.
	// Experimental.
	Errorhtml *string `field:"optional" json:"errorhtml" yaml:"errorhtml"`
	// Index document for the website.
	// Experimental.
	Indexhtml *string `field:"optional" json:"indexhtml" yaml:"indexhtml"`
}

The options for the Assets. Experimental.

type AstroSiteConstruct

type AstroSiteConstruct interface {
	constructs.Construct
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// New bucket.
	// Experimental.
	NewBucket(scope constructs.Construct, whEnabled *bool, props *AssetsOptions) awss3.Bucket
	// New CloudFront distribution.
	// Experimental.
	NewDistribution(scope constructs.Construct, defaultBehavior *awscloudfront.BehaviorOptions, props *CfOptions) awscloudfront.Distribution
	// New nodejs function.
	// Experimental.
	NewFunction(scope constructs.Construct, serverEntry *string, props *ServerOptions) awslambdanodejs.NodejsFunction
	// New HttpApi Gateway origin.
	// Experimental.
	NewHttpApiGatewayOrigin(httpApi awscdkapigatewayv2alpha.HttpApi) awscloudfrontorigins.HttpOrigin
	// New HttpApi Gateway.
	// Experimental.
	NewHttpApiGw(scope constructs.Construct, fn awslambdanodejs.NodejsFunction, props *GwOptions) awscdkapigatewayv2alpha.HttpApi
	// New S3 origin.
	// Experimental.
	NewS3Origin(scope constructs.Construct, bucket awss3.Bucket) awscloudfrontorigins.S3Origin
	// Parse routes from directory.
	//
	// if the item is directory will parse to {"/item/*": "/item/*"} or {"/item/{proxy+}": "/item/{proxy}"}
	// if the item is file will parse to {"/item": "/item"}.
	// Experimental.
	ParseRoutesFromDir(dir *string, isCf *bool) *map[string]*string
	// Transform string to Runtime.
	// Experimental.
	StrToRuntime(str *string) awslambda.Runtime
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

The base class for all constructs. Experimental.

func NewAstroSiteConstruct

func NewAstroSiteConstruct(scope constructs.Construct, id *string) AstroSiteConstruct

Experimental.

type CfOptions added in v0.0.10

type CfOptions struct {
	// Use a custom certificate for the distribution from AWS Certificate Manager (ACM).
	// See: https://aws.amazon.com/premiumsupport/knowledge-center/custom-ssl-certificate-cloudfront/
	//
	// Experimental.
	CertificateArn *string `field:"required" json:"certificateArn" yaml:"certificateArn"`
	// Domains of the website.
	// Experimental.
	Domain *string `field:"required" json:"domain" yaml:"domain"`
	// The CloudFront functions to invoke before serving the contents.
	// Experimental.
	CfFunctions *[]*awscloudfront.FunctionAssociation `field:"optional" json:"cfFunctions" yaml:"cfFunctions"`
	// The Lambda@Edge functions to invoke before serving the contents.
	// See: https://aws.amazon.com/lambda/edge
	//
	// Experimental.
	EdgeFunctions *[]*awscloudfront.EdgeLambda `field:"optional" json:"edgeFunctions" yaml:"edgeFunctions"`
	// How CloudFront should handle requests that are not successful (e.g., PageNotFound).
	// Experimental.
	ErrorResponses *[]*awscloudfront.ErrorResponse `field:"optional" json:"errorResponses" yaml:"errorResponses"`
	// Controls the countries in which your content is distributed.
	// Experimental.
	GeoRestriction awscloudfront.GeoRestriction `field:"optional" json:"geoRestriction" yaml:"geoRestriction"`
	// The Amazon S3 bucket to store the access logs in.
	// Experimental.
	LogBucket awss3.IBucket `field:"optional" json:"logBucket" yaml:"logBucket"`
	// An optional string that you want CloudFront to prefix to the access log filenames for this distribution.
	// Experimental.
	LogFilePrefix *string `field:"optional" json:"logFilePrefix" yaml:"logFilePrefix"`
	// Specifies whether you want CloudFront to include cookies in access logs.
	// Experimental.
	LogIncludesCookies *bool `field:"optional" json:"logIncludesCookies" yaml:"logIncludesCookies"`
	// The price class for the distribution (this impacts how many locations CloudFront uses for your distribution, and billing).
	// Experimental.
	PriceClass awscloudfront.PriceClass `field:"optional" json:"priceClass" yaml:"priceClass"`
	// Unique identifier that specifies the AWS WAF web ACL to associate with this CloudFront distribution.
	//
	// To specify a web ACL created using the latest version of AWS WAF, use the ACL ARN, for example
	// `arn:aws:wafv2:us-east-1:123456789012:global/webacl/ExampleWebACL/473e64fd-f30b-4765-81a0-62ad96dd167a`.
	//
	// To specify a web ACL created using AWS WAF Classic, use the ACL ID, for example `473e64fd-f30b-4765-81a0-62ad96dd167a`.
	// See: https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateDistribution.html#API_CreateDistribution_RequestParameters.
	//
	// Experimental.
	WebACLId *string `field:"optional" json:"webACLId" yaml:"webACLId"`
}

CloudFront options. Experimental.

type EdgeAstroSite

type EdgeAstroSite interface {
	AstroSiteConstruct
	// Experimental.
	BucketArn() *string
	// Experimental.
	BucketName() *string
	// Experimental.
	DistributionId() *string
	// Experimental.
	Domains() *[]*string
	// Experimental.
	FunctionArn() *string
	// Experimental.
	FunctionName() *string
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// New bucket.
	// Experimental.
	NewBucket(scope constructs.Construct, whEnabled *bool, props *AssetsOptions) awss3.Bucket
	// New CloudFront distribution.
	// Experimental.
	NewDistribution(scope constructs.Construct, defaultBehavior *awscloudfront.BehaviorOptions, props *CfOptions) awscloudfront.Distribution
	// New nodejs function.
	// Experimental.
	NewFunction(scope constructs.Construct, serverEntry *string, props *ServerOptions) awslambdanodejs.NodejsFunction
	// New HttpApi Gateway origin.
	// Experimental.
	NewHttpApiGatewayOrigin(httpApi awscdkapigatewayv2alpha.HttpApi) awscloudfrontorigins.HttpOrigin
	// New HttpApi Gateway.
	// Experimental.
	NewHttpApiGw(scope constructs.Construct, fn awslambdanodejs.NodejsFunction, props *GwOptions) awscdkapigatewayv2alpha.HttpApi
	// New S3 origin.
	// Experimental.
	NewS3Origin(scope constructs.Construct, bucket awss3.Bucket) awscloudfrontorigins.S3Origin
	// Parse routes from directory.
	//
	// if the item is directory will parse to {"/item/*": "/item/*"} or {"/item/{proxy+}": "/item/{proxy}"}
	// if the item is file will parse to {"/item": "/item"}.
	// Experimental.
	ParseRoutesFromDir(dir *string, isCf *bool) *map[string]*string
	// Transform string to Runtime.
	// Experimental.
	StrToRuntime(str *string) awslambda.Runtime
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

Experimental.

func NewEdgeAstroSite

func NewEdgeAstroSite(scope constructs.Construct, id *string, props *EdgeAstroSiteProps) EdgeAstroSite

Experimental.

type EdgeAstroSiteProps

type EdgeAstroSiteProps struct {
	// The server entry file, e.g. path.join(__dirname, "../server/entry.mjs").
	// Experimental.
	ServerEntry *string `field:"required" json:"serverEntry" yaml:"serverEntry"`
	// The directory of static files, e.g. path.join(__dirname, "../dist/client").
	// Experimental.
	StaticDir *string `field:"required" json:"staticDir" yaml:"staticDir"`
	// The options for the CloudFront distribution.
	//
	// CloudFront is required, unless `onlyLambda` is true.
	// Experimental.
	CfOptions *CfOptions `field:"optional" json:"cfOptions" yaml:"cfOptions"`
	// Only deploy the lambda function for testing, no S3 Bucket and CloudFront.
	//
	// Edge function only works in CloudFront, but it really deploy too slow.
	// Experimental.
	OnlyLambda *bool `field:"optional" json:"onlyLambda" yaml:"onlyLambda"`
	// The server options.
	// Experimental.
	ServerOptions *ServerOptions `field:"optional" json:"serverOptions" yaml:"serverOptions"`
}

The options for the EdgeAstroSite. Experimental.

type GwOptions added in v0.0.10

type GwOptions struct {
	// OIDC scopes attached to the gateway.
	// Experimental.
	AuthorizationScopes *[]*string `field:"optional" json:"authorizationScopes" yaml:"authorizationScopes"`
	// Authorizer to applied to the gateway.
	// Experimental.
	Authorizer awscdkapigatewayv2alpha.IHttpRouteAuthorizer `field:"optional" json:"authorizer" yaml:"authorizer"`
	// Specifies a CORS configuration for an API.
	// See: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html
	//
	// Experimental.
	Cors *awscdkapigatewayv2alpha.CorsPreflightOptions `field:"optional" json:"cors" yaml:"cors"`
}

The options for the CloudFront distribution. Experimental.

type LambdaAstroSite

type LambdaAstroSite interface {
	AstroSiteConstruct
	// Experimental.
	BucketArn() *string
	// Experimental.
	BucketName() *string
	// Experimental.
	DistributionId() *string
	// Experimental.
	Domains() *[]*string
	// Experimental.
	FunctionArn() *string
	// Experimental.
	FunctionName() *string
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// New bucket.
	// Experimental.
	NewBucket(scope constructs.Construct, whEnabled *bool, props *AssetsOptions) awss3.Bucket
	// New CloudFront distribution.
	// Experimental.
	NewDistribution(scope constructs.Construct, defaultBehavior *awscloudfront.BehaviorOptions, props *CfOptions) awscloudfront.Distribution
	// New nodejs function.
	// Experimental.
	NewFunction(scope constructs.Construct, serverEntry *string, props *ServerOptions) awslambdanodejs.NodejsFunction
	// New HttpApi Gateway origin.
	// Experimental.
	NewHttpApiGatewayOrigin(httpApi awscdkapigatewayv2alpha.HttpApi) awscloudfrontorigins.HttpOrigin
	// New HttpApi Gateway.
	// Experimental.
	NewHttpApiGw(scope constructs.Construct, fn awslambdanodejs.NodejsFunction, props *GwOptions) awscdkapigatewayv2alpha.HttpApi
	// New S3 origin.
	// Experimental.
	NewS3Origin(scope constructs.Construct, bucket awss3.Bucket) awscloudfrontorigins.S3Origin
	// Parse routes from directory.
	//
	// if the item is directory will parse to {"/item/*": "/item/*"} or {"/item/{proxy+}": "/item/{proxy}"}
	// if the item is file will parse to {"/item": "/item"}.
	// Experimental.
	ParseRoutesFromDir(dir *string, isCf *bool) *map[string]*string
	// Transform string to Runtime.
	// Experimental.
	StrToRuntime(str *string) awslambda.Runtime
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

Experimental.

func NewLambdaAstroSite

func NewLambdaAstroSite(scope constructs.Construct, id *string, props *LambdaAstroSiteProps) LambdaAstroSite

Experimental.

type LambdaAstroSiteProps

type LambdaAstroSiteProps struct {
	// The server entry file, e.g. path.join(__dirname, "../server/entry.mjs").
	// Experimental.
	ServerEntry *string `field:"required" json:"serverEntry" yaml:"serverEntry"`
	// The directory of static files, e.g. path.join(__dirname, "../dist/client").
	// Experimental.
	StaticDir *string `field:"required" json:"staticDir" yaml:"staticDir"`
	// The options for the CloudFront distribution.
	//
	// Recommended to use CloudFront for production.
	// Experimental.
	CfOptions *CfOptions `field:"optional" json:"cfOptions" yaml:"cfOptions"`
	// HttpApi Gateway options.
	// Experimental.
	GwOptions *GwOptions `field:"optional" json:"gwOptions" yaml:"gwOptions"`
	// The server options.
	// Experimental.
	ServerOptions *ServerOptions `field:"optional" json:"serverOptions" yaml:"serverOptions"`
}

The options for the LambdaAstroSite. Experimental.

type ServerOptions

type ServerOptions struct {
	// The maximum age of a request that Lambda sends to a function for processing.
	//
	// Minimum: 60 seconds
	// Maximum: 6 hours.
	// Experimental.
	MaxEventAge awscdk.Duration `field:"optional" json:"maxEventAge" yaml:"maxEventAge"`
	// The destination for failed invocations.
	// Experimental.
	OnFailure awslambda.IDestination `field:"optional" json:"onFailure" yaml:"onFailure"`
	// The destination for successful invocations.
	// Experimental.
	OnSuccess awslambda.IDestination `field:"optional" json:"onSuccess" yaml:"onSuccess"`
	// The maximum number of times to retry when the function returns an error.
	//
	// Minimum: 0
	// Maximum: 2.
	// Experimental.
	RetryAttempts *float64 `field:"optional" json:"retryAttempts" yaml:"retryAttempts"`
	// Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.
	// See: https://aws-otel.github.io/docs/getting-started/lambda
	//
	// Experimental.
	AdotInstrumentation *awslambda.AdotInstrumentationConfig `field:"optional" json:"adotInstrumentation" yaml:"adotInstrumentation"`
	// Whether to allow the Lambda to send all network traffic.
	//
	// If set to false, you must individually add traffic rules to allow the
	// Lambda to connect to network targets.
	// Experimental.
	AllowAllOutbound *bool `field:"optional" json:"allowAllOutbound" yaml:"allowAllOutbound"`
	// Lambda Functions in a public subnet can NOT access the internet.
	//
	// Use this property to acknowledge this limitation and still place the function in a public subnet.
	// See: https://stackoverflow.com/questions/52992085/why-cant-an-aws-lambda-function-inside-a-public-subnet-in-a-vpc-connect-to-the/52994841#52994841
	//
	// Experimental.
	AllowPublicSubnet *bool `field:"optional" json:"allowPublicSubnet" yaml:"allowPublicSubnet"`
	// The system architectures compatible with this lambda function.
	// Experimental.
	Architecture awslambda.Architecture `field:"optional" json:"architecture" yaml:"architecture"`
	// Code signing config associated with this function.
	// Experimental.
	CodeSigningConfig awslambda.ICodeSigningConfig `field:"optional" json:"codeSigningConfig" yaml:"codeSigningConfig"`
	// Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method.
	// Experimental.
	CurrentVersionOptions *awslambda.VersionOptions `field:"optional" json:"currentVersionOptions" yaml:"currentVersionOptions"`
	// The SQS queue to use if DLQ is enabled.
	//
	// If SNS topic is desired, specify `deadLetterTopic` property instead.
	// Experimental.
	DeadLetterQueue awssqs.IQueue `field:"optional" json:"deadLetterQueue" yaml:"deadLetterQueue"`
	// Enabled DLQ.
	//
	// If `deadLetterQueue` is undefined,
	// an SQS queue with default options will be defined for your Function.
	// Experimental.
	DeadLetterQueueEnabled *bool `field:"optional" json:"deadLetterQueueEnabled" yaml:"deadLetterQueueEnabled"`
	// The SNS topic to use as a DLQ.
	//
	// Note that if `deadLetterQueueEnabled` is set to `true`, an SQS queue will be created
	// rather than an SNS topic. Using an SNS topic as a DLQ requires this property to be set explicitly.
	// Experimental.
	DeadLetterTopic awssns.ITopic `field:"optional" json:"deadLetterTopic" yaml:"deadLetterTopic"`
	// A description of the function.
	// Experimental.
	Description *string `field:"optional" json:"description" yaml:"description"`
	// Key-value pairs that Lambda caches and makes available for your Lambda functions.
	//
	// Use environment variables to apply configuration changes, such
	// as test and production environment configurations, without changing your
	// Lambda function source code.
	// Experimental.
	Environment *map[string]*string `field:"optional" json:"environment" yaml:"environment"`
	// The AWS KMS key that's used to encrypt your function's environment variables.
	// Experimental.
	EnvironmentEncryption awskms.IKey `field:"optional" json:"environmentEncryption" yaml:"environmentEncryption"`
	// The size of the function’s /tmp directory in MiB.
	// Experimental.
	EphemeralStorageSize awscdk.Size `field:"optional" json:"ephemeralStorageSize" yaml:"ephemeralStorageSize"`
	// Event sources for this function.
	//
	// You can also add event sources using `addEventSource`.
	// Experimental.
	Events *[]awslambda.IEventSource `field:"optional" json:"events" yaml:"events"`
	// The filesystem configuration for the lambda function.
	// Experimental.
	Filesystem awslambda.FileSystem `field:"optional" json:"filesystem" yaml:"filesystem"`
	// A name for the function.
	// Experimental.
	FunctionName *string `field:"optional" json:"functionName" yaml:"functionName"`
	// Initial policy statements to add to the created Lambda Role.
	//
	// You can call `addToRolePolicy` to the created lambda to add statements post creation.
	// Experimental.
	InitialPolicy *[]awsiam.PolicyStatement `field:"optional" json:"initialPolicy" yaml:"initialPolicy"`
	// Specify the version of CloudWatch Lambda insights to use for monitoring.
	// See: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-Getting-Started-docker.html
	//
	// Experimental.
	InsightsVersion awslambda.LambdaInsightsVersion `field:"optional" json:"insightsVersion" yaml:"insightsVersion"`
	// A list of layers to add to the function's execution environment.
	//
	// You can configure your Lambda function to pull in
	// additional code during initialization in the form of layers. Layers are packages of libraries or other dependencies
	// that can be used by multiple functions.
	// Experimental.
	Layers *[]awslambda.ILayerVersion `field:"optional" json:"layers" yaml:"layers"`
	// The number of days log events are kept in CloudWatch Logs.
	//
	// When updating
	// this property, unsetting it doesn't remove the log retention policy. To
	// remove the retention policy, set the value to `INFINITE`.
	// Experimental.
	LogRetention awslogs.RetentionDays `field:"optional" json:"logRetention" yaml:"logRetention"`
	// When log retention is specified, a custom resource attempts to create the CloudWatch log group.
	//
	// These options control the retry policy when interacting with CloudWatch APIs.
	// Experimental.
	LogRetentionRetryOptions *awslambda.LogRetentionRetryOptions `field:"optional" json:"logRetentionRetryOptions" yaml:"logRetentionRetryOptions"`
	// The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
	// Experimental.
	LogRetentionRole awsiam.IRole `field:"optional" json:"logRetentionRole" yaml:"logRetentionRole"`
	// The amount of memory, in MB, that is allocated to your Lambda function.
	//
	// Lambda uses this value to proportionally allocate the amount of CPU
	// power. For more information, see Resource Model in the AWS Lambda
	// Developer Guide.
	// Experimental.
	MemorySize *float64 `field:"optional" json:"memorySize" yaml:"memorySize"`
	// Enable profiling.
	// See: https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html
	//
	// Experimental.
	Profiling *bool `field:"optional" json:"profiling" yaml:"profiling"`
	// Profiling Group.
	// See: https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html
	//
	// Experimental.
	ProfilingGroup awscodeguruprofiler.IProfilingGroup `field:"optional" json:"profilingGroup" yaml:"profilingGroup"`
	// The maximum of concurrent executions you want to reserve for the function.
	// See: https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html
	//
	// Experimental.
	ReservedConcurrentExecutions *float64 `field:"optional" json:"reservedConcurrentExecutions" yaml:"reservedConcurrentExecutions"`
	// Lambda execution role.
	//
	// This is the role that will be assumed by the function upon execution.
	// It controls the permissions that the function will have. The Role must
	// be assumable by the 'lambda.amazonaws.com' service principal.
	//
	// The default Role automatically has permissions granted for Lambda execution. If you
	// provide a Role, you must add the relevant AWS managed policies yourself.
	//
	// The relevant managed policies are "service-role/AWSLambdaBasicExecutionRole" and
	// "service-role/AWSLambdaVPCAccessExecutionRole".
	// Experimental.
	Role awsiam.IRole `field:"optional" json:"role" yaml:"role"`
	// Sets the runtime management configuration for a function's version.
	// Experimental.
	RuntimeManagementMode awslambda.RuntimeManagementMode `field:"optional" json:"runtimeManagementMode" yaml:"runtimeManagementMode"`
	// The list of security groups to associate with the Lambda's network interfaces.
	//
	// Only used if 'vpc' is supplied.
	// Experimental.
	SecurityGroups *[]awsec2.ISecurityGroup `field:"optional" json:"securityGroups" yaml:"securityGroups"`
	// The function execution time (in seconds) after which Lambda terminates the function.
	//
	// Because the execution time affects cost, set this value
	// based on the function's expected execution time.
	// Experimental.
	Timeout awscdk.Duration `field:"optional" json:"timeout" yaml:"timeout"`
	// Enable AWS X-Ray Tracing for Lambda Function.
	// Experimental.
	Tracing awslambda.Tracing `field:"optional" json:"tracing" yaml:"tracing"`
	// VPC network to place Lambda network interfaces.
	//
	// Specify this if the Lambda function needs to access resources in a VPC.
	// This is required when `vpcSubnets` is specified.
	// Experimental.
	Vpc awsec2.IVpc `field:"optional" json:"vpc" yaml:"vpc"`
	// Where to place the network interfaces within the VPC.
	//
	// This requires `vpc` to be specified in order for interfaces to actually be
	// placed in the subnets. If `vpc` is not specify, this will raise an error.
	//
	// Note: Internet access for Lambda Functions requires a NAT Gateway, so picking
	// public subnets is not allowed (unless `allowPublicSubnet` is set to `true`).
	// Experimental.
	VpcSubnets *awsec2.SubnetSelection `field:"optional" json:"vpcSubnets" yaml:"vpcSubnets"`
	// Bundling options.
	// Experimental.
	Bundling *awslambdanodejs.BundlingOptions `field:"optional" json:"bundling" yaml:"bundling"`
	// The Nodejs Runtime.
	// Experimental.
	Runtime *string `field:"optional" json:"runtime" yaml:"runtime"`
}

The options for the lambda function. Experimental.

type StaticAstroSite

type StaticAstroSite interface {
	AstroSiteConstruct
	// Experimental.
	BucketArn() *string
	// Experimental.
	BucketName() *string
	// Experimental.
	DistributionId() *string
	// Experimental.
	Domains() *[]*string
	// The tree node.
	// Experimental.
	Node() constructs.Node
	// New bucket.
	// Experimental.
	NewBucket(scope constructs.Construct, whEnabled *bool, props *AssetsOptions) awss3.Bucket
	// New CloudFront distribution.
	// Experimental.
	NewDistribution(scope constructs.Construct, defaultBehavior *awscloudfront.BehaviorOptions, props *CfOptions) awscloudfront.Distribution
	// New nodejs function.
	// Experimental.
	NewFunction(scope constructs.Construct, serverEntry *string, props *ServerOptions) awslambdanodejs.NodejsFunction
	// New HttpApi Gateway origin.
	// Experimental.
	NewHttpApiGatewayOrigin(httpApi awscdkapigatewayv2alpha.HttpApi) awscloudfrontorigins.HttpOrigin
	// New HttpApi Gateway.
	// Experimental.
	NewHttpApiGw(scope constructs.Construct, fn awslambdanodejs.NodejsFunction, props *GwOptions) awscdkapigatewayv2alpha.HttpApi
	// New S3 origin.
	// Experimental.
	NewS3Origin(scope constructs.Construct, bucket awss3.Bucket) awscloudfrontorigins.S3Origin
	// Parse routes from directory.
	//
	// if the item is directory will parse to {"/item/*": "/item/*"} or {"/item/{proxy+}": "/item/{proxy}"}
	// if the item is file will parse to {"/item": "/item"}.
	// Experimental.
	ParseRoutesFromDir(dir *string, isCf *bool) *map[string]*string
	// Transform string to Runtime.
	// Experimental.
	StrToRuntime(str *string) awslambda.Runtime
	// Returns a string representation of this construct.
	// Experimental.
	ToString() *string
}

Experimental.

func NewStaticAstroSite

func NewStaticAstroSite(scope constructs.Construct, id *string, props *StaticAstroSiteProps) StaticAstroSite

Experimental.

type StaticAstroSiteProps

type StaticAstroSiteProps struct {
	// The CORS configuration of this bucket.
	// See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-cors.html
	//
	// Experimental.
	Cors *[]*awss3.CorsRule `field:"optional" json:"cors" yaml:"cors"`
	// Error document for the website.
	// Experimental.
	Errorhtml *string `field:"optional" json:"errorhtml" yaml:"errorhtml"`
	// Index document for the website.
	// Experimental.
	Indexhtml *string `field:"optional" json:"indexhtml" yaml:"indexhtml"`
	// The directory of built files, e.g. path.join(__dirname, "../dist").
	// Experimental.
	SiteDir *string `field:"required" json:"siteDir" yaml:"siteDir"`
	// The options for the CloudFront distribution.
	// Experimental.
	CfOptions *CfOptions `field:"optional" json:"cfOptions" yaml:"cfOptions"`
}

The options for the StaticAstroSite. Experimental.

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL