Skip to main content

Easy and powerful stack templates for AWS CloudFormation

Project description

CloudCast - Easy and powerful stack templates for AWS CloudFormation
====================================================================

What is it?
-----------

AWS CloudFormation is pretty powerful, but once your stacks are getting
sophisticated, it can be hard to work with. You may easily get
lost in a sea of maps and lists, and it can be hard to keep track of
references across your resources.

Also, this may be my personal pet peeve, but JSON has no syntax for comments!
This makes templates written for CFN hard to document and maintain.

With CloudCast you can easily create any template you would write for CFN, but
using plain Python syntax.

Resources, Mappings, Parameters and Outputs are defined as Python objects. It
looks cleaner and you can do smarter stuff with them!

For instance:

from cloudcast.template import Resource

LoadBalancer = Resource(
"AWS::ElasticLoadBalancing::LoadBalancer",
AvailabilityZones=[ 'us-east-1c', 'us-east-1d' ],
HealthCheck={
"HealthyThreshold" : "2",
"Interval" : "30",
"Target" : "HTTP:80/status",
"Timeout" : "5",
"UnhealthyThreshold" : "3"
},
Listeners=[{
"InstancePort" : "80",
"InstanceProtocol" : 'HTTP',
"LoadBalancerPort" : "80",
"Protocol" : 'HTTP',
}]
),
)

If you are familiar with AWS and CFN, this structure shouldn't be strange to you.
We have just declared an ELB resource with some properties.

Later on, the load balancer may be referenced from a security group, in order to
be allowed to access the service ports in the balanced instances:

AppSG = Resource(
"AWS::EC2::SecurityGroup",
GroupDescription = "Allow access app from LB only",
SecurityGroupIngress = [ {
"IpProtocol" : "tcp",
"FromPort" : 80,
"ToPort" : 80,
"SourceSecurityGroupOwnerId" : LoadBalancer['SourceSecurityGroup.OwnerAlias'],
"SourceSecurityGroupName": LoadBalancer['SourceSecurityGroup.GroupName'],
}]
)

Since you are dealing with Python objects, nothing is stopping you from
bundling them in your own libraries and reusing them as necessary. We have
an example of that around here (look at the cloudcast.library.stack_user module).

In fact, you can create any Python code that may help you making your
templates simpler and more expressive!

How do you get the JSON templates?
----------------------------------

Once you've got your template python file (let's call it template.py), you would:

from cloudcast import Stack
stack = Stack(
description = "Sample stack that doesn't do much",
env = { ... define environment vars here ... },
resources_file = "template.py"
)
print stack.dump_json()

The following will happen:

1. The Stack class will load, examine your code module and find
the relevant objects to be included in the CloudFormation template (resources,
outputs, parameters..). It shouldn't get confused with any other code you
may have there.
2. The template will be printed out for you to feed into CloudFormation.

Special thanks
--------------

[Bright & Shiny](http://brightandshiny.com/) - their support and fine
understanding of well managed infrastructure, made it possible for me to
devote the necessary efforts to evolve this concept.

If you are looking for an awesome software agency make sure to check their
website!

[Lifestreams Technology](http://lifestreams.com/) - developing for their
products has proved to be an excellent ground to develop and put into
practice new ideas such as the one that originated this project. Thanks
for the chance to bring CloudCast to the point where it is a key technology
to support mission-critical operations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudcast-0.0.4.tar.gz (12.3 kB view details)

Uploaded Source

File details

Details for the file cloudcast-0.0.4.tar.gz.

File metadata

  • Download URL: cloudcast-0.0.4.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for cloudcast-0.0.4.tar.gz
Algorithm Hash digest
SHA256 5924025e750d897b01cb2c5ee7bb78f8eb8c56d0afa7655eb2cbf7d8e80d2a5a
MD5 93be04b1483977c7b46557ae22333a03
BLAKE2b-256 ab88e1987f32835f15c2b3d764638f421088dbf30faa69a87070cf0ed287b8e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page