def create_distribution(access_key_id, secret_access_key, origin, comment="", cnames=None): import time from boto.cloudfront import CloudFrontConnection """utility function to create a new distribution""" c = CloudFrontConnection( access_key_id, secret_access_key ) d = c.create_distribution(origin, True, '', cnames, comment) print """Created distribution - domain name: %s - origin: %s - status: %s - comment: %s - id: %s Over the next few minutes, the distribution will become active. This function will keep running until that happens. """ % (d.domain_name, d.config.origin, d.status, d.config.comment, d.id) # Keep polling CloudFront every 5 seconds until the status changes from # "InProgress" to (hopefully) "Deployed". print "\n" id = d.id while d.status == "InProgress": d = c.get_distribution_info(id) print "." time.sleep(5) print "\nThe distribution has been deployed!"
def create_distribution(access_key_id, secret_access_key, origin, comment="", cnames=None): import time from boto.cloudfront import CloudFrontConnection """utility function to create a new distribution""" c = CloudFrontConnection(access_key_id, secret_access_key) d = c.create_distribution(origin, True, '', cnames, comment) print """Created distribution - domain name: %s - origin: %s - status: %s - comment: %s - id: %s Over the next few minutes, the distribution will become active. This function will keep running until that happens. """ % (d.domain_name, d.config.origin, d.status, d.config.comment, d.id) # Keep polling CloudFront every 5 seconds until the status changes from # "InProgress" to (hopefully) "Deployed". print "\n" id = d.id while d.status == "InProgress": d = c.get_distribution_info(id) print "." time.sleep(5) print "\nThe distribution has been deployed!"
def to_cdn(c, slug): "Create a new Distribution object on CloudFront" from boto.cloudfront import CloudFrontConnection from boto.cloudfront.origin import CustomOrigin c = CloudFrontConnection(env.aws_access_key_id, env.aws_secret_access_key) d = c.create_distribution(origin=CustomOrigin( slug + '.cdn.readthedocs.org', origin_protocol_policy='http-only'), enabled=True, comment='Slug: ' + slug, cnames=[slug + '.readthedocs.org']) print "Created: " + d.domain_name + " for " + slug list_cdn()
def to_cdn(c, slug): "Create a new Distribution object on CloudFront" from boto.cloudfront import CloudFrontConnection from boto.cloudfront.origin import CustomOrigin c = CloudFrontConnection(env.aws_access_key_id, env.aws_secret_access_key) d = c.create_distribution( origin=CustomOrigin(slug + ".cdn.readthedocs.org", origin_protocol_policy="http-only"), enabled=True, comment="Slug: " + slug, cnames=[slug + ".readthedocs.org"], ) print "Created: " + d.domain_name + " for " + slug list_cdn()
def create_cloudfront_distribution(aws_access_key, aws_secret_key, bucket_endpoint, hostname): connection = CloudFrontConnection(aws_access_key, aws_secret_key) origin = CustomOrigin(dns_name=bucket_endpoint, origin_protocol_policy="http-only") distribution = connection.create_distribution(origin=origin, enabled=True, cnames=[hostname]) print("A CloudFront distribution has been created.") print("You need to do two things:") print("1. Go to the DNS provider for {hostname} and set up a CNAME to map it to {distribution_domain}".format( hostname=hostname, distribution_domain=distribution.domain_name )) print("2. Go to the AWS control panel, and associate the appropriate SSL cert with distribution {id}".format( id=distribution.id )) print("(The latter step is required because boto currently doesn't support setting certificates.)")
def create_cloudfront_distribution(aws_access_key, aws_secret_key, bucket_endpoint, hostname): connection = CloudFrontConnection(aws_access_key, aws_secret_key) origin = CustomOrigin(dns_name=bucket_endpoint, origin_protocol_policy="http-only") distribution = connection.create_distribution(origin=origin, enabled=True, cnames=[hostname]) print("A CloudFront distribution has been created.") print("You need to do two things:") print( "1. Go to the DNS provider for {hostname} and set up a CNAME to map it to {distribution_domain}" .format(hostname=hostname, distribution_domain=distribution.domain_name)) print( "2. Go to the AWS control panel, and associate the appropriate SSL cert with distribution {id}" .format(id=distribution.id)) print( "(The latter step is required because boto currently doesn't support setting certificates.)" )