Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(cloudfront): Cannot set Origin Access Control on Object Lambda Access Point origin #26405

Closed
joseph-m-smith opened this issue Jul 18, 2023 · 2 comments
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@joseph-m-smith
Copy link

Describe the bug

I have a CloudFront distribution with an Object Lambda Access Point (OLAP) origin to serve S3 objects. The distribution construct uses an HttpOrigin with the OLAP's domain name (from its alias). Origin Access Control is set up using CfnOriginAccessControl. The origin access control ID is set on the underlying CfnDistribution. Attempting to deploy results in an CloudFront API 400 response. But I can set origin access control on the origin via the AWS console and the origin's type is S3 in the console.

Expected Behavior

The origin access control policy is applied to the distribution's default origin.

Current Behavior

The stack named [redacted] failed to deploy: UPDATE_ROLLBACK_COMPLETE: Resource handler returned message: "Invalid request provided: Illegal configuration: The origin type and OAC origin type differ. (Service: CloudFront, Status Code: 400, Request ID: [redacted])" (RequestToken: [redacted], HandlerErrorCode: InvalidRequest)

Reproduction Steps

    const distribution = new Distribution(scope, id, {
      defaultBehavior: {
       // accessPoint is a custom construct with the OLAP and supporting access point
        origin: new HttpOrigin(accessPoint.accessPointDomainName),
      },
    });

    const originAccessControl = new CfnOriginAccessControl(
      scope,
      'OriginAccessControl',
      {
        originAccessControlConfig: {
          name: 'originAccessControlPolicy',
          originAccessControlOriginType: 's3',
          signingBehavior: 'always',
          signingProtocol: 'sigv4',
        },
      },
    );

    (distribution.node.defaultChild as CfnDistribution).addPropertyOverride(
      'DistributionConfig.Origins.0.OriginAccessControlId',
      originAccessControl.getAtt('Id'),
    );

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.86.0

Framework Version

No response

Node.js Version

18.14.0

OS

linux

Language

Typescript

Language Version

No response

Other information

No response

@joseph-m-smith joseph-m-smith added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 18, 2023
@github-actions github-actions bot added the @aws-cdk/aws-cloudfront Related to Amazon CloudFront label Jul 18, 2023
@joseph-m-smith
Copy link
Author

This appears to be related to the CloudFront API. I discovered using an origin with an empty S3 origin configuration works.

class CustomOrigin extends OriginBase {
  public constructor(domainName: string, props: OriginProps = {}) {
    super(domainName, props);
  }

  protected renderS3OriginConfig(): CfnDistribution.S3OriginConfigProperty {
    return {};
  }
}

I'm closing the issue as no further work is needed.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-cloudfront Related to Amazon CloudFront bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant