This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sam-template.yml
86 lines (86 loc) · 2.82 KB
/
sam-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
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'SAM template for Serverless framework service: Application Cost Monitoring'
Resources:
BillingRecordsSnsTopic:
Type: 'AWS::SNS::Topic'
Publish:
Type: 'AWS::Serverless::Function'
Properties:
# NOTE: Necessary to handle LambdaInvokePolicy for self.
FunctionName: 'aws-serverless-repository-ApplicationCostMonitoring-Publish'
Runtime: python3.6
Handler: handlers/line-item-publisher.handler
CodeUri: s3://%%S3_BUCKET%%/%%S3_DEPLOY_ARTIFACT%%
Description: Ingest an S3 object and publish line items.
MemorySize: 512
Timeout: 300
Policies:
- S3CrudPolicy:
# NOTE: Need to ref the parameter to avoid a circular dependency.
BucketName:
Ref: BillingReportBucketName
- SNSPublishMessagePolicy:
TopicName:
Fn::GetAtt:
- BillingRecordsSnsTopic
- TopicName
- LambdaInvokePolicy:
# NOTE: We can't Ref Stack name when publishing to AppRepo
FunctionName: 'aws-serverless-repository-ApplicationCostMonitoring-Publish'
Environment:
Variables:
LOG_LEVEL: INFO
AWS_SNS_TOPIC:
Ref: BillingRecordsSnsTopic
SCHEMA_CHANGE_HANDLING:
Ref: SchemaChangeHandling
Events:
Event1:
Type: S3
Properties:
Bucket:
Ref: BillingReportS3Bucket
Events: 's3:ObjectCreated:Put'
Filter:
S3Key:
Rules:
- Name: suffix
Value: .gz
Event2:
Type: S3
Properties:
Bucket:
Ref: BillingReportS3Bucket
Events: 's3:ObjectCreated:Put'
Filter:
S3Key:
Rules:
- Name: suffix
Value: .zip
BillingReportS3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName:
Ref: BillingReportBucketName
Outputs:
BillingReportS3BucketName:
Description: Name of S3 Bucket for billing reports.
Value:
Ref: BillingReportS3Bucket
Export:
Name: aws-serverless-repository-ApplicationCostMonitoring-BillingReportS3BucketName
BillingRecordsSnsTopicArn:
Description: SNS topic ARN where billing records are published to.
Value:
Ref: BillingRecordsSnsTopic
Export:
Name: aws-serverless-repository-ApplicationCostMonitoring-BillingRecordsSnsTopicArn
Parameters:
SchemaChangeHandling:
Type: String
Description: Behavior by Publish function on report schema change.
Default: CONTINUE
BillingReportBucketName:
Type: String
Description: Name of S3 bucket AWS Cost and Usage reports are delivered to.