Skip to content
v2.277.0

AllowedMethods Class ​

The HTTP methods that the Behavior will accept requests on.

Example ​

ts
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
declare const myBucket: s3.Bucket;
const myWebDistribution = new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: new origins.S3Origin(myBucket),
    allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
    viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
  },
});
python
# Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
# my_bucket: s3.Bucket

my_web_distribution = cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.S3Origin(my_bucket),
        allowed_methods=cloudfront.AllowedMethods.ALLOW_ALL,
        viewer_protocol_policy=cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS
    )
)
java
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;

Distribution myWebDistribution = Distribution.Builder.create(this, "myDist")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(new S3Origin(myBucket))
                .allowedMethods(AllowedMethods.ALLOW_ALL)
                .viewerProtocolPolicy(ViewerProtocolPolicy.REDIRECT_TO_HTTPS)
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
Bucket myBucket;

var myWebDistribution = new Distribution(this, "myDist", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = new S3Origin(myBucket),
        AllowedMethods = AllowedMethods.ALLOW_ALL,
        ViewerProtocolPolicy = ViewerProtocolPolicy.REDIRECT_TO_HTTPS
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Distribution with configured HTTP methods and viewer protocol policy of the cache.
var myBucket Bucket

myWebDistribution := cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.NewS3Origin(myBucket),
		AllowedMethods: cloudfront.AllowedMethods_ALLOW_ALL(),
		ViewerProtocolPolicy: cloudfront.ViewerProtocolPolicy_REDIRECT_TO_HTTPS,
	},
})

Properties ​

ALLOW_ALLAllowedMethodsALLOW_ALLAllowedMethodsALLOW_ALLAllowedMethodsALLOW_ALLAllowedMethodsALLOW_ALLAllowedMethods static #
All supported HTTP methods.
ALLOW_GET_HEADAllowedMethodsALLOW_GET_HEADAllowedMethodsALLOW_GET_HEADAllowedMethodsALLOW_GET_HEADAllowedMethodsALLOW_GET_HEADAllowedMethods static #
HEAD and GET.
ALLOW_GET_HEAD_OPTIONSAllowedMethodsALLOW_GET_HEAD_OPTIONSAllowedMethodsALLOW_GET_HEAD_OPTIONSAllowedMethodsALLOW_GET_HEAD_OPTIONSAllowedMethodsALLOW_GET_HEAD_OPTIONSAllowedMethods static #
HEAD, GET, and OPTIONS.
methodsstring[]methodstyping.List[str]methodsList<String>Methodsstring[]Methods*[]*string #
HTTP methods supported.