My First troposphere code to create instance (sample)

Below is the troposphere library which is used to convert the python script to json and yaml formats which avoids writing of clouformation 🙂

 

from troposphere import Ref, Template
import troposphere.ec2 as ec2
t = Template()
instance = ec2.Instance(“myinstance”)
instance.ImageId = “ami-951945d0”
instance.InstanceType = “t1.micro”
t.add_resource(instance)
with open(‘jaml.yaml’, ‘w’) as f:    // command to create a output file and write to it
f.write(t.to_yaml())
with open (‘insta.json’, ‘w’)as f:
f.write(t.to_yaml())

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s