serverless-tag-resources 1.2.50 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,40 +1,126 @@
1
1
  # serverless-tag-resources
2
- A serverless plugin to tag all resources on AWS
2
+
3
+ Serverless Framework plugin to tag all AWS resources. Supports dual tagging (legacy PascalCase + new `datamart:*` format) for transition periods.
3
4
 
4
5
  ## Features
5
- * Tag all resources created by serverless
6
- * Tag all resources specified on resources section
7
- * Fix tags on dict based tag specification resources like *AWS::SSM::Parameter*
8
- * Add *Resource* tag automatically, setting *LogicalID* as value
9
- * Add *Stage* tag automatically
10
6
 
11
- ## Instalation
7
+ - Tags all resources created by Serverless Framework
8
+ - Tags resources in the `resources` section
9
+ - Handles dict-based tag resources (SSM Parameter, API GW V2, Glue, Batch)
10
+ - Post-deploy tagging for RDS Clusters, Firehose, EC2 related resources
11
+ - Auto-generates `Stage` / `datamart:environment` from deployment stage
12
+ - Auto-generates `Resource` / `datamart:resource` from CloudFormation LogicalID
13
+ - Optional tag validation against allowed domains
14
+ - AWS SDK v3
15
+
16
+ ## Installation
12
17
 
13
18
  ```
14
19
  npm i serverless-tag-resources
15
20
  ```
16
21
 
17
- then add it in your plugins list:
22
+ Add to plugins:
18
23
 
19
- ```
24
+ ```yaml
20
25
  plugins:
21
26
  - serverless-tag-resources
22
- ```
27
+ ```
23
28
 
24
- ## Tags Configuration
29
+ ## Configuration
25
30
 
26
- Using the tags configuration makes it possible to add key / value tags on all AWS Resources.
31
+ ### Tags (provider.stackTags)
27
32
 
28
- This plugin use stackTags values from provider specification.
33
+ ```yaml
34
+ provider:
35
+ stackTags:
36
+ # Legacy tags (maintained for backwards compatibility)
37
+ CostCenter: getdata
38
+ BusinessUnit: getdata-cl
39
+ Service: ${self:service}
40
+ Component: api
41
+ Customer: common
29
42
 
43
+ # New datamart:* tags
44
+ datamart:cost-center: getdata
45
+ datamart:business-unit: getdata-cl
46
+ datamart:service: ${self:service}
47
+ datamart:component: api
48
+ datamart:finops-scope: runtime
49
+ datamart:data-classification: confidential
50
+ datamart:criticality: high
51
+ datamart:team: platform
30
52
  ```
31
- stackTags:
32
- Component: ${self:service}
33
- Scheduled: no
34
- Scope: protected
35
- Developer: ysaborit
36
- Customer: Common
53
+
54
+ The plugin auto-adds these tags (no need to specify):
55
+ - `Stage` / `datamart:environment` — set to the deployment stage
56
+ - `Resource` / `datamart:resource` — set to the CloudFormation LogicalID
57
+
58
+ ### Validation (optional)
59
+
60
+ Enable tag validation to enforce required tags and allowed values:
61
+
62
+ ```yaml
63
+ custom:
64
+ datamart:
65
+ validation: true
37
66
  ```
38
67
 
68
+ When enabled, deployment fails if required `datamart:*` tags are missing or have invalid values.
69
+
70
+ **Required tags**: `datamart:cost-center`, `datamart:finops-scope`, `datamart:data-classification`, `datamart:criticality`, `datamart:team`
71
+
72
+ **Validated values**:
73
+ - `datamart:finops-scope`: runtime, compliance, security, scraping, ai, devtools, infrastructure
74
+ - `datamart:environment`: prod, homo, qa, dev, sandbox, dr
75
+ - `datamart:data-classification`: public, internal, confidential, restricted
76
+ - `datamart:criticality`: critical, high, medium, low
77
+ - `datamart:cost-center`: datamart, getdata, connect, vizdata, legalbase, facesign, keyshield, lendbot, jscipher, atlas, openfinance, payments, operations
78
+
79
+ ## How it works
80
+
81
+ ### Hook 1: before:package:finalize
82
+
83
+ Mutates the CloudFormation template to inject tags into all supported resources before deployment. Handles both list-based (`[{Key, Value}]`) and dict-based (`{key: value}`) tag formats depending on the resource type.
84
+
85
+ ### Hook 2: after:deploy:deploy
86
+
87
+ Tags resources that need post-deploy API calls:
88
+ - SSM Parameters (AddTagsToResource)
89
+ - Pinpoint Apps (TagResource)
90
+ - API Gateway V2 (Api, Stage, DomainName, VpcLink)
91
+ - RDS Clusters (AddTagsToResource)
92
+ - Kinesis Firehose (TagDeliveryStream)
93
+ - EC2 Instances + related resources (EBS volumes, ENIs, EIPs, Security Groups)
94
+
95
+ ## Development
96
+
97
+ ```bash
98
+ npm install
99
+ npm test
100
+ npm run test:verbose
101
+ npm run test:coverage
102
+ ```
103
+
104
+ ## Changelog
105
+
106
+ ### v3.0.0 (April 2026)
107
+ - Migrated to AWS SDK v3
108
+ - Modular architecture (src/ directory)
109
+ - Dual tag support: legacy PascalCase + datamart:* format
110
+ - Auto-generated `datamart:environment` and `datamart:resource` tags
111
+ - Optional tag validation with domain enforcement
112
+ - Fixed: Stage tag was never added to list-based resources (concat bug)
113
+ - Fixed: forEach+async pattern (promises were not awaited)
114
+ - Fixed: dict-based resources now tagged in CF template (was commented out)
115
+ - Fixed: Glue::Crawler contradiction (was in both supported and unsupported lists)
116
+ - Added Jest test suite (60+ tests)
117
+ - Removed unused helpers (awsCloudFormation.js, awsSSM.js)
118
+
119
+ ### v2.5.2
120
+ - Last version before refactor
121
+ - Single file architecture (index.js)
122
+ - AWS SDK v2
123
+
39
124
  ## License
40
- MIT
125
+
126
+ ISC