-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial RFC for design of #1432
- Loading branch information
Elad Ben-Israel
authored
Dec 26, 2018
1 parent
6baa8df
commit c0d2d6a
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# RFC: AWS Lambda - Metadata about Code Assets | ||
|
||
As described in [#1432](https://github.com/awslabs/aws-cdk/issues/1432), in order to support local debugging, | ||
debuggers like [SAM CLI](https://github.com/awslabs/aws-sam-cli) need to be able to find the code of a Lambda | ||
function locally. | ||
|
||
The current implementation of assets uses CloudFormation Parameters which represent the S3 bucket and key of the | ||
uploaded asset, which makes it impossible for local tools to reason about (without traversing the cx protocol with | ||
many heuristics). | ||
|
||
## Approach | ||
|
||
We will automatically embed CloudFormation metadata on `AWS::Lambda::Function` resources which use | ||
local assets for code. The metadata will allow tools like SAM CLI to find the code locally for local invocations. | ||
|
||
## Design | ||
|
||
Given a CDK app with an AWS Lambda function defined like so: | ||
|
||
```ts | ||
new lambda.Function(this, 'MyHandler', { | ||
// ... | ||
code: lambda.Code.asset('/path/to/handler') | ||
}); | ||
|
||
The synthesized `AWS::Lambda::Function` resource will include a "Metadata" entry as follows: | ||
|
||
```js | ||
{ | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
// current asset magic | ||
} | ||
}, | ||
"Metadata": { | ||
"aws:code:property": "Code", | ||
"aws:code:path": "/path/to/handler" | ||
} | ||
} | ||
``` | ||
|
||
Local debugging tools like SAM CLI will be able to traverse the template and look up the `aws:source-code` metadata | ||
entries, and use them to process the template so it will be compatible with their inputs. |