CorsRule
Struct Stable
Specifies a cross-origin access rule for an Amazon S3 bucket.
| Source | aws-s3/lib/bucket.ts |
|---|
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,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3
cors_rule = s3.CorsRule(
allowed_methods=[s3.HttpMethods.GET],
allowed_origins=["allowedOrigins"],
# the properties below are optional
allowed_headers=["allowedHeaders"],
exposed_headers=["exposedHeaders"],
id="id",
max_age=123
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.s3.*;
CorsRule corsRule = CorsRule.builder()
.allowedMethods(List.of(HttpMethods.GET))
.allowedOrigins(List.of("allowedOrigins"))
// the properties below are optional
.allowedHeaders(List.of("allowedHeaders"))
.exposedHeaders(List.of("exposedHeaders"))
.id("id")
.maxAge(123)
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.S3;
var corsRule = new CorsRule {
AllowedMethods = new [] { HttpMethods.GET },
AllowedOrigins = new [] { "allowedOrigins" },
// the properties below are optional
AllowedHeaders = new [] { "allowedHeaders" },
ExposedHeaders = new [] { "exposedHeaders" },
Id = "id",
MaxAge = 123
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
corsRule := &CorsRule{
AllowedMethods: []HttpMethods{
awscdk.Aws_s3.HttpMethods_GET,
},
AllowedOrigins: []*string{
jsii.String("allowedOrigins"),
},
// the properties below are optional
AllowedHeaders: []*string{
jsii.String("allowedHeaders"),
},
ExposedHeaders: []*string{
jsii.String("exposedHeaders"),
},
Id: jsii.String("id"),
MaxAge: jsii.Number(123),
}
Properties
allowedHeadersoptionalstring[]allowed_headersoptionaltyping.List[str]allowedHeadersoptionalList<String>AllowedHeadersoptionalstring[]AllowedHeadersoptional*[]*string #Headers that are specified in the Access-Control-Request-Headers header.
Default: No headers allowed.
allowedMethodsHttpMethods[]allowed_methodstyping.List[HttpMethods]allowedMethodsList<HttpMethods>AllowedMethodsHttpMethods[]AllowedMethods*[]HttpMethods required #An HTTP method that you allow the origin to execute.
allowedOriginsstring[]allowed_originstyping.List[str]allowedOriginsList<String>AllowedOriginsstring[]AllowedOrigins*[]*string required #One or more origins you want customers to be able to access the bucket from.
exposedHeadersoptionalstring[]exposed_headersoptionaltyping.List[str]exposedHeadersoptionalList<String>ExposedHeadersoptionalstring[]ExposedHeadersoptional*[]*string #One or more headers in the response that you want customers to be able to access from their applications.
Default: No headers exposed.
A unique identifier for this rule.
Default: No id specified.
maxAgeoptionalnumbermax_ageoptionalint | floatmaxAgeoptionalNumberMaxAgeoptionaldoubleMaxAgeoptional*float64 #The time in seconds that your browser is to cache the preflight response for the specified resource.
Default: No caching.