-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.yml
120 lines (111 loc) · 3.69 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
ship-logs-to-honeycomb-app
Ship logs and traces to honeycomb.io
Metadata:
AWS::ServerlessRepo::Application:
Name: ship-logs-to-honeycomb
Description: Ship logs and traces to honeycomb.io
Author: Solve HQ
SpdxLicenseId: MIT
LicenseUrl: LICENSE
ReadmeUrl: README.md
Labels: ["lambda", "honeycomb", "logging", "observability"]
HomePageUrl: https://github.com/solve-hq/ship-logs-to-honeycomb
SemanticVersion: 0.3.12
SourceCodeUrl: https://github.com/solve-hq/ship-logs-to-honeycomb
Parameters:
EventSourceType:
Type: String
Default: "Lambda"
Description: >
What's the event source you will intend to use?
If logs are pushed from CloudWatch Logs to Lambda directly, then use 'Lambda'.
If logs are pushed to a Kinesis Stream first, then use 'Kinesis'.
Other event sources are not supported (yet).
AllowedValues:
- "Lambda"
- "Kinesis"
SecretId:
Type: String
Description: >
The Lambda function expects the HoneyComb credentials to be stored in SecretsManager.
Provide the secret ID for the HoneyComb credentials here.
TimeoutSeconds:
Type: Number
Default: 30
MaxValue: 900
MinValue: 1
Description: >
(optional) Timeout for the Lambda function that would ship logs to HoneyComb. Defaults to 30s.
KinesisStreamArn:
Type: String
Default: ""
Description: >
(optional) Only relevant to the Kinesis event source type. The ARN to the Kinesis stream to
subscribe the function to.
KinesisStreamBatchSize:
Type: Number
Default: 100
Description: >
(optional) Only relevant to the Kinesis event source type. The batch size to use for the
subscription.
Conditions:
IsLambda: !Equals [!Ref EventSourceType, "Lambda"]
IsKinesis: !Equals [!Ref EventSourceType, "Kinesis"]
Globals:
Function:
Timeout: !Ref TimeoutSeconds
Runtime: nodejs8.10
MemorySize: 1024
Environment:
Variables:
SECRET_ID: !Ref SecretId
Resources:
ShipLogsToHoneyLambda:
Type: AWS::Serverless::Function
Condition: IsLambda
Properties:
CodeUri: ./functions/ship-logs-to-honey
Handler: index.handler
Policies:
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource:
- !Sub
- arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${SecretId}-*
- { SecretId: !Ref SecretId }
ShipLogsToHoneyKinesis:
Type: AWS::Serverless::Function
Condition: IsKinesis
Properties:
CodeUri: ./functions/ship-logs-to-honey
Handler: index.handler
Policies:
- Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- secretsmanager:GetSecretValue
Resource:
- !Sub
- arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${SecretId}-*
- { SecretId: !Ref SecretId }
Events:
Stream:
Type: Kinesis
Properties:
Stream: !Ref KinesisStreamArn
BatchSize: !Ref KinesisStreamBatchSize
StartingPosition: LATEST
Outputs:
ShipLogsToHoneyLambdaFunctionName:
Description: Name of the Lambda function name
Value: !If [IsLambda, !Ref ShipLogsToHoneyLambda, !Ref ShipLogsToHoneyKinesis]
ShipLogsToHoneyLambdaFunctionArn:
Description: ARN of the Lambda function name
Value: !If [IsLambda, !GetAtt ShipLogsToHoneyLambda.Arn, !GetAtt ShipLogsToHoneyKinesis.Arn]