All Projects → jed → cfn-api-gateway-custom-domain

jed / cfn-api-gateway-custom-domain

Licence: MIT License
API Gateway custom domains as CloudFormation resources, backed by Let's Encrypt

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to cfn-api-gateway-custom-domain

Aws Cognito Apigw Angular Auth
A simple/sample AngularV4-based web app that demonstrates different API authentication options using Amazon Cognito and API Gateway with an AWS Lambda and Amazon DynamoDB backend that stores user details in a complete end to end Serverless fashion.
Stars: ✭ 278 (+1535.29%)
Mutual labels:  cloudformation, aws-lambda, api-gateway
acme2
Another PHP client for acme protocal (version 2) implementation, used for generating letsencrypt's free ssl certificates.
Stars: ✭ 45 (+164.71%)
Mutual labels:  letsencrypt, ssl
go-localstack
Go Wrapper for using localstack
Stars: ✭ 56 (+229.41%)
Mutual labels:  route53, cloudformation
cim
CIM takes the pain out of Infrastructure as Code and CloudFormation
Stars: ✭ 51 (+200%)
Mutual labels:  cloudformation, api-gateway
LeSslCertToAzure
Powershell Module that creates a SSL/TLS Certificate with Let's Encrypt Service and apply to an Azure Application Gateway.
Stars: ✭ 14 (-17.65%)
Mutual labels:  letsencrypt, ssl
httpsify
a transparent HTTPS termination proxy using letsencrypt with auto certification renewal
Stars: ✭ 107 (+529.41%)
Mutual labels:  letsencrypt, ssl
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (+76.47%)
Mutual labels:  aws-lambda, api-gateway
qiniu-auto-cert
七牛 CDN 证书自动化工具
Stars: ✭ 20 (+17.65%)
Mutual labels:  letsencrypt, ssl
mediastack
All in one Docker Compose media server
Stars: ✭ 42 (+147.06%)
Mutual labels:  letsencrypt, ssl
shim
HTTP Handler shim for Go projects running on AWS Lambda
Stars: ✭ 64 (+276.47%)
Mutual labels:  aws-lambda, api-gateway
whats-your-name
Sample app for AWS Serverless Repository - uses Amazon Rekognition to recognize person on the photo
Stars: ✭ 17 (+0%)
Mutual labels:  cloudformation, aws-lambda
MySB
MySB (MySeedBox) is more than a simplified installation script of a multi-users Seedbox. There are many solutions to install a Seedbox, but we never talk about safety and regular operations. MySB could be renamed MySSB (MySecuredSeedBox).
Stars: ✭ 105 (+517.65%)
Mutual labels:  letsencrypt, ssl
certbot-dns-loopia
Loopia DNS authentication plugin for Certbot
Stars: ✭ 28 (+64.71%)
Mutual labels:  letsencrypt, ssl
httpsbook
《深入浅出HTTPS:从原理到实战》代码示例、勘误、反馈、讨论
Stars: ✭ 77 (+352.94%)
Mutual labels:  letsencrypt, ssl
AzureWebAppSSLManager
Acquires and manages free SSL certificates for Azure Web App and Azure Functions applications.
Stars: ✭ 70 (+311.76%)
Mutual labels:  letsencrypt, ssl
Hands-On-Serverless-Applications-with-Go
Hands-On Serverless Applications with Go, published by Packt.
Stars: ✭ 92 (+441.18%)
Mutual labels:  cloudformation, api-gateway
mangum-cli
CLI tools for use with Mangum
Stars: ✭ 14 (-17.65%)
Mutual labels:  aws-lambda, api-gateway
Acme Nginx
python acme client for nginx
Stars: ✭ 248 (+1358.82%)
Mutual labels:  letsencrypt, ssl
docker-ssl-reverse-proxy
Easy-to-use auto-SSL reverse proxy as a Docker container based on Caddy and Let’s Encrypt
Stars: ✭ 22 (+29.41%)
Mutual labels:  letsencrypt, ssl
docker-nginx-certbot
Automatically create and renew website certificates for free using the Let's Encrypt certificate authority.
Stars: ✭ 367 (+2058.82%)
Mutual labels:  letsencrypt, ssl

cfn-api-gateway-custom-domain

[Ed note: in an amazing turn of events, this library was released mere hours before AWS basically made it obsolete.]

