Skip to content

Commit 63626b9

Browse files
authored
removing use of calculateFunctionHash function (#4)
We drop the usage of the internal `calculateFunctionHash` function to use the `fn.currentVersion.version` public attribute instead.
1 parent c7026a8 commit 63626b9

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/resource-initializer.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
import * as ec2 from '@aws-cdk/aws-ec2'
55
import * as lambda from '@aws-cdk/aws-lambda'
6-
import { Construct, Duration, Stack, Tags } from '@aws-cdk/core'
7-
import { createHash } from 'crypto'
8-
import { calculateFunctionHash } from '@aws-cdk/aws-lambda/lib/function-hash'
6+
import { Construct, Duration, Stack } from '@aws-cdk/core'
97
import { AwsCustomResource, AwsCustomResourcePolicy, AwsSdkCall, PhysicalResourceId } from '@aws-cdk/custom-resources'
108
import { RetentionDays } from '@aws-cdk/aws-logs'
119
import { PolicyStatement, Role, ServicePrincipal } from '@aws-cdk/aws-iam'
@@ -55,18 +53,14 @@ export class CdkResourceInitializer extends Construct {
5553
}
5654
})
5755

58-
const physicalResIdHash = createHash('md5')
59-
.update(calculateFunctionHash(fn) + payload)
60-
.digest('hex')
61-
6256
const sdkCall: AwsSdkCall = {
6357
service: 'Lambda',
6458
action: 'invoke',
6559
parameters: {
6660
FunctionName: fn.functionName,
6761
Payload: payload
6862
},
69-
physicalResourceId: PhysicalResourceId.of(`${id}-AwsSdkCall-${physicalResIdHash}`)
63+
physicalResourceId: PhysicalResourceId.of(`${id}-AwsSdkCall-${fn.currentVersion.version}`)
7064
}
7165

7266
// IMPORTANT: the AwsCustomResource construct deploys a singleton AWS Lambda function that is re-used across the same CDK Stack,

0 commit comments

Comments
 (0)