Skip to content

Instantly share code, notes, and snippets.

@dobeerman
Created May 8, 2021 06:43
Show Gist options
  • Select an option

  • Save dobeerman/52d092aab24a1bb9c806d4fac617f20e to your computer and use it in GitHub Desktop.

Select an option

Save dobeerman/52d092aab24a1bb9c806d4fac617f20e to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: HTTP API to EventBridge with Custom Domain
Parameters:
DomainName:
Type: String
Description: Domain name for api
Resources:
CustomBus:
Type: AWS::Events::EventBus
Properties:
Name: DemoBus
HttpApi:
Type: AWS::Serverless::HttpApi
Properties:
DefinitionBody:
"Fn::Transform":
Name: "AWS::Include"
Parameters:
Location: "./api.yml"
HttpApiMapping:
Type: AWS::ApiGatewayV2::ApiMapping
Properties:
ApiId: !Ref HttpApi
DomainName: !Ref DomainName
Stage: !Ref HttpApiApiGatewayDefaultStage
ApiMappingKey: !Sub "${AWS::StackName}"
HttpApiRole:
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: !GetAtt CustomBus.Arn
Outputs:
ApiEndpoint:
Description: "Demo HTTP API endpoint URL with Custom domain"
Value: !Sub "https://${DomainName}/${AWS::StackName}/{source}/{detailType}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment