Skip to content
v2.274.0

CorsRule Struct ​

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

Example ​

ts
// 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 ​

allowedHeadersstring[]allowed_headerstyping.List[str]allowedHeadersList<String>AllowedHeadersstring[]AllowedHeaders*[]*string= No headers allowed.#
Headers that are specified in the Access-Control-Request-Headers header.
allowedMethodsHttpMethods[]allowed_methodstyping.List[HttpMethods]allowedMethodsList<HttpMethods>AllowedMethodsHttpMethods[]AllowedMethods*[]HttpMethodsrequired#
An HTTP method that you allow the origin to execute.
allowedOriginsstring[]allowed_originstyping.List[str]allowedOriginsList<String>AllowedOriginsstring[]AllowedOrigins*[]*stringrequired#
One or more origins you want customers to be able to access the bucket from.
exposedHeadersstring[]exposed_headerstyping.List[str]exposedHeadersList<String>ExposedHeadersstring[]ExposedHeaders*[]*string= No headers exposed.#
One or more headers in the response that you want customers to be able to access from their applications.
idstringidstridStringIdstringId*string= No id specified.#
A unique identifier for this rule.
maxAgenumbermax_ageint | floatmaxAgeNumberMaxAgedoubleMaxAge*float64= No caching.#
The time in seconds that your browser is to cache the preflight response for the specified resource.