-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.yml
64 lines (56 loc) · 2.83 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
# This is the SAM template that represents the architecture of your serverless application
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-template-basics.html
# The AWSTemplateFormatVersion identifies the capabilities of the template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/format-version-structure.html
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Receive Pybossa notifications of taskruns completed.
# Transform section specifies one or more macros that AWS CloudFormation uses to process your template
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/transform-section-structure.html
Transform: AWS::Serverless-2016-10-31
# Shared configuration for all resources, more in
# https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
# The PermissionsBoundary allows users to safely develop with their function's permissions constrained
# to their current application. All the functions and roles in this application have to include it and
# it has to be manually updated when you add resources to your application.
# More information in https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html
PermissionsBoundary: !Sub 'arn:${AWS::Partition}:iam::${AWS::AccountId}:policy/${AppId}-${AWS::Region}-PermissionsBoundary'
Parameters:
AppId:
Type: String
# Resources declares the AWS resources that you want to include in the stack
# https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html
Resources:
# Each Lambda function is defined by properties:
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
forwardPybossaWebhook:
Type: AWS::Serverless::Function
Properties:
CodeUri: vdashboard/
Handler: app.lambda_handler
Runtime: python3.8
MemorySize: 128
Timeout: 60
Description: Receive Pybossa notifications of taskruns completed and forward to other services.
Policies:
# Give Create/Read/Update/Delete Permissions to the TaskRunTable
- DynamoDBCrudPolicy:
TableName: !Ref TaskRunTable
Environment:
Variables:
# Make table name accessible as environment variable from function code during execution
TASKRUN_TABLE: !Ref TaskRunTable
# Simple syntax to create a DynamoDB table with a single attribute primary key, more in
# https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlesssimpletable
# DynamoDB table
TaskRunTable:
Type: AWS::Serverless::SimpleTable
Properties:
PrimaryKey:
Name: id
Type: Number
ProvisionedThroughput:
ReadCapacityUnits: 2
WriteCapacityUnits: 2