-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
119 lines (111 loc) · 3.77 KB
/
template.yaml
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
lambda-go-sam-s3
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 60
MemorySize: 256
Environment:
Variables:
AWS_ASSUME_ROLE: <AWS Assume Role ARN>
DD_HOST: <Datadog metric hostname>
DD_API_KEY: <Datadog api key>
DEBUG: <If debug output, define THIS>
#Parameters:
#LambdaRole:
# Default: <External IAM Role name>
# Type: String
# Bucket:
# Default: <ALB access logs s3 bucket name>
# Type: String
# BucketPrefix:
# Default: <ALB access logs s3 bucket prefix>
# Type: String
Resources:
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: "sts:AssumeRole"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
-
PolicyName: "StsAssumeRole"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action: "sts:AssumeRole"
Resource: "*"
S3GetFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: main.zip
Handler: main
Runtime: go1.x
Role: !GetAtt LambdaRole.Arn
# Role: !Join
# - ''
# - - 'arn:aws:iam::'
# - !Ref 'AWS::AccountId'
# - ':role/'
# - !Ref LambdaRole
# Events:
# BucketEventCreate:
# Type: S3 # More info about S3 Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#s3
# Properties:
# Bucket:
# Ref: AlbLogBucket
# Events:
# - 's3:ObjectCreated:*'
# Filter: # More info about S3 Notification Filter https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfiguration-config-filter.html
# S3Key:
# Rules:
# - Name: prefix
# Value:
# Ref: BucketPrefix
# - Name: suffix
# Value: '.gz'
# Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
# Variables:
# DEBUG: 1
# DD_HOST:
# DD_API_KEY:
S3GetFunctionLogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub /aws/lambda/${S3GetFunction}
RetentionInDays: 30
# AlbLogBucket:
# Type: AWS::S3::Bucket
# Properties:
# BucketName:
# Ref: Bucket
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
LambdaRoleName:
Description: "Lambda Name"
Value: !Ref LambdaRole
LambdaRoleArn:
Description: "Lambda Role"
Value: !GetAtt LambdaRole.Arn
S3GetFunctionName:
Description: "Lambda Function Name"
Value: !Ref S3GetFunction
S3GetFunctionArn:
Description: "Lambda Function ARN"
Value: !GetAtt S3GetFunction.Arn
# AlbLogBucket:
# Description: "S3 Bucket ARN"
# Value: !GetAtt AlbLogBucket.Arn