What's the difference between "tags" and "stackTags" at the provider level for AWS configurations?

What’s the difference between “tags” and “stackTags” at the provider level for AWS configurations?

The example here shows both available.

Serverless Framework - AWS Lambda Guide - Serverless.yml Reference

Do “tags” only apply to Lambda functions?

provider: 
  name: aws
  stackTags: # Optional CF stack tags
    key: value
  tags: # Optional service wide function tags
    foo: bar
    baz: qux
1 Like

I’ve also got this question, is anyone able to provide any further information? From the comments in the serverless.yml example linked above, I am assuming that the difference is that provider.tags are only applied to functions, while provider.stackTags are applied to all resources (including functions)?

tags: # Optional service wide function tags
stackTags: # Optional CF stack tags

The link had the “tags” comment description changed from what the initial poster showed.
Right now the comment of “tags” indicates that it’s globally applied, if tags are given in the provider:

  tags: # Tags that will be added to each of the deployment resources

In my experience this is not working. You actually need to add these to stackTags for the desired effect (propagation of tags in all the resources declared in the yml file). Not entirely sure what the provider.tags does. It looks to be an unfinished feature, as whats in the comment simply does not work.

Also, why provide both provider.tags and stackTags? Provider.tags SHOULD BE the exact same as stackTags, accordin to the provider.tags comment in the docs. This makes zero sense. It should be fixed or the docs should be properly updated, to indicate whats supposed to happen as current behavior is clearly confusing. There is no difference in saying “tags: # Tags that will be added to each of the deployment resources” and “stackTags: # Optional CF stack tags”, as by definition I expect a CF stack tag to be propagated to child resources.

In my testing, tags get added only to functions and API gateway, while stackTags get added to the Cloudformation stack and any other AWS resources you create.

In AWS, “tags” are key-value pairs that you can assign to AWS resources such as EC2 instances, S3 buckets, or RDS databases. Tags are used to categorize and manage resources, making it easier to identify, organize, and control them. Each tag consists of a key and a value, both of which are user-defined strings.