AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: API Gateway HTTP API to EventBridge 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"