Skip to content

the AWS Identity and Access Management (IAM) client library for Ruby

License

Notifications You must be signed in to change notification settings

pjsawicki/stratus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stratus

Stratus is a client interface for the AWS Identity and Access Management (IAM) Services.

It was developed to for usage in the Japanese AWS management console service Cloudworks.

REQUIREMENTS:

  • Ruby 1.8.7 or 1.9.2
  • xml-simple and rest-client gems
  • json_pure or json gem (optionally)

INSTALL:

gem install stratus

USAGE EXAMPLE

As interactive shell

You can run interactive shell `iamsh' and call IAM API.

$ export AMAZON_ACCESS_KEY_ID=XXXXX
$ export AMAZON_SECRET_ACCESS_KEY=XXXXX
$ iamsh

    @iam defined.

    Examples to try:

      returns : all iam public methods
      >> @iam.methods.sort

      returns : get all Amazon IAM groups.
      >> @iam.list_groups

Welcome to IRB.
>>

Create a new IAM user by CreateUser API.

>> @iam.create_user :user_name => 'john'
>> result = @iam.list_users
>> puts result['ListUsersResult']['Users']['member'].inspect
[{"UserName"=>"john", "Arn"=>"arn:aws:iam::000000000000:user/john", "Path"=>"/", "UserId"=>"XXXXXXXXXXXXXXXXXXXX"}]

Then create an user policy JSON string.

>> policy = {}
>> policy['Statement'] = [{
  'Effect' => 'Allow',
  'Action' => 'ec2:Describe*',
  'Resource' => '*'
}]
>> require 'json'
>> policy = policy.to_json

And put it by PutUserPolicy API.

>> @iam.put_user_policy :user_name => 'john', :policy_name => 'AllowDescribeEC2', :policy_document => policy
>> result = @iam.get_user_policy :user_name => 'john', :policy_name => 'AllowDescribeEC2'
>> result['GetUserPolicyResult']['PolicyDocument']
"{\"Statement\":[{\"Action\":\"ec2:Describe*\",\"Resource\":\"*\",\"Effect\":\"Allow\"}]}"

Delete an user policy and user.

>> @iam.delete_user_policy :user_name => 'john', :policy_name => 'AllowDescribeEC2'
>> @iam.delete_user :user_name => 'john'

As library

You can require the library and call IAM API from any ruby script.

require 'rubygems'
require 'stratus'

iam = Stratus::AWS::IAM::Base.new('YOUR_ACCESS_KEY_ID', 'YOUR_SECRET_ACCESS_KEY')
result = iam.create_group :group_name => 'Developers'
group = result['CreateGroupResult']['Group']
puts "Group ARN is #{group['Arn']}"

Read the IAM API Reference for further information.

REFERENCES:

LICENSE:

This plugin is licensed under the MIT licenses.

COPYRIGHT:

Copyright (c) 2010 Serverworks Co.,Ltd. See LICENSE for details.

About

the AWS Identity and Access Management (IAM) client library for Ruby

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%