Creating an S3 Bucket for Lambda Artifacts
(Do this once ever) = create an S3 bucket for artifacts#
Before building our first lambda, we'll first need to have a bucket in Amazon S3 that will be used to hold our deployment artifacts. This S3 bucket will be used by AWS to fetch our Lambda code, and acts as an artifact repository that we can browse if we ever want to see the exact contents of previous Lambda versions. S3 is cheap, extremely reliable, and commonly used with all kinds of AWS services. By default, S3 buckets are locked down to be available to our account only. While it's possible to change those settings and make an S3 bucket available to anyone on the internet (this is called a public S3 bucket), it's not advised to do that unless you really know what you're doing! Any permissions that need to be modified, will be called out explicitly here - and we will not be creating a public S3 bucket.
One interesting thing about S3 buckets, is that they must be given a name that is globally unique across all AWS accounts. So if we try to create a bucket named
lambda-resources, it probably won't work since someone has taken that name. Instead, try pre-pending some unique string to your desired
myuniquename-lambda-resources . S3 bucket names must be all lower case, and there can be no spaces or special characters (other than a
When we've settled on a name, we can create it either through the S3 web console, or by sending an AWS CLI command for
aws s3api create-bucket as shown below. If you use the AWS CLI, set the flag to
--acl private to keep permissions on lock.
This bucket can be re-used for other future lambda projects. If you decide to create a different bot later - you can just reference this bucket for that project as well.