boto3_s3_bucket

Connection module for Amazon S3 Buckets using boto3.

Renamed from boto_s3_bucket to boto3_s3_bucket and rewritten to use the boto3 s3 client APIs directly via saltext.boto3.utils.boto3mod. The legacy boto2 code path (object-style access, retry loops) has been removed.

depends:
  • boto3 >= 1.28.0

  • botocore >= 1.31.0

configuration:

This module accepts explicit S3 credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API and no further configuration is necessary. More Information available at:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html

If IAM roles are not used you need to specify them either in the minion’s config file or as a profile. For example, to specify them in the minion’s config file:

s3.keyid: GKTADJGHEIQSXMKKRBJ08H
s3.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs

A region may also be specified in the configuration:

s3.region: us-east-1

It’s also possible to specify key, keyid and region via a profile, either as a passed in dict, or as a string to pull from pillars or minion config:

myprofile:
    keyid: GKTADJGHEIQSXMKKRBJ08H
    key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
    region: us-east-1

Added in version 1.0.0.

saltext.boto3.modules.boto3_s3_bucket.__virtual__()[source]

Only load if boto3 is available.

saltext.boto3.modules.boto3_s3_bucket.exists(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Given a bucket name, check to see if the given bucket exists.

Bucket (str):

The name of the S3 bucket to check for existence.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.exists mybucket
saltext.boto3.modules.boto3_s3_bucket.create(Bucket, ACL=None, LocationConstraint=None, GrantFullControl=None, GrantRead=None, GrantReadACP=None, GrantWrite=None, GrantWriteACP=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, create an S3 Bucket.

Bucket (str):

The name of the S3 bucket to create.

ACL (str, optional):

The canned ACL to apply to the bucket.

LocationConstraint (str, optional):

The AWS region where the bucket will be created.

GrantFullControl (str, optional):

The grantee is granted FULL_CONTROL permissions on the bucket.

GrantRead (str, optional):

The grantee is granted READ permissions on the bucket.

GrantReadACP (str, optional):

The grantee is granted READ_ACP permissions on the bucket.

GrantWrite (str, optional):

The grantee is granted WRITE permissions on the bucket.

GrantWriteACP (str, optional):

The grantee is granted WRITE_ACP permissions on the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.create my_bucket \
                 GrantFullControl='emailaddress=example@example.com' \
                 GrantRead='uri="http://acs.amazonaws.com/groups/global/AllUsers"' \
                 GrantReadACP='emailaddress="exampl@example.com",id="2345678909876432"' \
                 LocationConstraint=us-west-1
saltext.boto3.modules.boto3_s3_bucket.delete(Bucket, MFA=None, RequestPayer=None, Force=False, region=None, key=None, keyid=None, profile=None)[source]

Given a bucket name, delete it, optionally emptying it first.

Bucket (str):

The name of the S3 bucket to delete.

MFA (str, optional):

The MFA authentication information.

RequestPayer (str, optional):

Confirms that the requester knows that they will be charged for the request.

Force (bool, optional):

If True, empties the bucket before deleting it.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete mybucket
saltext.boto3.modules.boto3_s3_bucket.delete_objects(Bucket, Delete, MFA=None, RequestPayer=None, region=None, key=None, keyid=None, profile=None)[source]

Delete objects in a given S3 bucket.

Bucket (str):

The name of the S3 bucket containing the objects to delete.

Delete (dict):

A dictionary specifying the objects to delete. Must contain an “Objects” key with a list of object keys.

MFA (str, optional):

The MFA authentication information.

RequestPayer (str, optional):

Confirms that the requester knows that they will be charged for the request.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_objects mybucket '{Objects: [Key: myobject]}'
saltext.boto3.modules.boto3_s3_bucket.describe(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Given a bucket name describe its properties.

Bucket (str):

The name of the S3 bucket to describe.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.describe mybucket
saltext.boto3.modules.boto3_s3_bucket.empty(Bucket, MFA=None, RequestPayer=None, region=None, key=None, keyid=None, profile=None)[source]

Delete all objects in a given S3 bucket.

Bucket (str):

The name of the S3 bucket to empty.

MFA (str, optional):

The MFA authentication information.

RequestPayer (str, optional):

Confirms that the requester knows that they will be charged for the request.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.empty mybucket
saltext.boto3.modules.boto3_s3_bucket.list(region=None, key=None, keyid=None, profile=None)[source]

List all buckets owned by the authenticated sender of the request.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

Owner: {...}
Buckets:
  - {...}
  - {...}
saltext.boto3.modules.boto3_s3_bucket.list_object_versions(Bucket, Delimiter=None, EncodingType=None, Prefix=None, region=None, key=None, keyid=None, profile=None)[source]

List objects in a given S3 bucket.

Bucket (str):

The name of the S3 bucket to list object versions for.

Delimiter (str, optional):

A delimiter is a character you use to group keys.

EncodingType (str, optional):

Requests Amazon S3 to encode the object keys in the response.

Prefix (str, optional):

Limits the response to keys that begin with the specified prefix.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.list_object_versions mybucket
saltext.boto3.modules.boto3_s3_bucket.list_objects(Bucket, Delimiter=None, EncodingType=None, Prefix=None, FetchOwner=False, StartAfter=None, region=None, key=None, keyid=None, profile=None)[source]

List objects in a given S3 bucket.

Bucket (str):

The name of the S3 bucket to list objects for.

Delimiter (str, optional):

A delimiter is a character you use to group keys.

EncodingType (str, optional):

Requests Amazon S3 to encode the object keys in the response.

Prefix (str, optional):

Limits the response to keys that begin with the specified prefix.

FetchOwner (bool, optional):

Specifies whether to include the owner field in the response.

StartAfter (str, optional):

Start listing after this key.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.list_objects mybucket
saltext.boto3.modules.boto3_s3_bucket.put_acl(Bucket, ACL=None, AccessControlPolicy=None, GrantFullControl=None, GrantRead=None, GrantReadACP=None, GrantWrite=None, GrantWriteACP=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the ACL for a bucket.

Bucket (str):

The name of the S3 bucket to update the ACL for.

ACL (str, optional):

The canned ACL to apply to the bucket.

AccessControlPolicy (dict, optional):

The access control policy to apply to the bucket.

GrantFullControl (str, optional):

Allows grantee full control over the bucket.

GrantRead (str, optional):

Allows grantee to read the bucket.

GrantReadACP (str, optional):

Allows grantee to read the bucket’s ACL.

GrantWrite (str, optional):

Allows grantee to write to the bucket.

GrantWriteACP (str, optional):

Allows grantee to write the bucket’s ACL.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_acl my_bucket 'public' \
                 GrantFullControl='emailaddress=example@example.com' \
                 GrantRead='uri="http://acs.amazonaws.com/groups/global/AllUsers"' \
                 GrantReadACP='emailaddress="exampl@example.com",id="2345678909876432"'
saltext.boto3.modules.boto3_s3_bucket.put_cors(Bucket, CORSRules, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the CORS rules for a bucket.

Bucket (str):

The name of the S3 bucket to update the CORS rules for.

CORSRules (list):

A list of CORS rules to apply to the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_cors my_bucket '[{\
      "AllowedHeaders":[],\
      "AllowedMethods":["GET"],\
      "AllowedOrigins":["*"],\
      "ExposeHeaders":[],\
      "MaxAgeSeconds":123,\
}]'
saltext.boto3.modules.boto3_s3_bucket.put_lifecycle_configuration(Bucket, Rules, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the Lifecycle rules for a bucket.

Bucket (str):

The name of the S3 bucket to update the Lifecycle rules for.

Rules (list):

A list of Lifecycle rules to apply to the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_lifecycle_configuration my_bucket '[{\
      "Expiration": {...},\
      "ID": "idstring",\
      "Prefix": "prefixstring",\
      "Status": "enabled",\
      "Transitions": [{...},],\
      "NoncurrentVersionTransitions": [{...},],\
      "NoncurrentVersionExpiration": {...},\
}]'
saltext.boto3.modules.boto3_s3_bucket.put_logging(Bucket, TargetBucket=None, TargetPrefix=None, TargetGrants=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the logging parameters for a bucket.

Bucket (str):

The name of the S3 bucket to update the logging parameters for.

TargetBucket (str, optional):

The name of the S3 bucket where logs should be delivered.

TargetPrefix (str, optional):

The prefix for the log object keys.

TargetGrants (list, optional):

A list of grants for the target bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_logging my_bucket log_bucket '[{...}]' prefix
saltext.boto3.modules.boto3_s3_bucket.put_notification_configuration(Bucket, TopicConfigurations=None, QueueConfigurations=None, LambdaFunctionConfigurations=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the notification parameters for a bucket.

Bucket (str):

The name of the S3 bucket to update the notification parameters for.

TopicConfigurations (list, optional):

A list of topic configurations for the bucket.

QueueConfigurations (list, optional):

A list of queue configurations for the bucket.

LambdaFunctionConfigurations (list, optional):

A list of Lambda function configurations for the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_notification_configuration my_bucket
        [{...}] \
        [{...}] \
        [{...}]
saltext.boto3.modules.boto3_s3_bucket.put_policy(Bucket, Policy, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the policy for a bucket.

Bucket (str):

The name of the S3 bucket to update the policy for.

Policy (str):

The policy to apply to the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_policy my_bucket {...}
saltext.boto3.modules.boto3_s3_bucket.put_replication(Bucket, Role, Rules, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the replication configuration for a bucket.

Bucket (str):

The name of the S3 bucket to update the replication configuration for.

Role (str):

The IAM role ARN to use for the replication configuration.

Rules (list):

A list of replication rules to apply to the bucket.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_replication my_bucket my_role [...]
saltext.boto3.modules.boto3_s3_bucket.put_request_payment(Bucket, Payer, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the request payment configuration for a bucket.

Bucket (str):

The name of the S3 bucket to update the request payment configuration for.

Payer (str):

The payer for the request payment configuration. Valid values are “BucketOwner” and “Requester”.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_request_payment my_bucket Requester
saltext.boto3.modules.boto3_s3_bucket.put_tagging(Bucket, region=None, key=None, keyid=None, profile=None, **kwargs)[source]

Given a valid config, update the tags for a bucket.

Bucket (str):

The name of the S3 bucket to update the tags for.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

**kwargs:

The tags to apply to the bucket as key-value pairs.

CLI Example:

salt myminion boto3_s3_bucket.put_tagging my_bucket my_role [...]
saltext.boto3.modules.boto3_s3_bucket.put_versioning(Bucket, Status, MFADelete=None, MFA=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the versioning configuration for a bucket.

Bucket (str):

The name of the S3 bucket to update the versioning configuration for.

Status (str):

The versioning status to apply to the bucket. Valid values are “Enabled” and “Suspended”.

MFADelete (str, optional):

The MFA delete status to apply to the bucket. Valid values are “Enabled” and “Disabled”.

MFA (str, optional):

The MFA authentication code to use when updating the versioning configuration.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_versioning my_bucket Enabled
saltext.boto3.modules.boto3_s3_bucket.put_website(Bucket, ErrorDocument=None, IndexDocument=None, RedirectAllRequestsTo=None, RoutingRules=None, region=None, key=None, keyid=None, profile=None)[source]

Given a valid config, update the website configuration for a bucket.

Bucket (str):

The name of the S3 bucket to update the website configuration for.

ErrorDocument (dict, optional):

The error document configuration for the website.

IndexDocument (dict, optional):

The index document configuration for the website.

RedirectAllRequestsTo (dict, optional):

The redirect all requests to configuration for the website.

RoutingRules (list, optional):

The routing rules configuration for the website.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.put_website my_bucket IndexDocument='{"Suffix":"index.html"}'
saltext.boto3.modules.boto3_s3_bucket.delete_cors(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Delete the CORS configuration for the given bucket.

Bucket (str):

The name of the S3 bucket to delete the CORS configuration for.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_cors my_bucket
saltext.boto3.modules.boto3_s3_bucket.delete_lifecycle_configuration(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Delete the lifecycle configuration for the given bucket.

Bucket (str):

The name of the S3 bucket to delete the lifecycle configuration for.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_lifecycle_configuration my_bucket
saltext.boto3.modules.boto3_s3_bucket.delete_policy(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Delete the policy from the given bucket.

Bucket (str):

The name of the S3 bucket to delete the policy from.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_policy my_bucket
saltext.boto3.modules.boto3_s3_bucket.delete_replication(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Delete the replication config from the given bucket.

Bucket (str):

The name of the S3 bucket to delete the replication config from.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_replication my_bucket
saltext.boto3.modules.boto3_s3_bucket.delete_tagging(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Delete the tags from the given bucket.

Bucket (str):

The name of the S3 bucket to delete the tags from.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_tagging my_bucket
saltext.boto3.modules.boto3_s3_bucket.delete_website(Bucket, region=None, key=None, keyid=None, profile=None)[source]

Remove the website configuration from the given bucket.

Bucket (str):

The name of the S3 bucket to remove the website configuration from.

region (str, optional):

The AWS region to use.

key (str, optional):

The AWS access key to use.

keyid (str, optional):

The AWS secret key to use.

profile (str, optional):

The AWS profile to use.

CLI Example:

salt myminion boto3_s3_bucket.delete_website my_bucket