Tagging serverless stacks


#1

I asked a question a couple days ago in the Serverless Gitter and wanted to post here with the question and solution so others can find the solution if they have a similar question.


Question:
Hey everyone, I’m just getting up and running on the Serverless tool suit deploying an AWS Lambda function running node. I’m having a problem with some of my companies AWS policies though. Any AWS resource that we deploy MUST be tagged with certain things. Resources that aren’t properly tagged will get destroyed. It’s for cost analysis and savings. Not a big deal at all! I have everything tagged that I need tagged except the S3 bucket that Serverless uses for deployment. Is there a way for me to define and programmatically tag that S3 bucket?

Solution:
Here is what you can do:
Add stackTags under the provider section to tag all resources that are taggable.

stackTags: # Optional CF stack tags
 key: value

Alternatively, if you do wnat to specify your own Deployment Bucket you can do so by specifying it under the provider section as well. You take care of managing the lifecycle of the bucket outside of the framework.

deploymentBucket:
 name: com.serverless.${self:provider.region}.deploys # Deployment bucket name. Default is generated by the framework

In the end I used a separate deployment bucket because it works with my team’s infrastructure more easily, however, the first solution worked perfectly too!

Thank you Rupak for your help!