Skip to content

Commit

Permalink
fix(sqsPlugin): sqs arn defined in cloudformation template is not par…
Browse files Browse the repository at this point in the history
…sed correctly
  • Loading branch information
Inqnuam committed Oct 20, 2023
1 parent 216d2ea commit a092ab0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
10 changes: 2 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ class ServerlessAwsLambda extends Daemon {
nodeVersion: number | boolean | string | undefined = false;
invokeName?: string;
afterDeployCallbacks: (() => void | Promise<void>)[] = [];
resources: {
ddb: {};
kinesis: {};
sns: {};
sqs: {};
};
resources: ReturnType<typeof getResources> = { ddb: {}, kinesis: {}, sns: {}, sqs: {} };
constructor(serverless: any, options: any, pluginUtils: PluginUtils) {
super({ debug: process.env.SLS_DEBUG == "*" });

Expand Down Expand Up @@ -123,8 +118,6 @@ class ServerlessAwsLambda extends Daemon {
"after:aws:deploy:finalize:cleanup": this.afterDeploy.bind(this),
"after:invoke:local:invoke": process.exit,
};

this.resources = getResources(this.serverless);
}

async invokeLocal() {
Expand All @@ -143,6 +136,7 @@ class ServerlessAwsLambda extends Daemon {
}
}
async init(isPackaging: boolean) {
this.resources = getResources(this.serverless);
this.#setRuntimeEnvs();
this.#lambdas = this.#getLambdas();
await this.#setCustomEsBuildConfig();
Expand Down
9 changes: 4 additions & 5 deletions src/lib/parseEvents/sqs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { log } from "../utils/colorize";
export interface ISqs {
name: string;
arn?: string;
Expand All @@ -19,17 +18,17 @@ const parseQueueNameFromObject = (resources: any, Outputs: any, obj: any) => {
if (!values.length) {
return;
}
const topicName = values[1][values[1].length - 1];
const queueName = values[1][values[1].length - 1];

if (typeof topicName == "string") {
return topicName.split("/")[1];
if (typeof queueName == "string") {
return queueName.split("/")[1];
}
} else if (key == "Fn::GetAtt" || key == "Ref") {
const [resourceName] = value as unknown as any[];

const resource = resources?.[resourceName];
if (resource) {
return resource.TopicName;
return resource.QueueName;
}
} else if (key == "Fn::ImportValue" && typeof value == "string") {
return Outputs?.[value]?.Export?.Name;
Expand Down

0 comments on commit a092ab0

Please sign in to comment.