This is a CloudFormation custom resource for API Gateway custom domains. It runs Certbot on Lambda to create certificates, and automatically creates Route53 DNS records to respond to Let's Encrypt domain ownership challenges.

It's basically a prollyfill for the conspicuously missing AWS::ApiGateway::DomainName resource type, which will likely land if/when AWS Certificate Manager supports API Gateway.

If you need to renew your certificates or would like to just use Route53 to create Let's Encrypt certificates, check out certbot-route53.sh.

Features

  • Fast: Certificates are installed and enabled in minutes
  • Free: Certificates cost nothing (but you can donate)
  • Easy: Certificates need only 14 lines in a CloudFormation template
  • Safe: Certificates never touch your email or machine

Setup

Before you get started, you'll need to:

  1. create a Route53 public hosted zone for the domain, and
  2. point the domain at your zone's nameservers.

Since Let's Encrypt needs to be able to contact Route53, your DNS settings must be in effect already.

Usage

  1. First, make sure you have a AWS::Route53::HostedZone in the Resources section of your template:

      MyHostedZone:
        Type: AWS::Route53::HostedZone
        Properties:
          Name: jedschmidt.com
  2. Then, add an API Gateway Custom Domain stack to your template:

      ApiGatewayCustomDomain:
        Type: AWS::CloudFormation::Stack
        Properties:
          TemplateURL: https://s3.amazonaws.com/api-gateway-custom-domain/stack.template
          Parameters:
            LetsEncryptAccountEmail: [email protected]
            LetsEncryptAgreeTOS: Yes
            LetsEncryptManualPublicIpLoggingOk: Yes

    You'll need to specify three things:

    • LetsEncryptAccountEmail: The email address associated with your Let's Encrypt account
    • LetsEncryptAgreeTOS: That you agree to the Let's Encrypt Terms of Service. This must be Yes.
    • LetsEncryptManualPublicIpLoggingOk: That you're okay with Let's Encrypt logging the IP address of the Lambda used to run certbot. This must be Yes.

    This stack has only one output: ServiceToken. This can be accessed using !GetAtt {your-logical-stack-name}.Outputs.ServiceToken.

  3. Finally, add a custom domain to your template:

      MyDomain:
        Type: Custom::ApiGatewayCustomDomain
        Properties:
          ServiceToken: !GetAtt ApiGatewayCustomDomain.Outputs.ServiceToken
          HostedZoneId: !Ref MyHostedZone
          Subdomain: www

    You'll need to specify two things:

    • Service Token: The Service token output by your API Gateway Custom Domain stack
    • HostedZoneId: A reference to the existing AWS::Route53::HostedZone resource for which you're creating a certificate.

    You can also optionally specify:

    • Subdomain: The subdomain prefix for which you're creating a certificate, such as www. This is concatenated with the Name of the hosted zone, to create the full domain name. If this is omitted, the bare apex domain is used.

    This resource returns the results of the createDomainName function.

At this point, you've done all you need to create/update/deploy your stack and get your certificate installed into API Gateway, but to user the domain you'll need to add an alias DNS record that resolves your domain to the CloudFront distribution created with your custom domain name, and then map the domain to a stage of your rest API:

  MyDNSRecord:
    Type: AWS::Route53::RecordSetGroup
    Properties:
      HostedZoneId: !Ref MyHostedZone
      RecordSets:
      - Type: A
        Name: !GetAtt MyDomain.domainName
        AliasTarget:
          HostedZoneId: Z2FDTNDATAQYW2 # (hardcoded for all CloudFormation templates)
          DNSName: !GetAtt MyDomain.distributionDomainName

  MyPathMapping:
    Type: AWS::ApiGateway::BasePathMapping
    Properties:
      DomainName: !GetAtt MyDomain.domainName
      RestApiId: !Ref MyRestAPI
      Stage: prod

Example

See the included example for a simple website redirect app configured entirely with CloudFormation.

How it works

When a custom domain name is first created in your stack, CloudFormation calls a node.js function in a Lambda-backed custom resource, which in turn launches Certbot in a Python subprocess. Certbot then contacts Let's Encrypt to get a challenge string, which is placed in a TXT record on Route53. Once the record is live, Certbot tells Let's Encrypt to verify it, and once it's verified, Let's Encrypt sends the certificate back to Certbot and then to API Gateway, where it's used to create a custom domain.

Todo

Thanks

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].