Created
April 7, 2014 06:29
-
-
Save viglesiasce/10015630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto | |
| from boto.regioninfo import RegionInfo | |
| from troposphere import Base64, FindInMap, GetAtt | |
| from troposphere import Parameter, Ref, Template | |
| import troposphere.ec2 as ec2 | |
| region = RegionInfo() | |
| region.endpoint = "10.111.5.163" | |
| region.name = "eucalyptus" | |
| stack_name = "vic-test-1" | |
| tester = boto.connect_cloudformation(region=region, port=8773, path="/services/CloudFormation", is_secure=False, | |
| aws_access_key_id="adfasdfsafasdfasfd", | |
| aws_secret_access_key="asdfasfasdfasfasfasfaasfd") | |
| template = Template() | |
| keyname_param = template.add_parameter(Parameter("KeyName", Description="Name of an existing EC2 KeyPair to enable SSH " | |
| "access to the instance", | |
| Type="String",)) | |
| template.add_mapping('RegionMap', {"": {"AMI": "emi-d59af350"}}) | |
| for i in xrange(2): | |
| ec2_instance = template.add_resource(ec2.Instance("Instance{0}".format(i), | |
| ImageId=FindInMap("RegionMap", Ref("AWS::Region"), "AMI"), | |
| InstanceType="t1.micro", KeyName=Ref(keyname_param), | |
| SecurityGroups=["default"], UserData=Base64("80"))) | |
| vol = template.add_resource(ec2.Volume("Volume{0}".format(i), Size="8", | |
| AvailabilityZone=GetAtt("Instance{0}".format(i), "AvailabilityZone"))) | |
| mount = template.add_resource(ec2.VolumeAttachment("MountPt{0}".format(i), InstanceId=Ref("Instance{0}".format(i)), | |
| VolumeId=Ref("Volume{0}".format(i)), Device="/dev/vdc")) | |
| tester.delete_stack(stack_name) | |
| stack = tester.create_stack(stack_name, template.to_json(), parameters=[("KeyName","vic")]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment