Coder Social home page Coder Social logo

loganbussey / aws-cloudfront-segment-proxy Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 3 KB

A simple script to create a Segment Proxy using AWS Cloudfront

License: MIT License

Shell 100.00%
aws aws-cloudformation aws-cloudfront aws-certificate-manager segment proxy

aws-cloudfront-segment-proxy's Introduction

AWS Cloudfront Segment Proxy

On April, 30th 2019, Segment released documentation on how to create a proxy to their service using AWS Cloudfront. This repository features a AWS CloudFormation template which will create the Cloudfront distribution as documented by Segment, and request a free SSL Certificate with a single command.

Prerequisites

Setting up the AWS CLI

You’ll need to have the AWS Command Line Interface installed and configured to connect to your AWS account. On a Mac with Homebrew it's as easy as entering the command:

$ brew install awscli

If you don't have or want to use Homebrew, you’ll need Python 2.6.5 or higher and to install using Pip:

$ pip install awscli

For Windows, download and install the installer from here.

Authenticating with AWS

Enter aws configure at the command line, and then press Enter.

$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

If your AWS account requires Multi-Factor Authentication (MFA), then aws-mfa makes it easy to manage your AWS SDK Security Credentials when MFA is enforced on your AWS account.

Getting Started

  1. Clone this repository
$ mkdir aws-cloudfront-segment-proxy && cd $_
$ git clone https://github.com/loganbussey/aws-cloudfront-segment-proxy.git .
  1. Run setup and follow the prompts:
$ ./setup
This script will help you setup a Cloudfront Distribution for a Segment proxy and request a SSL Certificate for the domains that you choose.

Enter your Segment CDN domain name [ENTER]: cdn.example.com
Enter your Segment tracking API domain name [ENTER]: api.example.com
Which validation method would you like to use for your SSL Certificate?
EMAIL
DNS
Which would you like to use? EMAIL
Enter a CloudFormation stack name [segment-proxy] [ENTER]: my-segment-proxy

Note: If you choose email as the domain validation method, you will need access to the domain administrators inbox to validate the certificate creation. If you choose DNS, then you will need to validate the domain with a CNAME.

To check on the status of the stack creation the following AWS services will be useful:

Next steps

  1. Point your domains to the Cloudfront distributions that were created.

  2. Change cdn.segment.com to your CDN domain in the Analytics.JS snippet.

  3. Contact Segment Support and let them know which domains you used so they can update the apiHost of your code. Alternatively, we've found that you can do this via the load options of the snippet directly on your page. E.g.

analytics.load("yourWriteKey", {
  integrations: {
    "Segment.io": {
      apiHost: "segment.example.com/v1",
    },
  },
});

If you need help setting this up or with your Segment implementation in general, get in touch with us at [email protected], or visit Logan Bussey for more information.

aws-cloudfront-segment-proxy's People

Contributors

lukebussey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.