GrantBirki / fastly-framework

⏰ Fastly Framework - A Framework for Using Fastly with Terraform, Automation, and CICD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fastly-framework

A Framework for Using Fastly with Terraform, Automation, and CICD

About 💡

This project is an open source framework for creating a CICD pipeline with Terraform that builds Fastly services.

The CICD framework portion was created using GitLab-CI but it can be adapted to run with GitHub actions, CircleCI, and others.

Benefits:

  • Using Git as a version control system for all Fastly changes
  • Eliminate code reuse through shared VCL files, Snippets, and Terraform configuration blocks
  • Test your services through a CICD pipeline before deploying them
  • Integrate with chatops for deployments (Example: Slack)
  • Quickly create new services from templates with make service - Using Jinja and Python
  • Adopt Infrastructure as Code methodologies with Terraform
  • Create your own pipeline stages for robust testing, alerts, approval, and much more

Documentation 📚

Table of Contents

Here is the table of contents for the documentation folder. See below for other doc links.

New to Fastly? The Getting Started doc is your place to start.

View the following documents for specific details around each subject:

  • getting-started - The best place for newcomers
  • learning - A guide for learning all things Fastly
  • fastly-to-insights - Aggregated metrics collection from Fastly to New Relic
  • new-service - A guide for creating a new service in Fastly using this repo
  • pipeline - General Pipeline framework information
  • rapid-rollback - Information about the rapid-rollback stage of the pipeline
  • slack - For setting up Slack integrations with this pipeline
  • terraform-reference - How to use common Terraform blocks to configure your Fastly service
  • vcl-include-and-snippets - Details about VCL include statements vs snippets. This guide has examples about how to use both and the key differences between them.

Additional Documentation

The following links are to other doc pages and READMEs in this repo that are not in this specific folder.

Demos

The following section will show screenshots and details for a demo pipeline deployment to Fastly.

1. Create a Merge Request

To kick off the pipeline, create a merge request with your changes. This demo will make changes to a nonprod and prod service as an example.

2. ChatOps Notification

Once your pipeline starts running, check Slack (or other messaging service if configured) for a notification that your MR has been created and the pipeline is now running.

cdn-bot-mr

3. Merge Request Pipeline

Check out your merge request pipeline to see how its doing. It will plan your changes with Terraform, test them with self configured tests, and then create an approval for deployment.

Note: TFsec will not be covered in this framework for simplicity. However, it is very easy to add on your own.

dev-and-prod-pipeline

If you have the slack integration configured with servicenow you will recieve an alert like the one below for approval requests:

fastly-ci-approval

4. Merge Changes

Once your merge request pipeline passes you are free to merge your changes to the main or master branch. This will trigger the deployment pipeline!

5. Deployment Pipeline

This pipeline is triggered from a successful merge to main/master branches. The deploy stage is a manual action so you may deploy nonprod first to validate changes before deploying to prod. The rapid-rollback stage exists to revert your changes if something goes wrong.

dev-and-prod-deploy-pipeline

If you have the slack integration configured you will recieve notification about successful deployments in Slack like the one below:

fastly-ci-activation

6. Deployed to Fastly

Hooray! Your change has been successfully deployed to Fastly!

fastly-new-version

7. Rapid-Rollback

If something goes wildly wrong you can always rollback your changes via the rapid-rollback stage. Doing so will revert to the last active version in Fastly.

If you have the slack integration configured you will recieve a notification like the one below:

fastly-ci-rollback

Large Job Support

The demo section above just shows two services running through the pipeline: nonprod and prod for example. However, the pipeline can support hundreds of concurrent jobs and for many services at once.

The example below shows many jobs running at once. They had testing errors so they failed and hence haulted the pipeline from continuing.

fastly-multiple-jobs

Contributing

You are welcome to send pull requests to this repo. All and any contributors are welcome.

About

⏰ Fastly Framework - A Framework for Using Fastly with Terraform, Automation, and CICD

License:GNU General Public License v3.0


Languages

Language:HCL 36.2%Language:Python 35.7%Language:Shell 17.9%Language:VCL 9.4%Language:Dockerfile 0.7%Language:Makefile 0.1%