You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::S3::BucketPolicy

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(bucket_name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(bucket_name, options = {}) ⇒ Object

    Parameters:

    • bucket_name (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :bucket_name (required, String)
    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#bucket_nameString (readonly)

Returns:

  • (String)

#policyString (readonly)

The bucket policy as a JSON document.

Returns:

  • (String)

    The bucket policy as a JSON document.

Instance Method Details

#bucketBucket

Returns:

#delete(options = {}) ⇒ Struct

This implementation of the DELETE operation uses the policy subresource to delete the policy of a specified bucket. If you are using an identity other than the root user of the AWS account that owns the bucket, the calling identity must have the DeleteBucketPolicy permissions on the specified bucket and belong to the bucket owner's account to use this operation.

If you don't have DeleteBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a 405 Method Not Allowed error.

As a security precaution, the root user of the AWS account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.

For more information about bucket policies, see Using Bucket Policies and UserPolicies.

The following operations are related to DeleteBucketPolicy

Examples:

Request syntax example with placeholder values


bucketpolicy.delete({
  expected_bucket_owner: "AccountId",
  use_accelerate_endpoint: false,
})

Options Hash (options):

  • :expected_bucket_owner (String)

    The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

  • :use_accelerate_endpoint (Boolean)

    When true, the "https://BUCKETNAME.s3-accelerate.amazonaws.com" endpoint will be used.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#put(options = {}) ⇒ Struct

Applies an Amazon S3 bucket policy to an Amazon S3 bucket. If you are using an identity other than the root user of the AWS account that owns the bucket, the calling identity must have the PutBucketPolicy permissions on the specified bucket and belong to the bucket owner's account in order to use this operation.

If you don't have PutBucketPolicy permissions, Amazon S3 returns a 403 Access Denied error. If you have the correct permissions, but you're not using an identity that belongs to the bucket owner's account, Amazon S3 returns a 405 Method Not Allowed error.

As a security precaution, the root user of the AWS account that owns a bucket can always use this operation, even if the policy explicitly denies the root user the ability to perform this action.

For more information about bucket policies, see Using Bucket Policies and User Policies.

The following operations are related to PutBucketPolicy:

Examples:

Request syntax example with placeholder values


bucketpolicy.put({
  content_md5: "ContentMD5",
  confirm_remove_self_bucket_access: false,
  policy: "Policy", # required
  expected_bucket_owner: "AccountId",
  use_accelerate_endpoint: false,
})

Options Hash (options):

  • :content_md5 (String)

    The MD5 hash of the request body.

    For requests made using the AWS Command Line Interface (CLI) or AWS SDKs, this field is calculated automatically.

  • :confirm_remove_self_bucket_access (Boolean)

    Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

  • :policy (required, String)

    The bucket policy as a JSON document.

  • :expected_bucket_owner (String)

    The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

  • :use_accelerate_endpoint (Boolean)

    When true, the "https://BUCKETNAME.s3-accelerate.amazonaws.com" endpoint will be used.

Returns:

  • (Struct)

    Returns an empty response.

See Also: