forked from aws-samples/serverless-patterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
64 lines (60 loc) · 1.81 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: API Gateway HTTP API to EventBridge (uksb-1tthgi812) (tag:apigw-http-api-eventbridge-java)
Resources:
# Creates an HTTP API endpoint
MyHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
DefinitionBody:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: './api.yaml'
# Create the role for API Gateway access to EventBridge
MyHttpApiRole:
Type: "AWS::IAM::Role"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: "Allow"
Principal:
Service: "apigateway.amazonaws.com"
Action:
- "sts:AssumeRole"
Policies:
- PolicyName: ApiDirectWriteEventBridge
PolicyDocument:
Version: '2012-10-17'
Statement:
Action:
- events:PutEvents
Effect: Allow
Resource:
- !Sub arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/default
# Lambda function invoked from EventBridge
MyTriggeredLambda:
Type: AWS::Serverless::Function
Properties:
CodeUri: TriggeredLambda/
Handler: com.example.App::handleRequest
Runtime: java11
Architectures:
- x86_64
Timeout: 30
MemorySize: 512
Environment:
Variables:
JAVA_TOOL_OPTIONS: -XX:+TieredCompilation -XX:TieredStopAtLevel=1
Events:
EventBridgeTrigger:
Type: EventBridgeRule
Properties:
Pattern:
source:
- "WebApp"
Outputs:
ApiEndpoint:
Description: "HTTP API endpoint URL"
Value: !Sub "https://${MyHttpApi}.execute-api.${AWS::Region}.amazonaws.com"