CloudFront

boto.cloudfront

class boto.cloudfront.CloudFrontConnection(aws_access_key_id=None, aws_secret_access_key=None, port=None, proxy=None, proxy_port=None, host='cloudfront.amazonaws.com', debug=0, security_token=None, validate_certs=True, profile_name=None, https_connection_factory=None)
DefaultHost = 'cloudfront.amazonaws.com'
Version = '2010-11-01'
create_distribution(origin, enabled, caller_reference='', cnames=None, comment='', trusted_signers=None)
create_invalidation_request(distribution_id, paths, caller_reference=None)

Creates a new invalidation request :see: http://goo.gl/8vECq

create_origin_access_identity(caller_reference='', comment='')
create_streaming_distribution(origin, enabled, caller_reference='', cnames=None, comment='', trusted_signers=None)
delete_distribution(distribution_id, etag)
delete_origin_access_identity(access_id, etag)
delete_streaming_distribution(distribution_id, etag)
get_all_distributions()
get_all_origin_access_identity()
get_all_streaming_distributions()
get_distribution_config(distribution_id)
get_distribution_info(distribution_id)
get_etag(response)
get_invalidation_requests(distribution_id, marker=None, max_items=None)

Get all invalidation requests for a given CloudFront distribution. This returns an instance of an InvalidationListResultSet that automatically handles all of the result paging, etc. from CF - you just need to keep iterating until there are no more results.

Parameters:
  • distribution_id (string) – The id of the CloudFront distribution
  • marker (string) – Use this only when paginating results and only in follow-up request after you’ve received a response where the results are truncated. Set this to the value of the Marker element in the response you just received.
  • max_items (int) – Use this only when paginating results and only in a follow-up request to indicate the maximum number of invalidation requests you want in the response. You will need to pass the next_marker property from the previous InvalidationListResultSet response in the follow-up request in order to get the next ‘page’ of results.
Return type:

boto.cloudfront.invalidation.InvalidationListResultSet

Returns:

An InvalidationListResultSet iterator that lists invalidation requests for a given CloudFront distribution. Automatically handles paging the results.

get_origin_access_identity_config(access_id)
get_origin_access_identity_info(access_id)
get_streaming_distribution_config(distribution_id)
get_streaming_distribution_info(distribution_id)
invalidation_request_status(distribution_id, request_id, caller_reference=None)
set_distribution_config(distribution_id, etag, config)
set_origin_access_identity_config(access_id, etag, config)
set_streaming_distribution_config(distribution_id, etag, config)

boto.cloudfront.distribution

class boto.cloudfront.distribution.Distribution(connection=None, config=None, domain_name='', id='', last_modified_time=None, status='')
add_object(name, content, headers=None, replace=True)

Adds a new content object to the Distribution. The content for the object will be copied to a new Key in the S3 Bucket and the permissions will be set appropriately for the type of Distribution.

Parameters:
  • name (str or unicode) – The name or key of the new object.
  • content (file-like object) – A file-like object that contains the content for the new object.
  • headers (dict) – A dictionary containing additional headers you would like associated with the new object in S3.
Return type:

boto.cloudfront.object.Object

Returns:

The newly created object.

create_signed_url(url, keypair_id, expire_time=None, valid_after_time=None, ip_address=None, policy_url=None, private_key_file=None, private_key_string=None)

Creates a signed CloudFront URL that is only valid within the specified parameters.

Parameters:
  • url (str) – The URL of the protected object.
  • keypair_id (str) – The keypair ID of the Amazon KeyPair used to sign theURL. This ID MUST correspond to the private key specified with private_key_file or private_key_string.
  • expire_time (int) – The expiry time of the URL. If provided, the URL will expire after the time has passed. If not provided the URL will never expire. Format is a unix epoch. Use time.time() + duration_in_sec.
  • valid_after_time (int) – If provided, the URL will not be valid until after valid_after_time. Format is a unix epoch. Use time.time() + secs_until_valid.
  • ip_address (str) – If provided, only allows access from the specified IP address. Use ‘192.168.0.10’ for a single IP or use ‘192.168.0.0/24’ CIDR notation for a subnet.
  • policy_url (str) – If provided, allows the signature to contain wildcard globs in the URL. For example, you could provide: ‘http://example.com/media/*‘ and the policy and signature would allow access to all contents of the media subdirectory. If not specified, only allow access to the exact url provided in ‘url’.
  • private_key_file (str or file object.) – If provided, contains the filename of the private key file used for signing or an open file object containing the private key contents. Only one of private_key_file or private_key_string can be provided.
  • private_key_string (str) – If provided, contains the private key string used for signing. Only one of private_key_file or private_key_string can be provided.
Return type:

str

Returns:

The signed URL.

delete()

Delete this CloudFront Distribution. The content associated with the Distribution is not deleted from the underlying Origin bucket in S3.

disable()

Deactivate the Distribution. A convenience wrapper around the update method.

enable()

Activate the Distribution. A convenience wrapper around the update method.

endElement(name, value, connection)
get_objects()

