How to create a s3 bucket using Boto3?

后端 未结 4 1550
离开以前
离开以前 2021-02-13 03:53

I want to enable cloudtrail logs for my account and so need to create an s3 bucket.I wanted to automate this task using Boto3.Currently I am using the following script



        
4条回答
  •  囚心锁ツ
    2021-02-13 04:26

    First, in boto3, if you setup security using "aws configure" , you don't need to declare that "sess" section (http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

    # if you already done aws configure
    import boto3
    s3 = boto3.client("s3")
    s3.create_bucket(Bucket="mybucket", ....) 
    

    Second, is the bad boto3 documentation that fail to link proper information. This is found under boto3 pdf, page 2181 (https://media.readthedocs.org/pdf/boto3/latest/boto3.pdf)

    Email : The value in the Grantee object is the registered email address of an AWS account.

    Grantee : The AWS user or group that you want to have access to transcoded files and playlists. To identify the user or group, you can specify the canonical user ID for an AWS account, an origin access identity for a CloudFront distribution, the registered email address of an AWS account, or a predefined Amazon S3 group

    And the easier solution is just use policy setting (http://support.cloudcheckr.com/getting-started-with-cloudcheckr/preparing-your-aws-account/aggregate-cloudtrail/) . You can convert the whole stuff using put_bucket_policy(), skip the dire GrantWrite,GrantWriteACP

提交回复
热议问题