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

- Added more logs. #619

Merged
merged 1 commit into from
Nov 28, 2023
Merged
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
63 changes: 41 additions & 22 deletions packages/aws/src/clients/cloudformation.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
UpdateStackCommand,
UpdateStackCommandInput,
UpdateStackCommandOutput,
OnStackFailure,
} from "@aws-sdk/client-cloudformation";
import {CloudformationClientInterface} from "../interfaces/cloudformation-client.interface";
import {v4 as uuid} from "uuid";
Expand Down Expand Up @@ -103,7 +104,7 @@ export class CloudformationClient implements CloudformationClientInterface {
}
return response.Stacks[0];
} catch (e) {
this.logHandler.error("Error getting stack description from cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error getting stack description from cloudformation", {error: e, input}, AwsModuleKeyname);
if (e.message.match("(.*)" + stackName + "(.*)does not exist(.*)")) {
return undefined;
} else {
Expand All @@ -123,7 +124,7 @@ export class CloudformationClient implements CloudformationClientInterface {
const response: DescribeStacksCommandOutput = await this.getClient().send(command);
return response.Stacks ?? [];
} catch (e) {
this.logHandler.error("Error getting stack description from cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error getting stack description from cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -138,7 +139,7 @@ export class CloudformationClient implements CloudformationClientInterface {
try {
return await this.getClient().send(command);
} catch (e) {
this.logHandler.error("Error creating stack in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error creating stack in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -160,7 +161,7 @@ export class CloudformationClient implements CloudformationClientInterface {
}
}
}
this.logHandler.error("Error updating stack in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error updating stack in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -175,7 +176,7 @@ export class CloudformationClient implements CloudformationClientInterface {
try {
return await this.getClient().send(command);
} catch (e) {
this.logHandler.error("Error deleting stack in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error deleting stack in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -188,9 +189,13 @@ export class CloudformationClient implements CloudformationClientInterface {
this.logHandler.debug("CLOUDFORMATION CLIENT - Create Change Set", {input}, AwsModuleKeyname);
const command = new CreateChangeSetCommand(input)
try {
return await this.getClient().send(command);
const response = await this.getClient().send(command);

this.logHandler.debug("CLOUDFORMATION CLIENT - Create Change set Response", {input, response}, AwsModuleKeyname)

return response;
} catch (e) {
this.logHandler.error("Error creating change set in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error creating change set in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -200,12 +205,16 @@ export class CloudformationClient implements CloudformationClientInterface {
* @param input The input to delete a change set.
*/
async deleteChangeSet(input: DeleteChangeSetCommandInput): Promise<DeleteChangeSetCommandOutput> {
this.logHandler.debug("CLOUDFORMATION CLIENT - delete Change Set", {input}, AwsModuleKeyname);
this.logHandler.debug("CLOUDFORMATION CLIENT - Delete Change Set", {input}, AwsModuleKeyname);
const command = new DeleteChangeSetCommand(input)
try {
return await this.getClient().send(command);
const response = await this.getClient().send(command);

this.logHandler.debug("CLOUDFORMATION CLIENT - Delete Change set Response", {input, response}, AwsModuleKeyname)

return response;
} catch (e) {
this.logHandler.error("Error deleting change set in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error deleting change set in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -219,9 +228,14 @@ export class CloudformationClient implements CloudformationClientInterface {
this.logHandler.debug("CLOUDFORMATION CLIENT - Describe Change Set", {input}, AwsModuleKeyname);
const command = new DescribeChangeSetCommand(input)
try {
return await this.getClient().send(command);

const response = await this.getClient().send(command);

this.logHandler.debug("CLOUDFORMATION CLIENT - Describe Change set Response", {input, response}, AwsModuleKeyname)

return response;
} catch (e) {
this.logHandler.error("Error describing change set in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error describing change set in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -235,9 +249,13 @@ export class CloudformationClient implements CloudformationClientInterface {
this.logHandler.debug("CLOUDFORMATION CLIENT - Execute Change Set", {input}, AwsModuleKeyname);
const command = new ExecuteChangeSetCommand(input)
try {
return await this.getClient().send(command);
const response = await this.getClient().send(command);

this.logHandler.debug("CLOUDFORMATION CLIENT - Execute Change set Response", {input, response}, AwsModuleKeyname)

return response;
} catch (e) {
this.logHandler.error("Error executing change set in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error executing change set in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand All @@ -250,9 +268,13 @@ export class CloudformationClient implements CloudformationClientInterface {
this.logHandler.debug("CLOUDFORMATION CLIENT - List Change Sets", {input}, AwsModuleKeyname);
const command = new ListChangeSetsCommand(input)
try {
return await this.getClient().send(command);
const response = await this.getClient().send(command);

this.logHandler.debug("CLOUDFORMATION CLIENT - List Change set Response", {input, response}, AwsModuleKeyname)

return response;
} catch (e) {
this.logHandler.error("Error listing change sets in cloudformation", {error: e}, AwsModuleKeyname);
this.logHandler.error("Error listing change sets in cloudformation", {error: e, input}, AwsModuleKeyname);
throw e;
}
}
Expand Down Expand Up @@ -290,22 +312,19 @@ export class CloudformationClient implements CloudformationClientInterface {
changeSetType = ChangeSetType.CREATE;
}

await this.createChangeSet(
const response = await this.createChangeSet(
{
StackName: stackName,
TemplateURL: cloudformationTemplateS3Url,
Parameters: parameters,
Capabilities: capabilities,
ChangeSetName: changeSetName,
ChangeSetType: changeSetType,
OnStackFailure: OnStackFailure.ROLLBACK,
}
);

// Check if there are actual changes in the ChangeSet.
await this.describeChangeSet({
StackName: stackName,
ChangeSetName: changeSetName,
})
this.logHandler.debug("After calling createChangeSet", {stack, response, changeSetName, stackName}, AwsModuleKeyname)

const status = await this.monitorChangeSet(stackName, changeSetName, "changeSet");

Expand Down
Loading