Create an S3 Bucket
Learn to create an S3 bucket with the Serverless Framework.
We'll cover the following
With the successful execution of the previous states of our Production Line State Machine, we've managed to check the availability of the required ingredients, mix them, shape the sweets, and obtain the necessary secret values. Our sweets factory is working quite effectively so far.
However, there's one more crucial step in the sweets production process we need to cover, which is Packaging
. The sweets aren't ready to be distributed until they're appropriately packaged. Each batch produced by the sweets factory has unique attributes. It might vary in terms of the mix of ingredients used, the shaping time, and the shape that was chosen. All this information is extremely valuable and should be documented for future reference or analysis.
That's where the Packaging
step comes in. This state in our AWS Step Functions will simulate the packaging process. Our primary goal here is to create a packaging record for each batch and store it securely. AWS S3 is a perfect service for such storage needs due to its scalability, data availability, security, and performance.
We'll be implementing a Lambda function for the Packaging
state. This function will convert the input it receives, which includes information about the ingredients, the mix result, the shape, and so on, into a packaging record. This record will then be uploaded as a JSON file to our S3 bucket, symbolizing the packaged batch of sweets.
S3 creation process
Note: AWS S3 bucket names need to be globally unique across all AWS accounts. Adding a random string can ensure that the bucket name doesn't collide with any existing bucket names.
We can start by creating the S3 bucket using the Serverless Framework. The serverless.yml
file would need a new resource entry for the S3 bucket.
Let's open serverless.yml
:
Get hands-on with 1400+ tech skills courses.