runway.blueprints.staticsite.staticsite module¶
Module with static website bucket and CloudFront distribution.
- class runway.blueprints.staticsite.staticsite.StaticSite[source]¶
Bases:
Blueprint
CFNgin blueprint for creating S3 bucket and CloudFront distribution.
- add_bucket() Bucket [source]¶
Add the bucket resource along with an output of it’s name / website url.
- Returns:
The bucket resource.
- add_bucket_policy(bucket: Bucket) BucketPolicy [source]¶
Add a policy to the bucket if CloudFront is disabled. Ensure PublicRead.
- Parameters:
bucket – The bucket resource to place the policy.
- Returns:
The Bucket Policy Resource.
- add_cloudfront_bucket_policy(bucket: Bucket, oai: CloudFrontOriginAccessIdentity) BucketPolicy [source]¶
Given a bucket and oai resource add cloudfront access to the bucket.
- Keyword Arguments:
bucket – A bucket resource.
oai – An Origin Access Identity resource.
- Returns:
The CloudFront Bucket access resource.
- add_cloudfront_directory_index_rewrite(role: Role) Function [source]¶
Add an index CloudFront directory index rewrite lambda function to the template.
- Keyword Arguments:
role – The index rewrite role resource.
- Returns:
The CloudFront directory index rewrite lambda function resource.
- add_cloudfront_directory_index_rewrite_version(directory_index_rewrite: Function) Version [source]¶
Add a specific version to the directory index rewrite lambda.
- Parameters:
directory_index_rewrite – The directory index rewrite lambda resource.
- Returns:
The CloudFront directory index rewrite version.
- add_cloudfront_distribution(bucket_policy: BucketPolicy, cloudfront_distribution_options: dict[str, Any]) Distribution [source]¶
Add the CloudFront distribution to the template / output the id and domain name.
- Parameters:
bucket_policy – Bucket policy to allow CloudFront access.
cloudfront_distribution_options – The distribution options.
- Returns:
The CloudFront Distribution resource
- add_lambda_execution_role(name: str = 'LambdaExecutionRole', function_name: str = '') Role [source]¶
Create the Lambda@Edge execution role.
- Parameters:
name – Name for the Lambda Execution Role.
function_name – Name of the Lambda Function the Role will be attached to.
- add_origin_access_identity() CloudFrontOriginAccessIdentity [source]¶
Add the origin access identity resource to the template.
- get_cloudfront_distribution_options(bucket: Bucket, oai: CloudFrontOriginAccessIdentity, lambda_function_associations: list[LambdaFunctionAssociation]) dict[str, Any] [source]¶
Retrieve the options for our CloudFront distribution.
- Parameters:
bucket – The bucket resource
oai – The origin access identity resource.
lambda_function_associations – List of Lambda Function associations.
- Returns:
The CloudFront Distribution Options.
- static get_directory_index_lambda_association(lambda_associations: list[LambdaFunctionAssociation], directory_index_rewrite_version: Version) list[LambdaFunctionAssociation] [source]¶
Retrieve the directory index lambda associations with the added rewriter.
- Parameters:
lambda_associations – The lambda associations.
directory_index_rewrite_version – The directory index rewrite version.