aws_lambda: enforced code signing causes deployment failure
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### 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.
```python
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_
Contributor guide
Research direction
Start by reproducing the reported deployment with the same Lambda code-signing configuration, comparing WARN and ENFORCE behavior. Trace the CDK Lambda configuration and asset-signing path to find why the deployed artifact is rejected; done means the ENFORCE deployment succeeds with the configured signing profile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100