libZSservicesZSamazonka-s3ZSamazonka-s3
Copyright(c) 2013-2021 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityauto-generated
Portabilitynon-portable (GHC extensions)
Safe HaskellNone

Amazonka.S3.PutBucketCors

Description

Sets the cors configuration for your bucket. If the configuration exists, Amazon S3 replaces it.

To use this operation, you must be allowed to perform the s3:PutBucketCORS action. By default, the bucket owner has this permission and can grant it to others.

You set this configuration on a bucket so that the bucket can service cross-origin requests. For example, you might want to enable a request whose origin is http://www.example.com to access your Amazon S3 bucket at my.example.bucket.com by using the browser's XMLHttpRequest capability.

To enable cross-origin resource sharing (CORS) on a bucket, you add the cors subresource to the bucket. The cors subresource is an XML document in which you configure rules that identify origins and the HTTP methods that can be executed on your bucket. The document is limited to 64 KB in size.

When Amazon S3 receives a cross-origin request (or a pre-flight OPTIONS request) against a bucket, it evaluates the cors configuration on the bucket and uses the first CORSRule rule that matches the incoming browser request to enable a cross-origin request. For a rule to match, the following conditions must be met:

  • The request's Origin header must match AllowedOrigin elements.
  • The request method (for example, GET, PUT, HEAD, and so on) or the Access-Control-Request-Method header in case of a pre-flight OPTIONS request must be one of the AllowedMethod elements.
  • Every header specified in the Access-Control-Request-Headers request header of a pre-flight request must match an AllowedHeader element.

For more information about CORS, go to Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide.

Related Resources

Synopsis

Creating a Request

data PutBucketCors Source #

See: newPutBucketCors smart constructor.

Constructors

PutBucketCors' 

Fields

  • contentMD5 :: Maybe Text

    The base64-encoded 128-bit MD5 digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to RFC 1864.

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

  • expectedBucketOwner :: Maybe Text

    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.

  • bucket :: BucketName

    Specifies the bucket impacted by the corsconfiguration.

  • cORSConfiguration :: CORSConfiguration

    Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide.

Instances

Instances details
Eq PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Read PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Show PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Generic PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Associated Types

type Rep PutBucketCors :: Type -> Type #

NFData PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Methods

rnf :: PutBucketCors -> () #

Hashable PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

AWSRequest PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Associated Types

type AWSResponse PutBucketCors #

ToHeaders PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

ToPath PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

ToQuery PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

ToElement PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

type Rep PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

type Rep PutBucketCors = D1 ('MetaData "PutBucketCors" "Amazonka.S3.PutBucketCors" "libZSservicesZSamazonka-s3ZSamazonka-s3" 'False) (C1 ('MetaCons "PutBucketCors'" 'PrefixI 'True) ((S1 ('MetaSel ('Just "contentMD5") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "expectedBucketOwner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Text))) :*: (S1 ('MetaSel ('Just "bucket") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 BucketName) :*: S1 ('MetaSel ('Just "cORSConfiguration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 CORSConfiguration))))
type AWSResponse PutBucketCors Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

newPutBucketCors Source #

Create a value of PutBucketCors with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.

The following record fields are available, with the corresponding lenses provided for backwards compatibility:

$sel:contentMD5:PutBucketCors', putBucketCors_contentMD5 - The base64-encoded 128-bit MD5 digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to RFC 1864.

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

$sel:expectedBucketOwner:PutBucketCors', putBucketCors_expectedBucketOwner - 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.

$sel:bucket:PutBucketCors', putBucketCors_bucket - Specifies the bucket impacted by the corsconfiguration.

$sel:cORSConfiguration:PutBucketCors', putBucketCors_cORSConfiguration - Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide.

Request Lenses

putBucketCors_contentMD5 :: Lens' PutBucketCors (Maybe Text) Source #

The base64-encoded 128-bit MD5 digest of the data. This header must be used as a message integrity check to verify that the request body was not corrupted in transit. For more information, go to RFC 1864.

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

putBucketCors_expectedBucketOwner :: Lens' PutBucketCors (Maybe Text) Source #

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.

putBucketCors_bucket :: Lens' PutBucketCors BucketName Source #

Specifies the bucket impacted by the corsconfiguration.

putBucketCors_cORSConfiguration :: Lens' PutBucketCors CORSConfiguration Source #

Describes the cross-origin access configuration for objects in an Amazon S3 bucket. For more information, see Enabling Cross-Origin Resource Sharing in the Amazon S3 User Guide.

Destructuring the Response

data PutBucketCorsResponse Source #

See: newPutBucketCorsResponse smart constructor.

Instances

Instances details
Eq PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Read PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Show PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Generic PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Associated Types

type Rep PutBucketCorsResponse :: Type -> Type #

NFData PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

Methods

rnf :: PutBucketCorsResponse -> () #

type Rep PutBucketCorsResponse Source # 
Instance details

Defined in Amazonka.S3.PutBucketCors

type Rep PutBucketCorsResponse = D1 ('MetaData "PutBucketCorsResponse" "Amazonka.S3.PutBucketCors" "libZSservicesZSamazonka-s3ZSamazonka-s3" 'False) (C1 ('MetaCons "PutBucketCorsResponse'" 'PrefixI 'False) (U1 :: Type -> Type))

newPutBucketCorsResponse :: PutBucketCorsResponse Source #

Create a value of PutBucketCorsResponse with all optional fields omitted.

Use generic-lens or optics to modify other optional fields.