Skip to content

Instantly share code, notes, and snippets.

@buggy
Created October 11, 2019 08:01
Show Gist options
  • Save buggy/b4d441e115a8620e81576622c247a0fb to your computer and use it in GitHub Desktop.
Save buggy/b4d441e115a8620e81576622c247a0fb to your computer and use it in GitHub Desktop.
API Gateway Proxy AppSync
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: SAM Template for API Gateway Proxy AppSync
Parameters:
DomainName:
Type: String
Stage:
Type: String
Default: dev
Resources:
ApiGw:
Type: AWS::Serverless::Api
Properties:
StageName: !Ref Stage
DefinitionBody:
openapi: "3.0.0"
info:
version: 1.0.0
title: MyApi
description: My API
servers:
- url: https://api.example.com
paths:
/graphql:
"x-amazon-apigateway-any-method":
summary: "GraphQL Proxy"
operationId: graphQL
x-amazon-apigateway-integration:
uri: https://mlsc6sxsmfdwteejduazc7dqs4.appsync-api.ap-southeast-2.amazonaws.com/graphql
passthroughBehavior: when_no_match
httpMethod: ANY
type: http_proxy
components:
responses:
Options:
description: Default response for CORS method
headers:
Access-Control-Allow-Headers:
type: "string"
Access-Control-Allow-Methods:
type: "string"
Access-Control-Allow-Origin:
type: "string"
EndpointConfiguration: REGIONAL
ApiGwCertificate:
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: !Ref DomainName
ValidationMethod: DNS
ApiGwDomainName:
Type: AWS::ApiGateway::DomainName
DependsOn:
- ApiGwCertificate
Properties:
DomainName: !Ref DomainName
EndpointConfiguration:
Types:
- REGIONAL
RegionalCertificateArn: !Ref ApiGwCertificate
ApiGwBasePathMapping:
Type: AWS::ApiGateway::BasePathMapping
DependsOn:
- ApiGwDomainName
- ApiGw
Properties:
DomainName: !Ref DomainName
RestApiId: !Ref ApiGw
Stage: !Ref Stage
ApiGatewayIamRole:
Properties:
AssumeRolePolicyDocument:
Statement:
-
Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- apigateway.amazonaws.com
Version: '2012-10-17'
Path: /
Policies:
-
PolicyDocument:
Statement:
-
Action:
- iam:PassRole
Effect: Allow
Resource: '*'
PolicyName: PermitApiGateway
Type: AWS::IAM::Role
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment