the AWS Identity and Access Management (IAM) client library for Ruby
Ruby
Switch branches/tags
Latest commit 1274b5f Apr 11, 2011 @juno juno update documents.
Permalink
Failed to load latest commit information.
bin
lib
spec Implement some methods for the login profile. Apr 11, 2011
.gitignore add .rvmrc Apr 11, 2011
History.txt update documents. Apr 11, 2011
LICENSE
README.markdown
Rakefile added activesupport to dependency. Jan 21, 2011
VERSION
stratus.gemspec

README.markdown

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
  • activesupport gem
  • xml-simple gem
  • rest-client gem
  • json_pure or json gem (optionally)

INSTALL:

$ gem install stratus

TESTING:

Currently, spec task only works for RSpec 1.

$ rake spec

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\"}]}"

Create login profile to access AWS Management Console.

>> @iam.create_login_profile(:user_name => 'john', :password => 'new password')
>> result = @iam.get_login_profile(:user_name => 'john')
>> @iam.update_login_profile(:user_name => 'john', :password => 'changed password')
>> @iam.delete_login_profile(:user_name => 'john')

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 software is licensed under the MIT licenses.

COPYRIGHT:

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