Return a list of all content objects in this distribution.

Return type:list of boto.cloudfront.object.Object
Returns:The content objects
set_permissions(object, replace=False)

Sets the S3 ACL grants for the given object to the appropriate value based on the type of Distribution. If the Distribution is serving private content the ACL will be set to include the Origin Access Identity associated with the Distribution. If the Distribution is serving public content the content will be set up with “public-read”.

Parameters:
  • enabled – The Object whose ACL is being set
  • replace (bool) – If False, the Origin Access Identity will be appended to the existing ACL for the object. If True, the ACL for the object will be completely replaced with one that grants READ permission to the Origin Access Identity.
set_permissions_all(replace=False)

Sets the S3 ACL grants for all objects in the Distribution to the appropriate value based on the type of Distribution.

Parameters:replace (bool) – If False, the Origin Access Identity will be appended to the existing ACL for the object. If True, the ACL for the object will be completely replaced with one that grants READ permission to the Origin Access Identity.
startElement(name, attrs, connection)
update(enabled=None, cnames=None, comment=None)

Update the configuration of the Distribution. The only values of the DistributionConfig that can be directly updated are:

  • CNAMES
  • Comment
  • Whether the Distribution is enabled or not

Any changes to the trusted_signers or origin properties of this distribution’s current config object will also be included in the update. Therefore, to set the origin access identity for this distribution, set Distribution.config.origin.origin_access_identity before calling this update method.

Parameters:
  • enabled (bool) – Whether the Distribution is active or not.
  • cnames (list of str) – The DNS CNAME’s associated with this Distribution. Maximum of 10 values.
  • comment (str or unicode) – The comment associated with the Distribution.
class boto.cloudfront.distribution.DistributionConfig(connection=None, origin=None, enabled=False, caller_reference='', cnames=None, comment='', trusted_signers=None, default_root_object=None, logging=None)
Parameters:
  • origin (boto.cloudfront.origin.S3Origin or boto.cloudfront.origin.CustomOrigin) – Origin information to associate with the distribution. If your distribution will use an Amazon S3 origin, then this should be an S3Origin object. If your distribution will use a custom origin (non Amazon S3), then this should be a CustomOrigin object.
  • enabled (array of str) – Whether the distribution is enabled to accept end user requests for content.
  • caller_reference – A unique number that ensures the request can’t be replayed. If no caller_reference is provided, boto will generate a type 4 UUID for use as the caller reference.
  • cnames – A CNAME alias you want to associate with this distribution. You can have up to 10 CNAME aliases per distribution.
  • comment (str) – Any comments you want to include about the distribution.
  • trusted_signers (:class`boto.cloudfront.signers.TrustedSigners`) – Specifies any AWS accounts you want to permit to create signed URLs for private content. If you want the distribution to use signed URLs, this should contain a TrustedSigners object; if you want the distribution to use basic URLs, leave this None.
  • default_root_object – Designates a default root object. Only include a DefaultRootObject value if you are going to assign a default root object for the distribution.
  • logging (:class`boto.cloudfront.logging.LoggingInfo`) – Controls whether access logs are written for the distribution. If you want to turn on access logs, this should contain a LoggingInfo object; otherwise it should contain None.
endElement(name, value, connection)
startElement(name, attrs, connection)
to_xml()
class boto.cloudfront.distribution.DistributionSummary(connection=None, domain_name='', id='', last_modified_time=None, status='', origin=None, cname='', comment='', enabled=False)
endElement(name, value, connection)
get_distribution()
startElement(name, attrs, connection)
class boto.cloudfront.distribution.StreamingDistribution(connection=None, config=None, domain_name='', id='', last_modified_time=None, status='')
delete()
startElement(name, attrs, connection)
update(enabled=None, cnames=None, comment=None)

Update the configuration of the StreamingDistribution. The only values of the StreamingDistributionConfig that can be directly updated are:

  • CNAMES
  • Comment
  • Whether the Distribution is enabled or not

Any changes to the trusted_signers or origin properties of this distribution’s current config object will also be included in the update. Therefore, to set the origin access identity for this distribution, set StreamingDistribution.config.origin.origin_access_identity before calling this update method.

Parameters:
  • enabled (bool) – Whether the StreamingDistribution is active or not.
  • cnames (list of str) – The DNS CNAME’s associated with this Distribution. Maximum of 10 values.
  • comment (str or unicode) – The comment associated with the Distribution.
class boto.cloudfront.distribution.StreamingDistributionConfig(connection=None, origin='', enabled=False, caller_reference='', cnames=None, comment='', trusted_signers=None, logging=None)
to_xml()
class boto.cloudfront.distribution.StreamingDistributionSummary(connection=None, domain_name='', id='', last_modified_time=None, status='', origin=None, cname='', comment='', enabled=False)
get_distribution()

boto.cloudfront.origin

class boto.cloudfront.origin.CustomOrigin(dns_name=None, http_port=80, https_port=443, origin_protocol_policy=None)

