Setting Up An EC2 Instance With IAM Role And Python Boto SDK



1. We just have to create a ROLE using AWS IAM console as below.



2. Launch  an  instance with that  role(ec2-admin) and that's it . From that instance you can do what ever operation you want like from creating S3 bucket and creating Route53 hosted zone or creating Elastic LoadBalancer  or what ever service you want to call you can do that from that EC-2 instance and most importantly you no need to specify the ACCESS_KEY and SECRET ACCESS_KEY to access the aws services.

3.You just have to install python boto SDK in that  instance and just call s3 service as below using a simple python file i.e. sample.py

#yum install -y python-pip
#pip install boto (or)

git clone git://github.com/boto/boto.git
cd boto
python setup.py install



That's more than enough.
Just create a python file as below and run it as ./

[root@ip-10-0-1-6 boto]# cat sample.py
#! /usr/bin/python
import boto
conn = boto.connect_s3()
bucket = conn.create_bucket('hanumansjan24_2016')

[root@ip-10-0-1-6 boto]#



Just Run it as below S3 bucket named hanumansjan24_2016 has been created.
[root@ip-10-0-1-6 boto]# ./sample.py
[root@ip-10-0-1-6 boto]#  



Comments

Popular posts from this blog

Ansible for Devops

python in liunx

How to check the hardware information in Linux Systems?