Skip to content
v2.278.0

OriginGroup ​

Class Stable

An Origin that represents a group.

Consists of a primary Origin, and a fallback Origin called when the primary returns one of the provided HTTP status codes.

Example ​

ts
const myBucket = new s3.Bucket(this, 'myBucket');
new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: {
    origin: new origins.OriginGroup({
      primaryOrigin: origins.S3BucketOrigin.withOriginAccessControl(myBucket),
      fallbackOrigin: new origins.HttpOrigin('www.example.com'),
      // optional, defaults to: 500, 502, 503 and 504
      fallbackStatusCodes: [404],
    }),
  },
});
python
my_bucket = s3.Bucket(self, "myBucket")
cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(
        origin=origins.OriginGroup(
            primary_origin=origins.S3BucketOrigin.with_origin_access_control(my_bucket),
            fallback_origin=origins.HttpOrigin("www.example.com"),
            # optional, defaults to: 500, 502, 503 and 504
            fallback_status_codes=[404]
        )
    )
)
java
Bucket myBucket = new Bucket(this, "myBucket");
Distribution.Builder.create(this, "myDist")
        .defaultBehavior(BehaviorOptions.builder()
                .origin(OriginGroup.Builder.create()
                        .primaryOrigin(S3BucketOrigin.withOriginAccessControl(myBucket))
                        .fallbackOrigin(new HttpOrigin("www.example.com"))
                        // optional, defaults to: 500, 502, 503 and 504
                        .fallbackStatusCodes(List.of(404))
                        .build())
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var myBucket = new Bucket(this, "myBucket");
new Distribution(this, "myDist", new DistributionProps {
    DefaultBehavior = new BehaviorOptions {
        Origin = new OriginGroup(new OriginGroupProps {
            PrimaryOrigin = S3BucketOrigin.WithOriginAccessControl(myBucket),
            FallbackOrigin = new HttpOrigin("www.example.com"),
            // optional, defaults to: 500, 502, 503 and 504
            FallbackStatusCodes = new [] { 404 }
        })
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
myBucket := s3.NewBucket(this, jsii.String("myBucket"))
cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.NewOriginGroup(&OriginGroupProps{
			PrimaryOrigin: origins.S3BucketOrigin_WithOriginAccessControl(myBucket),
			FallbackOrigin: origins.NewHttpOrigin(jsii.String("www.example.com")),
			// optional, defaults to: 500, 502, 503 and 504
			FallbackStatusCodes: []*f64{
				jsii.Number(404),
			},
		}),
	},
})

Initializer ​

ts
new OriginGroup(props: OriginGroupProps)
python
OriginGroup(props: OriginGroupProps)
java
new OriginGroup(OriginGroupProps props)
csharp
new OriginGroup(OriginGroupProps props)
go
NewOriginGroup(Props OriginGroupProps)

Methods ​

bind(scope: Construct, options: OriginBindOptions): OriginBindConfigdef bind(self, scope: Construct, options: OriginBindOptions) -> OriginBindConfigpublic OriginBindConfig bind(Construct scope, OriginBindOptions options)public OriginBindConfig Bind(Construct scope, OriginBindOptions options)func Bind(Scope Construct, Options OriginBindOptions) OriginBindConfig #
The method called when a given Origin is added (for the first time) to a Distribution.