Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS-Lambda: Sharing Lambda bucket between accounts #26684

Closed
1 of 2 tasks
Ajris opened this issue Aug 9, 2023 · 3 comments
Closed
1 of 2 tasks

AWS-Lambda: Sharing Lambda bucket between accounts #26684

Ajris opened this issue Aug 9, 2023 · 3 comments
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.

Comments

@Ajris
Copy link

Ajris commented Aug 9, 2023

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

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.88.0

Environment details (OS name and version, etc.)

Ubuntu 22.04, Typescript

@Ajris Ajris added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 9, 2023
@github-actions github-actions bot added the @aws-cdk/aws-lambda Related to AWS Lambda label Aug 9, 2023
@peterwoodworth
Copy link
Contributor

When you pass in the bucket to Code.fromBucket, you can specify the account when importing the bucket. Does this help?

@peterwoodworth peterwoodworth added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Aug 9, 2023
@Ajris
Copy link
Author

Ajris commented Aug 10, 2023

Yes, it works. Sorry for trouble :) I was hoping that I dont have to explicitly provide the string values, but I could someohw just reference it in the CDK by passing the bucket. Thanks!

@Ajris Ajris closed this as completed Aug 10, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants