Passing Resource References to Functions
Understand how to pass external resource references, such as S3 bucket names, to AWS Lambda functions using environment variables. Learn to avoid hard-coding values, configure environment variables with SAM templates, and keep your Lambda deployments flexible and secure.
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 ...