From 21dcb1bd4fbca2bfab40126f5f70d68b002a89e3 Mon Sep 17 00:00:00 2001 From: Tatu Lahtela Date: Wed, 5 Feb 2020 09:35:10 +0200 Subject: [PATCH 1/3] Allow tagging of function Fixes #22 --- serverless.js | 6 ++++-- utils.js | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/serverless.js b/serverless.js index dd321d9..e41e1a4 100644 --- a/serverless.js +++ b/serverless.js @@ -28,7 +28,8 @@ const outputsList = [ 'role', 'layer', 'arn', - 'region' + 'region', + 'tags' ] const defaults = { @@ -41,7 +42,8 @@ const defaults = { handler: 'handler.hello', runtime: 'nodejs10.x', env: {}, - region: 'us-east-1' + region: 'us-east-1', + tags: {} } class AwsLambda extends Component { diff --git a/utils.js b/utils.js index 7e2aac2..e8711d6 100644 --- a/utils.js +++ b/utils.js @@ -76,7 +76,8 @@ const createLambda = async ({ zipPath, bucket, role, - layer + layer, + tags }) => { const params = { FunctionName: name, @@ -88,6 +89,7 @@ const createLambda = async ({ Role: role.arn, Runtime: runtime, Timeout: timeout, + Tags: tags, Environment: { Variables: env } @@ -119,7 +121,8 @@ const updateLambdaConfig = async ({ env, description, role, - layer + layer, + tags }) => { const functionConfigParams = { FunctionName: name, @@ -180,7 +183,8 @@ const getLambda = async ({ lambda, name }) => { memory: res.MemorySize, hash: res.CodeSha256, env: res.Environment ? res.Environment.Variables : {}, - arn: res.FunctionArn + arn: res.FunctionArn, + tags: res.Tags } } catch (e) { if (e.code === 'ResourceNotFoundException') { From 519b14aaf9a1b0317088ca14b45bc6a8dee6e902 Mon Sep 17 00:00:00 2001 From: Tatu Lahtela Date: Fri, 7 Feb 2020 11:53:39 +0200 Subject: [PATCH 2/3] Add example in readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index b489579..8e61054 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,11 @@ myFunction: TABLE_NAME: my-table region: us-east-1 + tags: + environment: "Production" + contact: "address@email.com" + + # if you'd like to include any shims shims: - ../shims/shim.js From 7d068cc0c5f22cc4a2233b10d27f53b9cc41f2df Mon Sep 17 00:00:00 2001 From: Tatu Lahtela Date: Fri, 7 Feb 2020 11:54:57 +0200 Subject: [PATCH 3/3] Tabs to spaces --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8e61054..59cd1b0 100644 --- a/README.md +++ b/README.md @@ -69,10 +69,10 @@ myFunction: TABLE_NAME: my-table region: us-east-1 - tags: - environment: "Production" - contact: "address@email.com" - + tags: + environment: "Production" + contact: "address@email.com" + # if you'd like to include any shims shims: