serverless.yml
file in backend
. It is a IAS
(Infrastructure As Code) Framework, used to define ressources in AWS or other providers. Open the file and let’s
look at how it works
webapp
is simply the name we gave to this Lambda function, each other name will create another function. The event
describes how this function is invoked, in our case it is through an HTTP request. This means, that alongside the function,
also an AWS API Gateway is created.
serverless-wsgi
.
Open app_lambda.py
, there you will see how we wrap our application and define the handler function
we point to in our YAML file.
useDotenv: true
at the
top of the file we allow serverless to read our .env
file and access it using ${env:KEYNAME}
. An important thing to note,
is that our .env
file will NOT be copied to our Lambda function for security reasons. This means, that all the environment
variables we want to give to the code, have to be passed manually. This we do in provider.environments:
.env
file. We will reference
it when creating the CloudFront distribution later
serverless.yml
to define custom ressources.
bucketName
, as well as a localDir
pointing to our static folder, which
we will deploy.
app.py
and go to the bottom of the file, to see, how we
point to the CloudFront domain, if it is requesting static content.
serverless-domain-manager
plugin. It is configured inside the custom tab:
.env
file:
sls create_domain
. This will use the set information to create the new Domain.
sls remove
), you
can simply call sls delete_domain
sls deploy
. This will automatically create all the ressources you have defined