How do I resolve the "One or more of your origins or origin groups do not exist" error in AWS CloudFormation?
3 minute read
When I try to create or update an AWS CloudFormation stack that contains an Amazon CloudFront distribution, I get the following error:
"One or more of your origins or origin groups do not exist."
This error occurs when the TargetOriginId property of CacheBehavior or DefaultCacheBehavior doesn't match a CloudFront origin or origin group ID. This ID is a user-defined string that uniquely identifies an origin or origin group. You must define the origin group in the template, and manage your resources through CloudFormation.
Tip: It's a best practice to avoid making changes to stack resources outside of CloudFormation. This can create a mismatch between your stack's template and the current state of your stack resources. When you update or delete the stack, the mismatch can cause errors.
1. Confirm that the TargetOriginId matches the ID of one of the defined origins or origin groups. Enter the correct origin ID as a parameter for DefaultCacheBehavior or CacheBehavior.
In the following example JSON and YAML template snippets, DefaultCacheBehavior defines and consumes a CloudFront distribution with a single origin. Also, the origin uses an origin access identity (OAI) for authentication. In the examples, the origin ID is set to my-s3-origin.