Skip to content

@aws-cdk/cloudfront: OriginAccessIdentity mixes up id and name #20141

@dbartholomae

Description

@dbartholomae

Describe the bug

OriginAccessIdentity.fromOriginAccessIdentityName asks for the OAI name, but actually needs the OAI id.

Set up the following bucket with a Cloudfront OAI name from a different account:

const bucket = new Bucket(this, "Bucket");
const originAccessIdentity =
  OriginAccessIdentity.fromOriginAccessIdentityName(
    this,
    "OriginAccessIdentity",
    "<add-OAI-name-here>"
  );

bucket.grantRead(originAccessIdentity);

Then deploy.

Expected Behavior

The deployment should work.

Current Behavior

The deployment fails because what is needed is actually the OAI id, not the OAI name. This makes OriginAccessIdentity.fromOriginAccessIdentityName quite a misnomer.

Reproduction Steps

See above.

Possible Solution

Rename the method and internal properties to OriginAccessIdentity.fromOriginAccessIdentityId.

Additional Information/Context

Not sure if this bug is CDK-specific or a general CloudFormation problem.

CDK CLI Version

2.20.0

Framework Version

No response

Node.js Version

16

OS

Windows 11

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cloudfrontRelated to Amazon CloudFrontbugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions