Skip to content

[cloudfront] OriginGroup doesn't register correctly as DefaultCacheBehavior target. #9561

Closed
@LarsFronius

Description

@LarsFronius

When I create a Distribution with a defaultBehavior origin that points to a OriginGroup, the outcoming templates target ID points to the primaryOrigin of that OriginGroup instead of to the OriginGroup itself.

Reproduction Steps

   const originGroup = new OriginGroup({
      primaryOrigin: new S3Origin(someBucket, {originPath: "/"}),
      fallbackOrigin: new HttpOrigin(`${api.restApiId}.execute-api.${this.region}.amazonaws.com`, {originPath: `/${api.deploymentStage.stageName}/thumbnail`}),
      fallbackStatusCodes: [404]}
    )
    const cdn = new Distribution(this, 'cdn', {
      defaultBehavior: {
        origin: originGroup
      },
    })

This (and many other configurations) create a Distribution with the primary origins target ID registered as default target, rather than the origin group.

What did you expect to happen?

I expected that the originGroup would be targeted by default.

Environment

  • **CLI Version : ** 1.57.0
  • **Framework Version: ** 1.57.0
  • Node.js Version: v14.7.0
  • OS : macOS 10.15.5
  • Language (Version): Typescript 3.7.2

Other

The issue was introduced as part of the original implementation of OriginGroups: #9360

I have a fix ready at master...LarsFronius:default-behaviour-origin-groups - let me know if this looks as expected and I'll create the PR.

/cc ing @skinny85 : Since you created the original implementation and have the most context, perhaps you are the best to give this a review. Thank you!


This is 🐛 Bug Report

Activity

added
bugThis issue is a bug.
needs-triageThis issue or PR still needs to be triaged.
on Aug 10, 2020
skinny85

skinny85 commented on Aug 11, 2020

@skinny85
Contributor

@iliapolo I can take this one, since I was the one who implemented OriginGroups originally.

iliapolo

iliapolo commented on Aug 11, 2020

@iliapolo
Contributor

@skinny85 go for it 😃

removed
needs-triageThis issue or PR still needs to be triaged.
on Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-cloudfrontRelated to Amazon CloudFrontbugThis issue is a bug.in-progressThis issue is being actively worked on.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @skinny85@LarsFronius@iliapolo@SomayaB

    Issue actions

      [cloudfront] OriginGroup doesn't register correctly as DefaultCacheBehavior target. · Issue #9561 · aws/aws-cdk