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)
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_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()

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

enable()

Deactivate 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.exception

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