Using CloudFormation

This topic describes the Eucalyptus implementation of the AWS CloudFormation web service, how CloudFormation works, and some details and examples of how to add CloudFormation to your Eucalyptus deployment.

Why use CloudFormation?

Cloud computing allows for application repeatability and redundancy. This means that you can spin up as many virtual machines as you need, but the application configuration only needs to happen when the images are created. CloudFormation takes this concept to the next level: it allows you to configure an entire set of resources (instances, security groups, user roles and policies, and more) in a single template. Then you can create a stack of all those resources from the template using a single command. So, you don’t just get machine repeatability, you get environment repeatability. CloudFormation allows you to clone environments in different cloud setups, as well as giving applications the ability to be set up and torn down in a repeatable manner.

How does CloudFormation Work?

CloudFormation manages a set of resources, called a stack, in batch operations (create, update, or delete). Stacks are described in templates, which can be simple, as the following example:

Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: emi-371ada125a928669e

This stack creates a single instance, based on the image with ID emi-371ada125a928669e. However, this stack is not portable because different clouds might have different image IDs.

CloudFormation allows stack customization through user parameters that are passed in at stack creation time. The following is an example of the template above with a user parameter called MyImageId.

Parameters:
  MyImageId:
    Description: Image id
    Type: String
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: !Ref MyImageId

This stack creates a single instance, but the image ID will be required to be passed in using the command line. For example, the following example uses the euform-create-stack command in Euca2ools:

euform-create-stack --template-file template.yaml -p MyImageId=emi-371ada125a928669e MyStack

or using the AWS CLI:

aws cloudformation create-stack --template-body file://template.yaml --parameters ParameterKey=MyImageId,ParameterValue=emi-371ada125a928669e --stack-name MyStack

These example commands pass the parameter MyImageId with value emi-371ada125a928669e into the stack creation process.

You can also use templates to create multiple resources and associate them with each other. For example, the following template creates an instance with its own security group and ingress rule.

Parameters:
  MyImageId:
    Description: Image id
    Type: String
Resources:
  MySecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Security Group with Ingress Rule for MyInstance
      SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: '22'
          ToPort: '22'
          CidrIp: '0.0.0.0/0'
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: !Ref 'MyImageId'
      SecurityGroups:
        - !Ref 'MySecurityGroup'

Templates can be more complicated than the ones shown above, but CloudFormation allows many resources to be deployed in one operation. Resources from most Eucalyptus services are supported.

CloudFormation Requirements

To run CloudFormation on Eucalyptus, you need the following:

  • A running Eucalyptus cloud, version 4.0 or later, with at least one Cloud Controller, Node Controller, and Cluster Controller up, running and registered
  • At least one active running service of each of the following: CloudWatch, AutoScaling, Load Balancing, Compute, and IAM
  • A registered active CloudFormation service

Supported Resources

The following resources are supported by CloudFormation in Eucalyptus.

ResourceDescription
AWS::AutoScaling::AutoScalingGroupAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except: HealthCheckType.
AWS::AutoScaling::LaunchConfigurationAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except AssociatePublicIpAddress.
AWS::AutoScaling::ScalingPolicyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::CloudFormation::StackAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::CloudFormation::WaitConditionAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::CloudFormation::WaitConditionHandle.All properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::CloudWatch::AlarmAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::CustomerGatewayAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::DHCPOptionsAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::EIPAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::EIPAssociationAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except: PrivateIpAddress.
AWS::EC2::InstanceAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except: SourceDestCheck, Tags, and Tenancy.
AWS::EC2::InternetGatewayAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::LaunchTemplateAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::NatGatewayAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::NetworkAclAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::NetworkAclEntryAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::NetworkInterfaceAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::NetworkInterfaceAttachmentAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::RouteAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::RouteTableAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::SecurityGroupAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::SecurityGroupEgressAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::SecurityGroupIngressAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except SourceSecurityGroupId.
AWS::EC2::SubnetAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::SubnetNetworkAclAssociationAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::SubnetRouteTableAssociationAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::VolumeAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except: HealthCheckType and Tags.
AWS::EC2::VolumeAttachmentAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::VPCAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::VPCDHCPOptionsAssociationAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::EC2::VPCGatewayAttachmentAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::ElasticLoadBalancing::LoadBalancerAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except: AccessLoggingPolicy, ConnectionDrainingPolicy, CrossZone, Policies.InstancePorts, and Policies.LoadBalanerPorts. All other properties are passed through to the LoadBalancing service internally but some features are not implemented so properties may be ignored there.
AWS::IAM::AccessKeyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported except Serial.
AWS::IAM::GroupAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::InstanceProfileAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::ManagedPolicyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::PolicyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::RoleAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::UserAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::IAM::UserToGroupAdditionAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::Route53::HostedZoneAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::Route53::RecordSetAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::Route53::RecordSetGroupAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::S3::BucketAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::S3::BucketPolicyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::SQS::QueueAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.
AWS::SQS::QueuePolicyAll properties in the Template Reference section of the AWS CloudFormation User Guide are supported.

CloudFormation Endpoint

The service endpoint for CloudFormation is of the form:

http://cloudformation.mycloud.example.com:8773/

If DNS is not availble for your cloud, then an endpoint with a service path can be used:

http://<host-ip>:8773/services/CloudFormation

CloudFormation follows the same convention as the other user facing services.