本文整理汇总了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.)")