aws / aws/aws-cdk

aws-cloudfront: unable to set origin group as default behavior origin

Open
#31,016 9 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-cloudfront bug effort/small p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
1d 19h
Merged PRs (30d)
74

Description

### Describe the bug

When deploying a CloudFront distribution with an origin group as default behavior origin, you get the following CloudFormation error:
**_Resource handler returned message: "Invalid request provided: Exactly one of CustomOriginConfig and S3OriginConfig must be specified"_**

When setting the origin group as default behavior origin in the AWS Console everything works.

### Expected Behavior

Set the origin group as the origin in the default behavior of the cloudfront distribution.

### Current Behavior

An error occurs when the CloudFormation stack gets deployed:

**_Resource handler returned message: "Invalid request provided: Exactly one of CustomOriginConfig and S3OriginConfig must be specified"_**

### Reproduction Steps

Here a sample setup:
```
const cloudfrontDistribution = new cloudfront.Distribution(this, 'CloudFrontDistribution', {
comment: 'Test CloudFront Distribution',
httpVersion: cloudfront.HttpVersion.HTTP2_AND_3,
enableIpv6: true,
certificate: certificate,
domainNames: [domainName],
defaultRootObject: 'index.html',
defaultBehavior: {
origin: myOriginGroup,
},
});
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.151.0 (build b8289e2)

### Framework Version

_No response_

### Node.js Version

v20.16.0

### OS

macos

### Language

TypeScript

### Language Version

Typescript 5.5.4

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the cloudfront.Distribution entry point and trace how defaultBehavior.origin is represented in the synthesized CloudFormation template. Reproduce the deployment with the provided TypeScript example and inspect the generated default behavior and origin fields. Done means an origin group can be used as the default behavior origin without the CustomOriginConfig/S3OriginConfig error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.