runway.blueprints.staticsite.staticsite module¶
Module with static website bucket and CloudFront distribution.
-
class
runway.blueprints.staticsite.staticsite.
StaticSite
(name, context, mappings=None, description=None)[source]¶ Bases:
runway.cfngin.blueprints.base.Blueprint
CFNgin blueprint for creating S3 bucket and CloudFront distribution.
Instantiate class.
- Parameters
name (str) – A name for the blueprint.
context (
runway.cfngin.context.Context
) – Context the blueprint is being executed under.mappings (dict, optional) – CloudFormation Mappings to be used in the template.
description (str) – Used to describe the resulting CloudFormation template.
-
VARIABLES
= {'AcmCertificateArn': {'default': '', 'description': '(Optional) Cert ARN for site', 'type': <class 'str'>}, 'Aliases': {'default': [], 'description': '(Optional) Domain aliases the distribution', 'type': <class 'list'>}, 'DisableCloudFront': {'default': False, 'description': 'Whether to disable CF', 'type': <class 'bool'>}, 'LogBucketName': {'default': '', 'description': 'S3 bucket for CF logs', 'type': <class 'str'>}, 'PriceClass': {'default': 'PriceClass_100', 'description': 'CF price class for the distribution.', 'type': <class 'str'>}, 'RewriteDirectoryIndex': {'default': '', 'description': '(Optional) File name to append to directory requests.', 'type': <class 'str'>}, 'RoleBoundaryArn': {'default': '', 'description': '(Optional) IAM Role permissions boundary applied to any created roles.', 'type': <class 'str'>}, 'WAFWebACL': {'default': '', 'description': '(Optional) WAF id to associate with the distribution.', 'type': <class 'str'>}, 'custom_error_responses': {'default': [], 'description': '(Optional) Custom error responses.', 'type': <class 'list'>}, 'lambda_function_associations': {'default': [], 'description': '(Optional) Lambda function associations.', 'type': <class 'list'>}}¶
-
property
aliases_specified
¶ Aliases are specified conditional.
-
property
cf_enabled
¶ CloudFront enabled conditional.
-
property
acm_certificate_specified
¶ ACM Certification specified conditional.
-
property
cf_logging_enabled
¶ CloudFront Logging specified conditional.
-
property
directory_index_specified
¶ Directory Index specified conditional.
-
property
role_boundary_specified
¶ IAM Role Boundary specified conditional.
-
property
waf_name_specified
¶ WAF name specified conditional.
-
get_lambda_associations
()[source]¶ Retrieve any lambda associations from the instance variables.
- Returns
List of Lambda Function association variables
-
get_directory_index_lambda_association
(lambda_associations, directory_index_rewrite_version)[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_cloudfront_distribution_options
(bucket, oai, lambda_function_associations)[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.
-
add_origin_access_identity
()[source]¶ Add the origin access identity resource to the template.
- Returns
The OAI resource
-
add_bucket_policy
(bucket)[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_bucket
()[source]¶ Add the bucket resource along with an output of it’s name / website url.
- Returns
The bucket resource.
-
add_cloudfront_bucket_policy
(bucket, oai)[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_lambda_execution_role
(name='LambdaExecutionRole', function_name='')[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_cloudfront_directory_index_rewrite
(role)[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)[source]¶ Add a specific version to the directory index rewrite lambda.