(cloudfront-origins): add ownerAccountId support for cross-account VPC origins
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Add support for the `ownerAccountId` property in the `VpcOrigin` origin class to enable cross-account VPC origin configurations.
The implementation includes
- A new `ownerAccountId` optional property on `VpcOriginProps`
- Validation that the value is a 12-digit AWS account ID (when not a token)
- README documentation with a usage example
### Use Case
In multi-account architectures, VPC origin resources often reside in a different account from the CloudFront distribution. Without this property, users must use escape hatches to set `OwnerAccountId`.
The following example shows how this feature would simplify cross-account VPC origin configuration with the proposed `ownerAccountId` property:
```ts
// Use a VPC origin from a different AWS account
const vpcOrigin = cloudfront.VpcOrigin.fromVpcOriginId(this, 'CrossAccountVpcOrigin', 'vo-1234567890abcdef0');
new cloudfront.Distribution(this, 'myDist', {
defaultBehavior: {
origin: origins.VpcOrigin.withVpcOrigin(vpcOrigin, {
domainName: 'vpcorigin.example.com',
ownerAccountId: '111122223333',
}),
},
});
```
### Proposed Solution
The implementation adds `ownerAccountId` as an optional string property to VpcOriginProps, validates it as a 12-digit account ID, and passes it through to `renderVpcOriginConfig()`. A README section with a cross-account usage example is also included.
**Note**
* Integration testing for this feature requires two separate AWS accounts with AWS RAM sharing configured between them, which makes it challenging to set up. Any guidance on how the team typically handles cross-account testing scenarios would be appreciated.
* This is a minor addition and the PR is created as a Draft. If there is demand for this feature, I'd be happy to continue contributing and get it merged. Otherwise, feel free to close it.
### Other Information
* AWS announcement: [Amazon CloudFront announces cross-account support for VPC origins](https://aws.amazon.com/about-aws/whats-new/2025/11/amazon-cloudfront-cross-account-vpc-origins/)
### Acknowledgements
- [x] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### AWS CDK Library version (aws-cdk-lib)
2.x
### AWS CDK CLI version
2.x
### Environment details (OS name and version, etc.)
all
Contributor guide
Research direction
Locate VpcOriginProps and renderVpcOriginConfig(), then review the existing VpcOrigin implementation and its validation patterns. Confirm the ownerAccountId value is optional, accepts tokens or 12-digit account IDs, reaches the rendered configuration, and that the README contains the cross-account usage example; integration testing would require two AWS accounts with RAM sharing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100