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 Cloudformation error message #623

Merged
merged 3 commits into from Mar 7, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [7.3.8] - 2023-03-07

### Fixed
- Updated Cloudformation find API id error message

## [7.3.7] - 2023-03-06

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "serverless-domain-manager",
"version": "7.3.7",
"version": "7.3.8",
"engines": {
"node": ">=14"
},
Expand Down
5 changes: 4 additions & 1 deletion src/aws/cloud-formation-wrapper.ts
Expand Up @@ -112,7 +112,10 @@ class CloudFormationWrapper {
}

if (!response) {
throw new Error(`Failed to find a stack ${this.stackName}\n`);
throw new Error(
`Failed to find logicalResourceId '${logicalResourceId}' for the stack ${this.stackName}\n` +
"Make sure the stack exists and the API gateway event is added"
);
}

const apiId = response.StackResourceDetail.PhysicalResourceId;
Expand Down
12 changes: 8 additions & 4 deletions test/unit-tests/aws/cloud-formation-wrapper.test.ts
Expand Up @@ -106,7 +106,8 @@ describe("Cloud Formation wrapper checks", () => {
await new CloudFormationWrapper().findApiId(Globals.apiTypes.rest);
} catch (err) {
errored = true;
expect(err.message).to.contains("Failed to find a stack");
expect(err.message).to.contains("Failed to find logicalResourceId");
expect(err.message).to.contains("Make sure the stack exists and the API gateway event is added");
}
expect(errored).to.equal(true);

Expand Down Expand Up @@ -159,7 +160,8 @@ describe("Cloud Formation wrapper checks", () => {
await new CloudFormationWrapper().findApiId(Globals.apiTypes.rest);
} catch (err) {
errored = true;
expect(err.message).to.contains("Failed to find a stack");
expect(err.message).to.contains("Failed to find logicalResourceId");
expect(err.message).to.contains("Make sure the stack exists and the API gateway event is added");
}
expect(errored).to.equal(true);

Expand All @@ -184,7 +186,8 @@ describe("Cloud Formation wrapper checks", () => {
await new CloudFormationWrapper().findApiId(Globals.apiTypes.rest);
} catch (err) {
errored = true;
expect(err.message).to.contains("Failed to find a stack");
expect(err.message).to.contains("Failed to find logicalResourceId");
expect(err.message).to.contains("Make sure the stack exists and the API gateway event is added");
}
expect(errored).to.equal(true);
expect(consoleOutput[0]).to.contains("Unsupported apiGateway");
Expand Down Expand Up @@ -388,7 +391,8 @@ describe("Cloud Formation wrapper checks", () => {
await new CloudFormationWrapper().findApiId(Globals.apiTypes.rest);
} catch (err) {
errored = true;
expect(err.message).to.contains("Failed to find a stack");
expect(err.message).to.contains("Failed to find logicalResourceId");
expect(err.message).to.contains("Make sure the stack exists and the API gateway event is added");
}
expect(errored).to.equal(true);
expect(consoleOutput[0]).to.contains("[WARNING] Failed to find CloudFormation resources with an error");
Expand Down