AWS-Lambda: Sharing Lambda bucket between accounts #26684
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
feature-request
A feature should be added or improved.
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Describe the feature
Hi,
Currently in CDK it is impossible to share values between the accounts/region (limitation of cloudformation). It is quite usual setup that there are couple of separate environments (1 shared with S3 bucket for Lambda code & ECR repositories, 1 dev account for application that uses those repositories and 1 prod account that is almost the same as the main one).
I suggest changing the implementation of S3Code or even adding the new implementation like S3CrossAccountCode, where we could provide the additional parameters like aws account so that it will be utilised by the Stack.
Use Case
In the current implementation of passing the code in the "new aws_lambda.Function", if we want to use the code from S3 bucket, we have to provide directly the object IBucket (from which only bucket name is taken). It limits the possibility of using bucket and ECR in another account (we cannot pass the object from one stack in one account to another account in CDK).
Proposed Solution
I found code for the S3Code here:
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-lambda/lib/code.ts#L215
Adding additional implementation based on this (and probably extending the configuration a bit of interface CodeConfig to add the account number) should be sufficient to solve it.
TBH, I would be happy to try out implementing it. (if the suggested solution is not enough, please clarify what is missing, so I can adjust it for the CDK)
Other Information
No response
Acknowledgements
CDK version used
2.88.0
Environment details (OS name and version, etc.)
Ubuntu 22.04, Typescript
The text was updated successfully, but these errors were encountered: