All Projects → drrb → cfoo

drrb / cfoo

Licence: GPL-3.0 license
CloudFormation master

Programming Languages

ruby
36898 projects - #4 most used programming language
Gherkin
971 projects

Projects that are alternatives of or similar to cfoo

aws-serverless-code-pipeline-cf-template
This solution allows you to use a AWS CloudFormation template to create AWS CodePipeline, and AWS CodeBuild supporting Serverless Framework and GitHub
Stars: ✭ 40 (+81.82%)
Mutual labels:  cloudformation, cloudformation-template
amazon-ivs-simple-chat-web-demo
⚠️ IMPORTANT ⚠️ This repository is no longer actively maintained and will be archived at the end of 2022. A basic live chat implementation built with WebSockets, that can be used in conjunction with Amazon IVS to build compelling customer experiences for live video streams with chat use cases.
Stars: ✭ 53 (+140.91%)
Mutual labels:  cloudformation, cloudformation-template
aws-cloudformation-cognito-identity-pool
A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation
Stars: ✭ 35 (+59.09%)
Mutual labels:  cloudformation, cloudformation-template
VaporShell
A PowerShell module for building, packaging and deploying AWS CloudFormation templates
Stars: ✭ 48 (+118.18%)
Mutual labels:  cloudformation, cloudformation-template
monitoring-jump-start
Monitor AWS resources with ease
Stars: ✭ 67 (+204.55%)
Mutual labels:  cloudformation, cloudformation-template
Aws Cf Templates
A cloudonaut.io project. Engineered by widdix.
Stars: ✭ 2,399 (+10804.55%)
Mutual labels:  cloudformation, cloudformation-template
on-demand
CloudFormation resources for scheduling On-Demand Buildkite Agents with AWS ECS and AWS Fargate
Stars: ✭ 19 (-13.64%)
Mutual labels:  cloudformation-template
bitops
Automate the provisioning and configuration of cloud infrastructure.
Stars: ✭ 28 (+27.27%)
Mutual labels:  cloudformation
sam-scaffold
A template for an AWS SAM project with continuous integration.
Stars: ✭ 80 (+263.64%)
Mutual labels:  cloudformation
aws-batch-example
Example use of AWS batch
Stars: ✭ 96 (+336.36%)
Mutual labels:  cloudformation
aws-autoscaling-gitlab-runner
CloudFormation template to deploy a GitLab Runner with auto-scaling on AWS.
Stars: ✭ 44 (+100%)
Mutual labels:  cloudformation
cfn-deploy
A useful GitHub Action to help you deploy cloudformation templates
Stars: ✭ 14 (-36.36%)
Mutual labels:  cloudformation
cfn-ami-to-mapping
Generate your CloudFormation RegionMap automatically
Stars: ✭ 34 (+54.55%)
Mutual labels:  cloudformation
quickstart-microsoft-sql
AWS Quick Start Team
Stars: ✭ 60 (+172.73%)
Mutual labels:  cloudformation
dokku-aws
One-click Dokku instance on AWS.
Stars: ✭ 53 (+140.91%)
Mutual labels:  cloudformation-template
wolkenkratzer
Javascript library for generating CloudFormation templates
Stars: ✭ 13 (-40.91%)
Mutual labels:  cloudformation
traefik-cluster-ecs
This is a tutorial on how to deploy a Traefik Load Balancer in AWS using CloudFormation to load balancer development ECS tasks using hosts (FQDN).
Stars: ✭ 62 (+181.82%)
Mutual labels:  cloudformation
cfn101-workshop
AWS CloudFormation Workshop
Stars: ✭ 114 (+418.18%)
Mutual labels:  cloudformation
eks-cluster
Quickly spin up an AWS EKS Kubernetes cluster using AWS CloudFormation
Stars: ✭ 41 (+86.36%)
Mutual labels:  cloudformation
cfn-tf-custom-types
CloudFormation Custom Types for Terraform resources.
Stars: ✭ 53 (+140.91%)
Mutual labels:  cloudformation

Cfoo

Build Status Coverage Status Code Climate

Gem Version Dependency Status

Cfoo (pronounced "sifu") lets you write your CloudFormation templates in YAML, and makes it easier with some helpers.

Installation

Cfoo can be installed as a Ruby Gem

$ gem install cfoo

Usage

  1. Write your CloudFormation templates using Cfoo YAML

  2. Turn your Cfoo templates into normal CloudFormation templates

$ cfoo web-server.template.yml database.template.yml > web-stack.template.json
  1. Create your stack with CloudFormation
$ cfn-create-stack --stack-name WebStack -f web-stack.template.json

Templates

Comparison with standard CloudFormation templates

Snippet from a CloudFormation template (based on this example):

