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

fix not working with localstack #396 #634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 / test (16.x)

More than 1 blank line not allowed

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

View workflow job for this annotation

GitHub Actions / test (18.x)

More than 1 blank line not allowed

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

View workflow job for this annotation

GitHub Actions / test (20.x)

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
Loading