Skip to content
This repository was archived by the owner on Aug 1, 2022. It is now read-only.

Commit 99627c5

Browse files
author
Jesús Fernando Alvarez Franco
committed
fix: resolve Fn::GetAtt
1 parent 8fa2908 commit 99627c5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/main.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,24 @@ class ServerlessOfflineStepFunctionsPlugin {
9999
break;
100100
}
101101

102-
const functionName = (stateOptions as any).Resource.split('-').slice(-1)[0];
102+
let functionName: string | undefined;
103+
const resource: string | Record<string, string[]> = (stateOptions as any).Resource;
104+
105+
if (typeof resource === 'string') {
106+
functionName = resource.split('-').slice(-1)[0];
107+
} else {
108+
// probably an object
109+
for (const [key, value] of Object.entries(resource)) {
110+
if (key === 'Fn::GetAtt') {
111+
functionName = value[0];
112+
}
113+
}
114+
}
115+
116+
if (!functionName) {
117+
throw Error();
118+
}
119+
103120
const { handler } = definedFunctions[functionName];
104121
const indexOfHandlerNameSeparator = handler.lastIndexOf('.');
105122
const handlerPath = handler.substring(0, indexOfHandlerNameSeparator);

0 commit comments

Comments
 (0)