"Properties": {
  "ImageId" : { "Fn::FindInMap" : [ "AWSRegion2AMI", { "Ref" : "AWS::Region" }, "AMI" ] },
  "InstanceType"   : { "Ref" : "InstanceType" },
  "SecurityGroups" : [ {"Ref" : "FrontendGroup"} ],
  "KeyName"        : { "Ref" : "KeyName" },
  "UserData"       : { "Fn::Base64" : { "Fn::Join" : ["", [
    "#!/bin/bash -v\n",
    "yum update -y aws-cfn-bootstrap\n",

    "function error_exit\n",
    "{\n",
    "  /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
    "  exit 1\n",
    "}\n",

    "/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackId" }, " -r WebServer ",
    "    --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n",

    "/opt/aws/bin/cfn-signal -e 0 -r \"cfn-init complete\" '", { "Ref" : "WaitHandle" }, "'\n"
  ]]}}
}

Equivalent Cfoo template snippet:

Properties:
  ImageId : AWSRegion2AMI[$(AWS::Region)][AMI]
  InstanceType: $(InstanceType)
  SecurityGroups:
     - $(FrontendGroup)
  KeyName: $(KeyName)
  UserData: !Base64 |
    #!/bin/bash -v
    yum update -y aws-cfn-bootstrap

    function error_exit
    {
      /opt/aws/bin/cfn-signal -e 1 -r "\$1" '$(WaitHandle)'
      exit 1
    }

    /opt/aws/bin/cfn-init -s $(AWS::StackId) -r WebServer --region $(AWS::Region) || error_exit 'Failed to run cfn-init'

    /opt/aws/bin/cfn-signal -e 0 -r "cfn-init completed" '$(WaitHandle)'

Projects

Using Cfoo, it is possible to split your templates up into logical components that will combined to form your CloudFormation template.

First, create a directory in your project directory called modules. For each module, create some Cfoo templates defining the different parts of your app. Your project structure will look like this:

my-web-app
└── modules
    ├── application
    │   ├── app_servers.yml
    │   ├── database.yml
    │   └── public_load_balancer.yml
    ├── instances
    │   └── instance_mappings.yml
    └── network
        ├── bastion.yml
        ├── cfn_user.yml
        ├── dns.yml
        ├── nat.yml
        ├── private_subnet.yml
        ├── public_subnet.yml
        └── vpc.yml

Use Cfoo to generate your project's CloudFormation template

$ cfoo > web-app.template.json

Shortcuts

Cfoo allows you to simplify CloudFormation intrinsic function references using its own shorthand

Reference

CloudFormation: { "Ref" : "InstanceType" }

Cfoo Shortcut: $(InstanceType)

Mapping Reference

CloudFormation: { "FindInMap" : [ "SubnetConfig", "VPC", "CIDR" ] }

Cfoo Shortcut: $(SubnetConfig[VPC][CIDR])

Attribute Reference

CloudFormation: { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }

Cfoo Shortcut: $(Ec2Instance[PublicIp])

Embedded Reference

CloudFormation: { "Fn::Join" : [ "", [{"Ref" : "HostedZone"}, "." ]]}

Cfoo Shortcut: $(HostedZone).

YAML Types

Cfoo gives you the option of using YAML custom data-types where it helps to make your templates easier to read.

Reference

CloudFormation:

{ "Ref" : "InstanceType" }

YAML Type:

!Ref InstanceType
Mapping Reference

CloudFormation:

{ "FindInMap" : [ "SubnetConfig", "VPC", "CIDR" ] }

YAML Type:

!FindInMap [ SubnetConfig, VPC, CIDR ]
Attribute Reference

CloudFormation:

{ "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }

YAML Type:

!GetAtt [ Ec2Instance, PublicIp ]
Base64 String

CloudFormation:

{ "Fn::Base64" : "#!/bin/bash\necho 'Running script...'" }

YAML Type:

!Base64 "#!/bin/bash\necho 'running script...'"

Alternative YAML Type:

!Base64 |
    #!/bin/bash
    echo 'running script...'
Condition Function

CloudFormation:

{ "Fn::Equals": [ "sg-mysggroup", {"Ref": "ASecurityGroup"} ] },

YAML Type:

!Equals [ "sg-mysggroup", $(ASecurityGroup) ]

Goals

Primary Goals

Cfoo aims to let developers simplify CloudFormation templates by:

  • allowing them to write templates in YAML
  • providing an expression language to simplify CF Ref/Attr/etc expressions
  • allowing templates to be split up into logical components (to simplify and share)

Secondary Goals

Cfoo also aims (subject to Primary Goals) to:

  • allow inclusion existing JSON templates (so you don't have to switch all at once)

Non-goals

Cfoo does not (yet) aim to:

  • provide commandline utilities for interacting directly with CloudFormation (it just generates the templates for now)
  • resolve/validate references (the CloudFormation API already does this)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes (with tests please)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request
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].