Origin information to associate with the distribution. If your distribution will use a non-Amazon S3 origin, then you use the CustomOrigin element.

Parameters:
  • dns_name (str) – The DNS name of your Amazon S3 bucket to associate with the distribution. For example: mybucket.s3.amazonaws.com.
  • http_port (int) – The HTTP port the custom origin listens on.
  • https_port – The HTTPS port the custom origin listens on.
  • origin_protocol_policy (str) – The origin protocol policy to apply to your origin. If you specify http-only, CloudFront will use HTTP only to access the origin. If you specify match-viewer, CloudFront will fetch from your origin using HTTP or HTTPS, based on the protocol of the viewer request.
endElement(name, value, connection)
startElement(name, attrs, connection)
to_xml()
class boto.cloudfront.origin.S3Origin(dns_name=None, origin_access_identity=None)

Origin information to associate with the distribution. If your distribution will use an Amazon S3 origin, then you use the S3Origin element.

Parameters:
  • dns_name (str) – The DNS name of your Amazon S3 bucket to associate with the distribution. For example: mybucket.s3.amazonaws.com.
  • origin_access_identity (str) – The CloudFront origin access identity to associate with the distribution. If you want the distribution to serve private content, include this element; if you want the distribution to serve public content, remove this element.
endElement(name, value, connection)
startElement(name, attrs, connection)
to_xml()
boto.cloudfront.origin.get_oai_value(origin_access_identity)

boto.cloudfront.identity

class boto.cloudfront.identity.OriginAccessIdentity(connection=None, config=None, id='', s3_user_id='', comment='')
delete()
endElement(name, value, connection)
startElement(name, attrs, connection)
update(comment=None)
uri()
class boto.cloudfront.identity.OriginAccessIdentityConfig(connection=None, caller_reference='', comment='')
endElement(name, value, connection)
startElement(name, attrs, connection)
to_xml()
class boto.cloudfront.identity.OriginAccessIdentitySummary(connection=None, id='', s3_user_id='', comment='')
endElement(name, value, connection)
get_origin_access_identity()
startElement(name, attrs, connection)

boto.cloudfront.signers

class boto.cloudfront.signers.ActiveTrustedSigners

x.__init__(...) initializes x; see help(type(x)) for signature

endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudfront.signers.Signer
endElement(name, value, connection)
startElement(name, attrs, connection)
class boto.cloudfront.signers.TrustedSigners

x.__init__(...) initializes x; see help(type(x)) for signature

endElement(name, value, connection)
startElement(name, attrs, connection)

boto.cloudfront.invalidation

class boto.cloudfront.invalidation.InvalidationBatch(paths=None, connection=None, distribution=None, caller_reference='')

A simple invalidation request. :see: http://docs.amazonwebservices.com/AmazonCloudFront/2010-08-01/APIReference/index.html?InvalidationBatchDatatype.html

Create a new invalidation request: :paths: An array of paths to invalidate

add(path)

Add another path to this invalidation request

endElement(name, value, connection)
escape(p)

Escape a path, make sure it begins with a slash and contains no invalid characters

remove(path)

Remove a path from this invalidation request

startElement(name, attrs, connection)
to_xml()

Get this batch as XML

class boto.cloudfront.invalidation.InvalidationListResultSet(markers=None, connection=None, distribution_id=None, invalidations=None, marker='', next_marker=None, max_items=None, is_truncated=False)

A resultset for listing invalidations on a given CloudFront distribution. Implements the iterator interface and transparently handles paging results from CF so even if you have many thousands of invalidations on the distribution you can iterate over all invalidations in a reasonably efficient manner.

endElement(name, value, connection)
startElement(name, attrs, connection)
to_boolean(value, true_value='true')
class boto.cloudfront.invalidation.InvalidationSummary(connection=None, distribution_id=None, id='', status='')

Represents InvalidationSummary complex type in CloudFront API that lists the id and status of a given invalidation request.

endElement(name, value, connection)
get_distribution()

Returns a Distribution object representing the parent CloudFront distribution of the invalidation request listed in the InvalidationSummary.

Return type:boto.cloudfront.distribution.Distribution
Returns:A Distribution object representing the parent CloudFront distribution of the invalidation request listed in the InvalidationSummary
get_invalidation_request()

Returns an InvalidationBatch object representing the invalidation request referred to in the InvalidationSummary.

Return type:boto.cloudfront.invalidation.InvalidationBatch
Returns:An InvalidationBatch object representing the invalidation request referred to by the InvalidationSummary
startElement(name, attrs, connection)

boto.cloudfront.object

class boto.cloudfront.object.Object(bucket, name=None)
url(scheme='http')
class boto.cloudfront.object.StreamingObject(bucket, name=None)
url(scheme='rtmp')

boto.cloudfront.logging

class boto.cloudfront.logging.LoggingInfo(bucket='', prefix='')
endElement(name, value, connection)
startElement(name, attrs, connection)

boto.cloudfront.exception

exception boto.cloudfront.exception.CloudFrontServerError(status, reason, body=None, *args)