I’ve found the best way to name AWS resources is to use the following convention.
{stage-name}-{stack-name}-{resource-name}
This approach tells us 3 things just by looking at the resource name.
service: Billing
Description: The billing service.
custom:
stage: ${opt:stage, self:provider.stage}
resourcePrefix: ${self:custom.stage}-${self:service.name}
provider:
stage: dev
functions:
ProcessPaymentNotification:
name: ${self:custom.resourcePrefix}-ProcessPaymentNotification
resources:
Resources:
PaymentsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.resourcePrefix}-Payments
This naming convention is not a replacement for Tags. Tags are useful in many other ways.
It helps small teams that are sharing an AWS account identify and search resources easily. Creating separate AWS accounts, setting up federated billing and using AWS Control Tower can be a complicated solution for small teams. Many team’s end up using a single account for this reason. This naming convention is useful in such cases.