-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaxiom-cloudfront-lambda-base-cloudformation-stack.template.yaml
80 lines (80 loc) · 2.2 KB
/
axiom-cloudfront-lambda-base-cloudformation-stack.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
Parameters:
BucketName:
Description: The Name of the S3 Bucket.
Type: String
MinLength: 1
AxiomToken:
Description: The Token of User in Axiom. Must start with xaat- or xait-.
Type: String
NoEcho: true
MinLength: 1
AllowedPattern: "^(xaat-|xait-).*"
AxiomURL:
Type: String
Default: "https://cloud.axiom.co"
Description: The URL of Axiom endpoint. Defaults to "https://cloud.axiom.co".
AxiomDataset:
Type: String
Description: The Name of the Dataset in Axiom.
MinLength: 1
Resources:
LogsRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- 'sts:AssumeRole'
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
LogsPolicy:
Type: AWS::IAM::Policy
Properties:
PolicyDocument:
Statement:
- Action:
- 's3:GetObject'
- 's3:ListBucket'
Effect: Allow
Resource:
- !Sub
- 'arn:aws:s3:::${BucketSub}'
- BucketSub: !Ref 'BucketName'
- 'arn:aws:s3:::*/*'
PolicyName: axiom-cloudfront-lambda-policy
Roles:
- !Ref 'LogsRole'
LogsLambda:
Type: AWS::Lambda::Function
Properties:
Runtime: python3.9
FunctionName: axiom-cloudfront-lambda
Handler: index.lambda_handler
Code:
ZipFile: |
# DO NOT EDIT
# CI will replace these comments with the code from ./handler.py
Role: !GetAtt
- LogsRole
- Arn
Environment:
Variables:
AXIOM_TOKEN: !Ref 'AxiomToken'
AXIOM_DATASET: !Ref 'AxiomDataset'
AXIOM_URL: !Ref 'AxiomURL'
LogsLambdaPermission:
Type: AWS::Lambda::Permission
DependsOn:
- LogsLambda
Properties:
Action: lambda:InvokeFunction
FunctionName: !Ref 'LogsLambda'
Principal: s3.amazonaws.com
SourceAccount: !Ref 'AWS::AccountId'
SourceArn: !Sub
- 'arn:aws:s3:::${BucketSub}'
- BucketSub: !Ref 'BucketName'