I wrote an IAM service module for ExAws. You can find it on GitHub.
It’s a work in progress, but I think I have the internal API figured out. Currently, the following services are supported:
* CreateAccessKey
* CreateUser
* DeleteAccessKey
* DeleteUser
* GetAccessKeyLastUsed
* GetUser
* ListAccessKeys
* ListUsers
* UpdateAccessKey
* UpdateUser
The API aims to be easy to use. For example:
- You can pass params as atoms and the lib converts them into the AWS IAM query format.
- Each operation has its own parser that translates the XML response into its equivalent map in Elixir.
- Helper functions are available to convert some responses into a data structure.
op = Iam.create_user("my_user", path: "/my/path/")
IO.inspect(op)
%ExAws.Operation.Query{
action: "CreateUser",
params: %{
"Action" => "CreateUser",
"Path" => "/my/path/",
"UserName" => "my_user",
"Version" => "2010-05-08"
},
parser: &ExAws.Iam.Parsers.User.create/2,
path: "/my/path/",
service: :iam
}
user = op |> ExAws.request() |> Iam.to_user()
IO.inspect(user)
%ExAws.Iam.User{
arn: "arn:aws:iam::085326204011:user/my/path/my_user",
create_date: "2018-10-18T15:47:08Z",
path: "/my/path/",
user_id: "AIDAIH3RMDWGIGEXAMPLE",
username: "my_user"
}
Extending the library is straightforward. For example, adding a new operation is as easy as:
def create_group(name, opts \\ []) do
:create_group
|> to_params(opts, [group_name: name])
|> to_op()
end
Iam.create_group("my_group", path: "/my/path/")
You may need to write a parser, and, obviously, some tests, but it’s as easy as that.
I’ve not released the lib yet as I’d like to wait for some feedback before doing so.