Skip to content

Commit

Permalink
fix(type-safe-api): replace stack partition/region by bucket ones to …
Browse files Browse the repository at this point in the history
…construct bucket invocation URI
  • Loading branch information
valebedu committed Oct 6, 2023
1 parent c4264e0 commit f220e85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 1 addition & 5 deletions packages/type-safe-api/src/construct/integrations/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ export class S3Integration extends Integration {
return {
type: "AWS",
httpMethod: props.method.toUpperCase(),
uri: bucketInvocationUri(
props.scope,
this.bucket,
this.pathOverride ?? props.path
),
uri: bucketInvocationUri(this.bucket, this.pathOverride ?? props.path),
credentials: this.role.roleArn,
responses: {
default: {
Expand Down
12 changes: 4 additions & 8 deletions packages/type-safe-api/src/construct/spec/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@ export const functionInvocationUri = (

/**
* Generate the s3 bucket invocation uri for the given s3 within the given scope
* @param scope scope in which the s3 is deployed
* @param bucket the s3 bucket to be invoked
* @param path? the path to object to invoke, default to none
*/
export const bucketInvocationUri = (
scope: Construct,
bucket: IBucket,
pathOverride?: string
): string => {
const stack = Stack.of(scope);
export const bucketInvocationUri = (bucket: IBucket, path?: string): string => {
const stack = bucket.stack;
return `arn:${stack.partition}:apigateway:${stack.region}:s3:path/${
bucket.bucketName
}/${pathOverride ?? ""}`;
}/${path ?? ""}`;
};

0 comments on commit f220e85

Please sign in to comment.