All Projects → freckle → Stratosphere

freckle / Stratosphere

Licence: mit
Haskell EDSL and type-checker for AWS CloudFormation templates

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Stratosphere

Aws Multi Account Viewer
Serverless app designed for any customer with two or more accounts to view resources across accounts/regions in simple single pane of glass website
Stars: ✭ 87 (-42.38%)
Mutual labels:  aws, cloudformation
Serverless static website with basic auth
Builds a serverless infrastructure in AWS for hosting a static website protected with Basic Authentication and published on a subdomain registered via Route 53
Stars: ✭ 112 (-25.83%)
Mutual labels:  aws, cloudformation
Cfer
Toolkit and Ruby DSL for automating infrastructure using AWS CloudFormation
Stars: ✭ 89 (-41.06%)
Mutual labels:  aws, cloudformation
Cloudformation Templates
Common tasks automated by CloudFormation
Stars: ✭ 79 (-47.68%)
Mutual labels:  aws, cloudformation
Cloudformation Cli
The CloudFormation Provider Development Toolkit allows you to author your own resource providers and modules that can be used by CloudFormation.
Stars: ✭ 149 (-1.32%)
Mutual labels:  aws, cloudformation
Perun
A command-line validation tool for AWS Cloud Formation that allows to conquer the cloud faster!
Stars: ✭ 82 (-45.7%)
Mutual labels:  aws, cloudformation
Aws Cloudformation Github Deploy
Deploys AWS CloudFormation Stacks
Stars: ✭ 105 (-30.46%)
Mutual labels:  aws, cloudformation
Awsconsolerecorder
Records actions made in the AWS Management Console and outputs the equivalent CLI/SDK commands and CloudFormation/Terraform templates.
Stars: ✭ 1,152 (+662.91%)
Mutual labels:  aws, cloudformation
Kumogata
Kumogata is a tool for AWS CloudFormation. It can define a template in Ruby DSL.
Stars: ✭ 128 (-15.23%)
Mutual labels:  aws, cloudformation
Cloudformation
Some CF templates
Stars: ✭ 123 (-18.54%)
Mutual labels:  aws, cloudformation
Cfn Sphere
AWS CloudFormation stack management tool
Stars: ✭ 76 (-49.67%)
Mutual labels:  aws, cloudformation
Serverless Dynamodb Autoscaling
Serverless Plugin for Amazon DynamoDB Auto Scaling configuration.
Stars: ✭ 142 (-5.96%)
Mutual labels:  aws, cloudformation
Cform Vscode
CloudFormation extension for Visual Studio Code
Stars: ✭ 73 (-51.66%)
Mutual labels:  aws, cloudformation
Aws Service Catalog Products
This repository contains a number of CloudFormation templates which can be used independently or as Products with AWS Service Catalog including the Open Source Tools AWS Service Catalog Factory and AWS Service Catalog Puppet. The templates include a number of the foundational AWS Services you may choose to manage Account Compliance including AWS Config, AWS CloudTrail and GuardDuty
Stars: ✭ 84 (-44.37%)
Mutual labels:  aws, cloudformation
Sceptre
Build better AWS infrastructure
Stars: ✭ 1,160 (+668.21%)
Mutual labels:  aws, cloudformation
Awesome Aws
A curated list of awesome Amazon Web Services (AWS) libraries, open source repos, guides, blogs, and other resources. Featuring the Fiery Meter of AWSome.
Stars: ✭ 9,895 (+6452.98%)
Mutual labels:  aws, cloudformation
Cfn Create Or Update
Create or update CloudFormation stack also if no updates are to be performed.
Stars: ✭ 59 (-60.93%)
Mutual labels:  aws, cloudformation
Kube Aws
[EOL] A command-line tool to declaratively manage Kubernetes clusters on AWS
Stars: ✭ 1,146 (+658.94%)
Mutual labels:  aws, cloudformation
Cfn Python Lint
CloudFormation Linter
Stars: ✭ 1,770 (+1072.19%)
Mutual labels:  aws, cloudformation
Scar
Deploy static websites in seconds - with HTTPS, a global CDN, and custom domains.
Stars: ✭ 1,715 (+1035.76%)
Mutual labels:  aws, cloudformation

