Skip to content

Commit 6805ee8

Browse files
committed
fix: remove token references when hashing
1 parent 789dc9c commit 6805ee8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,19 @@ export class ImagePipeline extends Construct {
329329
new imagebuilder.CfnImagePipeline(this, 'ImagePipeline', imagePipelineProps);
330330
}
331331

332+
/**
333+
* Helper function to hash an object to create unique resource names
334+
*
335+
* @param o an object to hash
336+
* @returns 6 character hash string
337+
*/
332338
private hash(o: object): string {
339+
// Remove any token references that would cause the result to be
340+
// non-deterministic.
341+
const cleanString = JSON.stringify(o).replace(/\${[^{]*}/g, '');
342+
333343
return createHash('sha256')
334-
.update(JSON.stringify(o))
344+
.update(cleanString)
335345
.digest('hex')
336346
.toUpperCase()
337347
.slice(0, 6);

0 commit comments

Comments
 (0)