Search⌘ K

Passing Resource References to Functions

Understand how to configure AWS Lambda functions to reference external resources such as S3 buckets without hard-coding values. Learn to use environment variables in AWS SAM to pass resource names dynamically, enabling secure and manageable serverless applications.

We'll cover the following...

In order to complete the function, you’ll need to tell it which bucket to use (line 8 from the code in the previous lesson). Lambda functions don’t really know about SAM and CloudFormation resources, so the function can’t just ask for the UploadS3Bucket resource. SAM will create the bucket using a randomised name, and you need to tell the Lambda function about the actual value.

You definitely don’t want to hard code a bucket name in the function source, because then SAM can’t automatically manage buckets. You could ...