Stratosphere: AWS CloudFormation in Haskell

Circle CI

AWS CloudFormation is a system that provisions and updates Amazon Web Services (AWS) resources based on declarative templates. Common criticisms of CloudFormation include the use of JSON as the template language and limited error-checking, often only available in the form of run-time errors and stack rollbacks. By wrapping templates in Haskell, we are able to easily construct them and help ensure correctness.

The goals of stratosphere are to:

  • Build a Haskell EDSL to specify CloudFormation templates. Since it is embedded in Haskell, it is type-checked and generally much easier to work with than raw JSON.
  • Have a simple checking/linting system outside of the types that can find common errors in templates.
  • Be able to also read valid CloudFormation JSON templates so they can be type-checked. This also gives us free integration tests by using the huge amount of example templates available in the AWS docs.

Example

Here is an example of a Template that creates an EC2 instance, along with the JSON output:

{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Data.ByteString.Lazy.Char8 as B
import Stratosphere

main :: IO ()
main = B.putStrLn $ encodeTemplate instanceTemplate

instanceTemplate :: Template
instanceTemplate =
  template
  [ resource "EC2Instance" (
    EC2InstanceProperties $
    ec2Instance
    & eciImageId ?~ "ami-22111148"
    & eciKeyName ?~ (Ref "KeyName")
    )
    & resourceDeletionPolicy ?~ Retain
  ]
  & templateDescription ?~ "Sample template"
  & templateParameters ?~
  [ parameter "KeyName" "AWS::EC2::KeyPair::KeyName"
    & parameterDescription ?~ "Name of an existing EC2 KeyPair to enable SSH access to the instance"
    & parameterConstraintDescription ?~ "Must be the name of an existing EC2 KeyPair."
  ]
{
  "Description": "Sample template",
  "Parameters": {
    "KeyName": {
      "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
      "ConstraintDescription": "Must be the name of an existing EC2 KeyPair.",
      "Type": "AWS::EC2::KeyPair::KeyName"
    }
  },
  "Resources": {
    "EC2Instance": {
      "DeletionPolicy": "Retain",
      "Type": "AWS::EC2::Instance",
      "Properties": {
        "KeyName": {
          "Ref": "KeyName"
        },
        "ImageId": "ami-22111148"
      }
    }
  }
}

Please see the examples directory for more in-depth examples.

Value Types

CloudFormation resource parameters can be literals (strings, integers, etc), references to another resource or a Parameter, or the result of some function call. We encapsulate all of these possibilities in the Val a type.

We recommend using the OverloadedStrings extension to reduce the number of Literals you have to use.

Lenses

Almost every CloudFormation resource has a handful of required arguments, and many more optional arguments. Each resource is represented as a record type with optional arguments wrapped in Maybe. Each resource also comes with a constructor that accepts required resource parameters as arguments. This allows the user to succinctly specify the resource parameters they actually use without adding too much noise to their code.

To specify optional arguments, we recommend using the lens operators & and ?~. In the example above, the optional EC2 key name is specified using the & and ?~ lens operators.

This approach is very similar to the approach taken by the amazonka library. See this blog post for an explanation.

Auto-generation

All of the resources and resource properties are auto-generated from a JSON schema file and are placed in library-gen/. The gen/ directory contains the auto-generator code and the JSON model file. We include the library-gen/ directory in git so the build process is simplified. To build library-gen from scratch and then build all of stratosphere, just run the very short build.sh script. You can pass stack args to the script too, so run ./build.sh --fast to build the library without optimization. This is useful for development.

In the future, it would be great to not have to include the auto-generated code in git.

Contributing

Feel free to raise any issues, or even just make suggestions, by filing a Github issue.

Future Work

  • Implement basic checker for things like undefined Refs and duplicate field names. This stuff would be too unwieldy to do in types, and performing a checking pass over a template should be pretty straightforward.
  • Use a custom JSON encoder so the templates look a little more idiomatic. We also create a lot of empty whitespace and newlines using aeson-pretty. There are limits on the size of CloudFormation templates, and we want readable output without hitting the limits. Also, we have some newtypes that just exist to override aeson instances, and we could get rid of those.
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].