Dominik Seibold
02/03/2022, 6:40 PMfunctions.jsonl
file.]
[SST-version: 0.61.0]
We are experiencing some weird behavior in the functions.jsonl file.
Functions that are created with the same custom Construct are given the same ID in the functions.jsonl
file.
When calling the function, the source code in the artifacts
is used where the ID is matched first.
Example:
We create functions in different services with the same custom CDK construct. Marked in the picture.
The ID is the same āb3f05295ā. However, in the artifacts folder there is only the source code for ā...services/user...ā for this ID.
Expected behavior:
Each function should get a unique ID in the functions.jsonl
file. This way the same code will not be executed for each function.
Does anyone else experience this problem?Dominik Seibold
02/03/2022, 6:41 PMthdxr
02/03/2022, 6:41 PMconst localId = crypto
.createHash("sha1")
.update(scope.node.id + id)
.digest("hex")
.substring(0, 8);
thdxr
02/03/2022, 6:42 PMFabian Ehringer
02/03/2022, 7:19 PMthdxr
02/03/2022, 9:01 PMthdxr
02/03/2022, 9:01 PMFabian Ehringer
02/03/2022, 10:21 PMFabian Ehringer
02/04/2022, 12:17 AMacme.Stack
is just a wrapper of the sst.Stack
to provide some āmetadataā like the service domain to our constructs.Fabian Ehringer
02/04/2022, 12:24 AMscope.node.id
in sst.Function
is the id of the construct which is only unique in the parent construct, but neither in the stack nor in the app, right? Our custom construct is used multiple times with the same ID which is fine since itās not the same stack. Using scope.node.path
would fix it imo:
const localId = crypto
.createHash("sha1")
.update(scope.node.path + id)
.digest("hex")
.substring(0, 8);
Fabian Ehringer
02/04/2022, 1:07 AMthdxr
02/04/2022, 1:28 AMthdxr
02/04/2022, 1:28 AMthdxr
02/04/2022, 1:28 AMthdxr
02/04/2022, 1:29 AMFabian Ehringer
02/04/2022, 1:29 AMFabian Ehringer
02/04/2022, 1:30 AM<stage>-<projectName>-<stackId>/<constructId>
Fabian Ehringer
02/04/2022, 1:31 AMDominik Seibold
02/04/2022, 9:06 AMthdxr
02/04/2022, 2:55 PMthdxr
02/07/2022, 2:44 PM