Vamsee Krishna
September 5, 2017
Amazon Web services have N number of services, one among them is Aws Identity and Access Management(IAM). IAM allows you to securely access the AWS services.
Using IAM you can control who can use your AWS service and what resources they can use. With IAM, you can create and manage AWS users and groups, and use permissions to allow and deny their access to AWS resources.
We can integrate IAM with many platforms like NodeJS, .NET, Java, etc., Here we can see how to use AWS IAM with the PHP platform.
require '/path/to/aws-autoloader.php';
<?php
$body = array(‘type’ => ‘search’, ‘keyword’ => ‘phones’);
$credentials = new Aws\Credentials\Credentials(‘access_key’, ‘secret_key’);
//From https://github.com/aws/aws-sdk-php/issues/671#issuecomment-120666137
// Prepare a CloudSearchDomain request
$headers = array('x-api-key' => 'api_key, 'Content-Type => application/x-www-form-urlencoded');
$request = new GuzzleHttp\Psr7\Request('POST', 'https://www.knackforge.com/post-endpoint, ['Content-Type' => 'application/x-www-form-urlencoded'], http_build_query($body, null, '&'));
// Construct a request signer
$signer = new Aws\Signature\SignatureV4('execute-api', 'us-west-2');
// Sign the request
$request = $signer->signRequest($request, $credentials);
// Send the request
$headers = array('Content-Type => application/x-www-form-urlencoded');
$client = new \GuzzleHttp\Client([ 'headers' => $headers]);
$response = $client->send($request);
$result = $response->getBody();
Installing Via ZIP
AWS SDK for PHP framework can be downloaded at https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.zip
Install Composer
curl -sS https://getcomposer.org/installer | PHP
Run the Composer command to install the latest stable version of the SDK:
php composer.phar require aws/aws-sdk-php
Require Composer's autoloader:
<?php
require 'vendor/autoload.php';
AWS IAM has lots of features some of which are
Shared access to your AWS account
Granular permissions
Secure access to AWS resources for applications that run on Amazon EC2
Multi-factor authentication (MFA)
Identity federation
Identity information for assurance
Integrated with many AWS services
Free to use
Just like how your fellow techies do.
We'd love to talk about how we can work together
Take control of your AWS cloud costs that enables you to grow!