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.

property acm_certificate_specified: bool

ACM Certification specified conditional.

add_acm_cert() cloudfront.ViewerCertificate | Ref[source]

Add ACM cert.

add_aliases() list[str] | Ref[source]

Add aliases.

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_logging_bucket() cloudfront.Logging | Ref[source]

Add Logging Bucket.

add_origin_access_identity() CloudFrontOriginAccessIdentity[source]

Add the origin access identity resource to the template.

add_web_acl() list[str] | Ref[source]

Add Web ACL.

property aliases_specified: bool

Aliases are specified conditional.

property cf_enabled: bool

CloudFront enabled conditional.

property cf_logging_enabled: bool

CloudFront Logging specified conditional.

create_template() None[source]

Create template (main function called by CFNgin).

property directory_index_specified: bool

Directory Index specified conditional.

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.

get_lambda_associations() list[LambdaFunctionAssociation][source]

Retrieve any lambda associations from the instance variables.

property role_boundary_specified: bool

IAM Role Boundary specified conditional.

property waf_name_specified: bool

WAF name specified conditional.