-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
78 lines (74 loc) · 2.23 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
AWSTemplateFormatVersion: 2010-09-09
Description: Should I Wear A Jacket Service
Transform:
- AWS::Serverless-2016-10-31
Parameters:
FaunaDbUrl:
Type: String
FaunaDBSecretKey:
Type: String
NoEcho: true
Resources:
FaunaConnection:
Type: AWS::Events::Connection
Properties:
Name: 'fauna-connection-2'
AuthorizationType: API_KEY
AuthParameters:
ApiKeyAuthParameters:
ApiKeyName: Authorization
ApiKeyValue: !Ref FaunaDBSecretKey
InvocationHttpParameters:
QueryStringParameters:
- IsValueSecret: true
Key: appid
Value: !Ref FaunaDBSecretKey
computeResult:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs20.x
CodeUri: result/
Description: A Lambda function to compute the result based on weather data.
Architectures:
- x86_64
Events:
ApiEvent:
Type: Api
Properties:
Path: /compute
Method: post
ShouldIWearAJacketStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
Type: STANDARD
DefinitionUri: ./workflows/query-global.asl.json
DefinitionSubstitutions:
FaunaDbUrl: !Ref FaunaDbUrl
FaunaConnectionArn: !GetAtt FaunaConnection.Arn
ComputeResultFunctionArn: !GetAtt computeResult.Arn
Policies:
- Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- secretsmanager:DescribeSecret
- secretsmanager:GetSecretValue
Resource: !GetAtt FaunaConnection.SecretArn
- Effect: Allow
Action:
- events:RetrieveConnectionCredentials
Resource: !GetAtt FaunaConnection.Arn
- Effect: Allow
Action:
- states:InvokeHTTPEndpoint
Resource: "*"
Condition:
StringEquals:
states:HTTPMethod: POST
StringLike:
states:HTTPEndpoint: !Ref FaunaDbUrl
- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: !GetAtt computeResult.Arn