Skip to content

Commit 785cef4

Browse files
committed
Allow tagging of function
Fixes serverless-components#22
1 parent 448e723 commit 785cef4

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ myFunction:
6969
TABLE_NAME: my-table
7070
region: us-east-1
7171

72+
tags:
73+
environment: "Production"
74+
contact: "[email protected]"
75+
76+
7277
# if you'd like to include any shims
7378
shims:
7479
- ../shims/shim.js

serverless.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const outputsList = [
2828
'role',
2929
'layer',
3030
'arn',
31-
'region'
31+
'region',
32+
'tags'
3233
]
3334

3435
const defaults = {
@@ -43,6 +44,7 @@ const defaults = {
4344
env: {},
4445
region: 'us-east-1',
4546
layers: []
47+
tags: {}
4648
}
4749

4850
class AwsLambda extends Component {

utils.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable prettier/prettier */
21
const { tmpdir } = require('os')
32
const path = require('path')
43
const archiver = require('archiver')
@@ -78,7 +77,8 @@ const createLambda = async ({
7877
bucket,
7978
role,
8079
layer, // From autogenerated layer
81-
layers // Manual layers
80+
layers, // Manual layers
81+
tags
8282
}) => {
8383
const params = {
8484
FunctionName: name,
@@ -90,6 +90,7 @@ const createLambda = async ({
9090
Role: role.arn,
9191
Runtime: runtime,
9292
Timeout: timeout,
93+
Tags: tags,
9394
Environment: {
9495
Variables: env
9596
},
@@ -124,7 +125,8 @@ const updateLambdaConfig = async ({
124125
description,
125126
role,
126127
layer, // From autogenerated layer
127-
layers // Manual layers
128+
layers, // Manual layers
129+
tags
128130
}) => {
129131
const functionConfigParams = {
130132
FunctionName: name,
@@ -186,7 +188,8 @@ const getLambda = async ({ lambda, name }) => {
186188
memory: res.MemorySize,
187189
hash: res.CodeSha256,
188190
env: res.Environment ? res.Environment.Variables : {},
189-
arn: res.FunctionArn
191+
arn: res.FunctionArn,
192+
tags: res.Tags
190193
}
191194
} catch (e) {
192195
if (e.code === 'ResourceNotFoundException') {

0 commit comments

Comments
 (0)