本文整理匯總了Python中boto.cloudfront.CloudFrontConnection.create_distribution方法的典型用法代碼示例。如果您正苦於以下問題:Python CloudFrontConnection.create_distribution方法的具體用法?Python CloudFrontConnection.create_distribution怎麽用?Python CloudFrontConnection.create_distribution使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類boto.cloudfront.CloudFrontConnection
的用法示例。
在下文中一共展示了CloudFrontConnection.create_distribution方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_distribution
# 需要導入模塊: from boto.cloudfront import CloudFrontConnection [as 別名]
# 或者: from boto.cloudfront.CloudFrontConnection import create_distribution [as 別名]
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!"
示例2: to_cdn
# 需要導入模塊: from boto.cloudfront import CloudFrontConnection [as 別名]
# 或者: from boto.cloudfront.CloudFrontConnection import create_distribution [as 別名]
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()
示例3: create_cloudfront_distribution
# 需要導入模塊: from boto.cloudfront import CloudFrontConnection [as 別名]
# 或者: from boto.cloudfront.CloudFrontConnection import create_distribution [as 別名]
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.)")