runway.hooks.staticsite.upload_staticsite module

CFNgin hook for syncing static website to S3 bucket.

runway.hooks.staticsite.upload_staticsite.get_archives_to_prune(archives, hook_data)[source]

Return list of keys to delete.

Parameters
  • archives (Dict) – The full list of file archives

  • hook_data (Dict) – CFNgin hook data

runway.hooks.staticsite.upload_staticsite.sync(context, provider, **kwargs)[source]

Sync static website to S3 bucket.

Parameters
runway.hooks.staticsite.upload_staticsite.display_static_website_url(website_url_handle, provider, context)[source]

Based on the url handle display the static website url.

Parameters
runway.hooks.staticsite.upload_staticsite.update_ssm_hash(context, session)[source]

Update the SSM hash with the new tracking data.

Parameters
runway.hooks.staticsite.upload_staticsite.get_distribution_data(context, provider, **kwargs)[source]

Retrieve information about the distribution.

Parameters
runway.hooks.staticsite.upload_staticsite.invalidate_distribution(session, identifier='', path='', domain='', **_)[source]

Invalidate the current distribution.

Parameters
  • session (Session) – The current CFNgin session.

  • identifier (string) – The distribution id.

  • path (string) – The distribution path.

  • domain (string) – The distribution domain.

runway.hooks.staticsite.upload_staticsite.prune_archives(context, session)[source]

Prune the archives from the bucket.

Parameters
runway.hooks.staticsite.upload_staticsite.auto_detect_content_type(filename)[source]

Auto detects the content type based on the filename.

Parameters

filename (str) – A filename to use to auto detect the content type.

Returns

The content type of the file. None if the content type could not be detected.

Return type

str

runway.hooks.staticsite.upload_staticsite.get_content_type(extra_file)[source]

Return the content type of the file.

Parameters

extra_file (Dict[str, Union[str, Dict[Any]]]) – The extra file configuration.

Returns

The content type of the extra file. If ‘content_type’ is provided then that is returned, otherways it is auto detected based on the name.

Return type

str

runway.hooks.staticsite.upload_staticsite.get_content(extra_file)[source]

Get serialized content based on content_type.

Parameters

extra_file (Dict[str, Union[str, Dict[Any]]]) – The extra file configuration.

Returns

Serialized content based on the content_type.

Return type

str

runway.hooks.staticsite.upload_staticsite.calculate_hash_of_extra_files(extra_files)[source]

Return a hash of all of the given extra files.

Adapted from stacker.hooks.aws_lambda; used according to its license: https://github.com/cloudtools/stacker/blob/1.4.0/LICENSE

All attributes of the extra file object are included when hashing: name, content_type, content, and file data.

Parameters

extra_files (List[Dict[str, Union[str, Dict[Any]]]]) – The list of extra file configurations.

Returns

The hash of all the files.

Return type

str

runway.hooks.staticsite.upload_staticsite.get_ssm_value(session, name)[source]

Get the ssm parameter value.

Parameters
  • session (runway.cfngin.session.Session) – The CFNgin session.

  • name (str) – The parameter name.

Returns

The parameter value.

Return type

str

runway.hooks.staticsite.upload_staticsite.set_ssm_value(session, name, value, description='')[source]

Set the ssm parameter.

Parameters
  • session (runway.cfngin.session.Session) – The CFNgin session.

  • name (str) – The name of the parameter.

  • value (str) – The value of the parameter.

  • description (str) – A description of the parameter.

runway.hooks.staticsite.upload_staticsite.sync_extra_files(context, bucket, extra_files, **kwargs)[source]

Sync static website extra files to S3 bucket.

Parameters
  • context (runway.cfngin.context.Context) – The context instance.

  • bucket (str) – The static site bucket name.

  • extra_files (List[Dict[str, str]]) – List of files and file content that should be uploaded.