Skip to content

ARN Parser Util Package's Build Method Generates Invalid ARN for S3 Resources #7621

@wpark95

Description

@wpark95

Checkboxes for prior research

Describe the bug

It seems that S3 resource ARNs are formatted differently from those of most other AWS resources, as account ID and region are omitted in S3 resource ARNs.

However, the current build method in the ARN parser util package seems to not distinguish S3 resources from other resources when generating ARNs.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/util-arn-parser@3.723.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v18.20.2

Reproduction Steps

import { build, parse } from "@aws-sdk/util-arn-parser";

function generateArn() {
  return build({
    partition: "aws",
    accountId: "123456789012",
    region: "us-east-1",
    service: "s3",
    resource: "a-bucket",
  });
}

console.log(generateArn()); // arn:aws:s3:us-east-1:123456789012:a-bucket - I believe this is incorrect as the region and account ID should be omitted, like arn:aws:s3:::a-bucket .

Observed Behavior

For S3 resources, the build method generates incorrect ARNs that include region and account ID.

Expected Behavior

For S3 resources, the build method should generate ARNs that do not include region and account ID.

Possible Solution

Omit region and account ID in if service is s3 in the relevant code.

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.p2This is a standard priority issuequeuedThis issues is on the AWS team's backlogresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions