aws-cdk: aws_lambda: enforced code signing causes deployment failure
Describe the bug
While configuring code signing on an aws lambda if you specify a code signing config where the untrusted_artifact_on_deployment parameter is set to ENFORCE the deployment will always fail. If the policy is set to warn there is no problem.
test_signing_profile = signer.SigningProfile(
self,
"Test Signing Profile",
platform=signer.Platform.AWS_LAMBDA_SHA384_ECDSA,
)
test_code_signing_config = lambda_.CodeSigningConfig(
self,
"Test Code Signing Config",
signing_profiles=[
test_signing_profile,
],
description="Test",
# setting untrusted_artifact_on_deployment to ENFORCE causes deployment to fail
untrusted_artifact_on_deployment=lambda_.UntrustedArtifactOnDeployment.ENFORCE,
)
test_lambda = lambda_.Function(
self,
"Test Lambda",
runtime=lambda_.Runtime.PYTHON_3_12,
handler="lambda_function.lambda_handler",
code_signing_config=test_code_signing_config,
code=lambda_.Code.from_asset(
"lambda/api/websocket/test",
),
timeout=Duration.seconds(15),
memory_size=256,
architecture=lambda_.Architecture.X86_64,
retry_attempts=0,
description="Test Lambda delete later.",
initial_policy=[],
)
Expected Behavior
The lambda to be signed using the code signing configuration
Current Behavior
The code fails to deploy with an error message: Lambda cannot deploy the function. The function or layer might be signed using a signature that the client is not configured to accept. Check the provided signature for LAMBDA_ARN_HERE
Reproduction Steps
Create a stack with the above resources, try to deploy a lambda with warn, it will work. Try to deploy the lambda with enforce, it will not work
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.132.1
Framework Version
No response
Node.js Version
v20.11.1
OS
Ubuntu 23.10
Language
Python
Language Version
Python 3.11
Other information
No response
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (10 by maintainers)
I believe it’s relevant to https://github.com/aws/aws-cdk/issues/12216#issuecomment-784290273 which mentioned that CDK actually didn’t sign the bundle from local and https://github.com/aws/aws-cdk-rfcs/issues/305 was attempting to address that but was closed. At this moment, I am afraid you need to sign the bundle using AWS CLI start-signing-job or from the AWS Signer console.
We still welcome any idea to continue from where https://github.com/aws/aws-cdk-rfcs/issues/305#issuecomment-1858352721 was stopped. I will submit a small PR to mention that in the lambda doc.
internal tracking: V1521555433
Looks like it’s Lambda service’s responsibility to proceed the signing operation but I can’t find relevant document about it.
I’ll cut an internal ticket for clarifying.
@cjhelloletsgo FYI we are still investigating. Will let you know shortly if we have any updates.
I am making it a p1 bug now.
Yes now I can reproduce this
CDK v2.158.0
synth