當前位置: 首頁>>代碼示例>>Python>>正文


Python CloudFrontConnection.create_distribution方法代碼示例

本文整理匯總了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!"
開發者ID:Adimpression,項目名稱:fileconveyor,代碼行數:32,代碼來源:transporter_cf.py

示例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()
開發者ID:hzyujun,項目名稱:readthedocs.org,代碼行數:16,代碼來源:fabfile.py

示例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.)")
開發者ID:pythonanywhere,項目名稱:microbit-deploy,代碼行數:18,代碼來源:create_distribution.py


注:本文中的boto.cloudfront.CloudFrontConnection.create_distribution方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。