Kartik it
Kartik it

Reputation: 403

create new user IAM with aws php sdk and limit access of one bucket

i am using aws php sdk for creating bucket in S3
i want to create new user IAM using aws php sdk.. .and then i want to save userkey and acceskey. ..
I got the tutorial for limit the access to user,but not get any for creating new user.
is there any way to create new user?

Upvotes: 1

Views: 1133

Answers (1)

Carlton
Carlton

Reputation: 5721

  1. Install AWS SDK - http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html
  2. Create an Iam client however you like by supplying your AWS credentials. The easiest example to demonstrate is putting the credentials in the PHP file directly - See http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html
  3. Then this example will create a user

<?php

require 'vendor/autoload.php';

$iamClient = \Aws\Iam\IamClient::factory(
    [
        'credentials' => [
            'key'    => 'YOUR_ACCESS_KEY',
            'secret' => 'YOUR_SECRET_KEY'
        ]
    ]
);

$result = $iamClient->createUser(
    [
        // UserName is required
        'UserName' => 'carlton',
        // Optional
        'Path' => '/packager/dev/'
    ]
);

4.Check http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Iam.IamClient.html for all of the methods available on the $iamClient variable we created. A good IDE will provide code completion on $iamClient so you can see available methods that way.

Upvotes: 4

Related Questions