With AWS AppSync, it’s easy to run your own serverless GraphQL service API. Thanks to Velocity Mapping Templates, DynamoDB, and AWS Lambda your can aim for an architecture without any maintenance at all.
Getting started with AppSync is not that problem; there are tons of guides and frameworks. AWS has a nice guide to add a custom domain to your API using CloudFront as well. But how do you configure a custom domain using Route 53, AWS Certificate Manager, and AppSync in a CloudFormation Template? Here’s the answer:
AWSTemplateFormatVersion: "2010-09-09" Resources: HostedZone: Type: AWS::Route53::HostedZone Properties: Name: api.example.com Certificate: Type: AWS::CertificateManager::Certificate DependsOn: HostedZone Properties: DomainName: api.example.com ValidationMethod: DNS Distribution: Type: AWS::CloudFront::Distribution Properties: DistributionConfig: Enabled: true HttpVersion: http2 Origins: - DomainName: !Ref AppSyncHostname Id: !Ref AppSyncHostname CustomOriginConfig: HTTPPort: 80 HTTPSPort: 443 OriginKeepaliveTimeout: 5 OriginReadTimeout: 30 OriginProtocolPolicy: https-only OriginSSLProtocols: [ TLSv1, TLSv1.1, TLSv1.2 ] Aliases: [ api.example.com ] DefaultCacheBehavior: AllowedMethods: [ HEAD, DELETE, POST, GET, OPTIONS, PUT, PATCH ] ForwardedValues: QueryString: false SmoothStreaming: false Compress: true TargetOriginId: !Ref AppSyncHostname ViewerProtocolPolicy: redirect-to-https PriceClass: PriceClass_100 ViewerCertificate: SslSupportMethod: sni-only MinimumProtocolVersion: TLSv1.1_2016 AcmCertificateArn: !Ref Certificate DNS: Type: AWS::Route53::RecordSetGroup Properties: HostedZoneName: api.example.com RecordSets: - Name: api.example.com Type: A AliasTarget: HostedZoneId: Z2FDTNDATAQYW2 DNSName: !GetAtt Distribution.DomainName Parameters: AppSyncHostname: Type: String
After creating your AppSync API, you will end up with a random subdomain for an AWS service. Of course, you want to configure a custom and branded domain for your AppSync GraphQL endpoint. Use the CloudFormation snippet above, provide the hostname of your GraphQL service and use your AppSync API with a custom hostname.
Important: You need to deploy this CloudFormation Stack to
us-east-1 region! But you can deploy the AWS AppSync GraphQL API to any AWS region.
You can find correlations in most things if you just look close enough: The more projects you work on, the more streamlined your tooling gets. Hopefully. Various services using different languages have different tooling requirements, of course. A sweet Makefile can be the entry to a unified tooling interface.263 words, posted on April 15
Let me be honest with you: GraphQL is the shit! Once you use GraphQL, you will never want to use anything else again. The same is true for a working and maintainable serverless FaaS infrastructure. Combine both technologies to run a genuinely serverless GraphQL API using AWS AppSync and Lambda resolvers.2104 words, posted on June 17
Amazon recently announced CloudFormation support for AppSync and all its features. Together with the Serverless Application Model it’s now dead simple to deploy a GraphQL API and custom Lambda resolvers without using the API at all. The GraphQL RSS Proxy example project is a serverless GraphQL API using AppSync, with an AWS Lambda function as a custom Query Resolver writting in Go.1135 words, posted on May 30