aws-cdk-lib.aws_s3.CorsRule

interface CorsRule

LanguageType name
.NETAmazon.CDK.AWS.S3.CorsRule
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awss3#CorsRule
Javasoftware.amazon.awscdk.services.s3.CorsRule
Pythonaws_cdk.aws_s3.CorsRule
TypeScript (source)aws-cdk-lib » aws_s3 » CorsRule

Specifies a cross-origin access rule for an Amazon S3 bucket.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const corsRule: s3.CorsRule = {
  allowedMethods: [s3.HttpMethods.GET],
  allowedOrigins: ['allowedOrigins'],

  // the properties below are optional
  allowedHeaders: ['allowedHeaders'],
  exposedHeaders: ['exposedHeaders'],
  id: 'id',
  maxAge: 123,
};

Properties

NameTypeDescription
allowedMethodsHttpMethods[]An HTTP method that you allow the origin to execute.
allowedOriginsstring[]One or more origins you want customers to be able to access the bucket from.
allowedHeaders?string[]Headers that are specified in the Access-Control-Request-Headers header.
exposedHeaders?string[]One or more headers in the response that you want customers to be able to access from their applications.
id?stringA unique identifier for this rule.
maxAge?numberThe time in seconds that your browser is to cache the preflight response for the specified resource.

allowedMethods

Type: HttpMethods[]

An HTTP method that you allow the origin to execute.


allowedOrigins

Type: string[]

One or more origins you want customers to be able to access the bucket from.


allowedHeaders?

Type: string[] (optional, default: No headers allowed.)

Headers that are specified in the Access-Control-Request-Headers header.


exposedHeaders?

Type: string[] (optional, default: No headers exposed.)

One or more headers in the response that you want customers to be able to access from their applications.


id?

Type: string (optional, default: No id specified.)

A unique identifier for this rule.


maxAge?

Type: number (optional, default: No caching.)

The time in seconds that your browser is to cache the preflight response for the specified resource.