Skip to content

Commit

Permalink
Merge pull request #634 from circulon/feature/fix-use-with-localstack
Browse files Browse the repository at this point in the history
fix not working with localstack #396
  • Loading branch information
rddimon authored Jul 18, 2024
2 parents 0dd7645 + e0f283b commit 9756b83
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/aws/acm-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class ACMWrapper {
credentials,
region: isEdge ? Globals.defaultRegion : Globals.getRegion(),
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: Globals.getServiceEndpoint("acm")
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/aws/api-gateway-v1-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ import { getAWSPagedResults } from "../utils";
class APIGatewayV1Wrapper extends APIGatewayBase {
public readonly apiGateway: APIGatewayClient;


Check failure on line 30 in src/aws/api-gateway-v1-wrapper.ts

View workflow job for this annotation

GitHub Actions / Release and publish Node package

More than 1 blank line not allowed
constructor (credentials?: any) {
super();
this.apiGateway = new APIGatewayClient({
credentials,
region: Globals.getRegion(),
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: Globals.getServiceEndpoint("apigateway")
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/aws/api-gateway-v2-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class APIGatewayV2Wrapper extends APIGatewayBase {
credentials,
region: Globals.getRegion(),
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: Globals.getServiceEndpoint("apigatewayv2")
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/aws/cloud-formation-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class CloudFormationWrapper {
credentials,
region: Globals.getRegion(),
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: Globals.getServiceEndpoint("cloudformation")
});
}

Expand Down
9 changes: 6 additions & 3 deletions src/aws/route53-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ class Route53Wrapper {

constructor (credentials?: any, region?: string) {
// not null and not undefined
const serviceEndpoint = Globals.getServiceEndpoint("route53");
if (credentials) {
this.region = region || Globals.getRegion();
this.route53 = new Route53Client({
credentials,
region: this.region,
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: serviceEndpoint
});
} else {
this.region = Globals.getRegion();
this.route53 = new Route53Client({
region: this.region,
retryStrategy: Globals.getRetryStrategy(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: serviceEndpoint
});
}
}
Expand Down Expand Up @@ -59,7 +62,7 @@ class Route53Wrapper {
"NextMarker",
new ListHostedZonesCommand({})
);
Logging.logInfo(`Founded hosted zones list: ${hostedZones.map((zone) => zone.Name)}.`);
Logging.logInfo(`Found hosted zones list: ${hostedZones.map((zone) => zone.Name)}.`);
} catch (err) {
throw new Error(`Unable to list hosted zones in Route53.\n${err.message}`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/aws/s3-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class S3Wrapper {
this.s3 = new S3Client({
credentials,
region: Globals.getRegion(),
requestHandler: Globals.getRequestHandler()
requestHandler: Globals.getRequestHandler(),
endpoint: Globals.getServiceEndpoint("s3")
});
}

Expand Down
8 changes: 8 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ export default class Globals {
return Globals.options.stage || Globals.serverless.service.provider.stage;
}

public static getServiceEndpoint (service: string) {
if (Globals.serverless.providers.aws.sdk) {
const serviceConf = Globals.serverless.providers.aws.sdk.config[service];
return serviceConf.endpoint || null;
}
return null;
}

public static getRegion () {
const slsRegion = Globals.options.region || Globals.serverless.service.provider.region;
return slsRegion || Globals.currentRegion || Globals.defaultRegion;
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export interface ServerlessInstance {
};
providers: {
aws: {
getCredentials (),
getCredentials (): any,
sdk: any
},
};
cli: {
Expand Down

0 comments on commit 9756b83

Please sign in to comment.