当前位置: 首页>>代码示例>>Python>>正文


Python s3.BucketPolicy方法代码示例

本文整理汇总了Python中troposphere.s3.BucketPolicy方法的典型用法代码示例。如果您正苦于以下问题:Python s3.BucketPolicy方法的具体用法?Python s3.BucketPolicy怎么用?Python s3.BucketPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在troposphere.s3的用法示例。


在下文中一共展示了s3.BucketPolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _add_bucket_policy

# 需要导入模块: from troposphere import s3 [as 别名]
# 或者: from troposphere.s3 import BucketPolicy [as 别名]
def _add_bucket_policy(template, bucket_title, bucket_name):
    template.add_resource(s3.BucketPolicy(
        "%sPolicy" % bucket_title,
        Bucket=bucket_name,
        PolicyDocument={
            "Version": "2012-10-17",
            "Statement": [{
                "Sid": "AddPerm",
                "Effect": "Allow",
                "Principal": "*",
                "Action": ["s3:GetObject"],
                "Resource":[
                    "arn:aws:s3:::%s/*" % bucket_name
                ]
            }]
        }
    )) 
开发者ID:elifesciences,项目名称:builder,代码行数:19,代码来源:trop.py

示例2: add_bucket

# 需要导入模块: from troposphere import s3 [as 别名]
# 或者: from troposphere.s3 import BucketPolicy [as 别名]
def add_bucket(self, name, access_control, static_site, route53, public_hosted_zone):
        """
        Helper method creates a directory service resource
        @param name [string] Fully qualified name for the bucket
        (corp.example.com)
        @param access_control [string] type of access control for the bucket
        @param static_site [boolean] should the bucket host a static site
        @param route53 [boolean] create a route53 entry?
        """

        if route53:
            self.add_dns_alias(
                name,
                "s3-website-us-east-1.amazonaws.com",
                "Z3AQBSTGFYJSTF",
                public_hosted_zone
            )

        if access_control == "PublicRead":
            policy = s3.BucketPolicy(
                name.replace('.', '') + "BucketPolicy",
                Bucket=name,
                PolicyDocument={
                    "Statement": [
                        {
                            "Sid": "PublicReadForGetBucketObjects",
                            "Effect": "Allow",
                            "Principal": "*",
                            "Action": "s3:GetObject",
                            "Resource": "arn:aws:s3:::%s/*" % name
                        }
                    ]
                }
            )
            self.add_resource(policy)

        bucket = s3.Bucket(
            name.replace('.', '') + "Bucket",
            BucketName=name,
            AccessControl=access_control,
        )

        if static_site:
            web_config = s3.WebsiteConfiguration(IndexDocument='index.html')
            bucket.properties['WebsiteConfiguration'] = web_config

        return self.add_resource(bucket) 
开发者ID:AWSFrederick,项目名称:Spires-Infra,代码行数:49,代码来源:aws_frederick_common.py


注:本文中的troposphere.s3.BucketPolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。