[Amazon S3 Connector] Using IAM user temporary credentials
Question
Forge component by Guilherme Pereira

Hi everyone, 


I would like to ask help on how to use temporary credential from AWS

Making requests using IAM user temporary credentials - Amazon Simple Storage Service 


Anyone had a chance to create something like this before? I really appreciate any sample demo or extension. 


Thanks,

Jeff

Hi Jeff,

You may modify this plugin using Integration Studio. Add a new field in the S3_AuthenticationInfo Structure for the session token.

After you publish it, modify the source code.
First thing you need to do is to install the needed package using Nuget Manager and install awssdk.securitytoken

Then, modify the AmazonS3.cs Login function to receive and set the sessiontoken parameter.

public void Login(string pInAwsAccessKeyId, string pInAwsSecretAccessKey, string pInAwsSessionKey, string region)

        {

            //Create credential object

            _amazonS3Credentials = new AmazonS3Credentials();

            _amazonS3Credentials.AwsAccessKeyId = pInAwsAccessKeyId;

            _amazonS3Credentials.AwsSecretAccessKey = pInAwsSecretAccessKey;

            _amazonS3Credentials.AwsSessionKey = pInAwsSessionKey;


            try

            {

                _amazonS3Credentials.AwsRegion = (RegionEndpoint)typeof(RegionEndpoint).GetField(region).GetValue(null); ;

            }

            catch (Exception)

            {

                throw new ArgumentException(string.Format("Invalid region {0}", region));

            }

        }

Then Modify the private function GetClient()

private AmazonS3Client GetClient()

        {

            //Check c

            if (_amazonS3Credentials == null)

            {

                throw (new ArgumentException("Amazon S3 credentials are not properly defined."));

            }


            //Create amazon client

            AmazonS3Config amazonS3Config = new AmazonS3Config();

            amazonS3Config.ServiceURL = _amazonS3Credentials.AwsServiceUrl;

            amazonS3Config.RegionEndpoint = _amazonS3Credentials.AwsRegion;


            SessionAWSCredentials tempCredentials = new SessionAWSCredentials(_amazonS3Credentials.AwsAccessKeyId, _amazonS3Credentials.AwsSecretAccessKey, _amazonS3Credentials.AwsSessionKey); 


            return (new AmazonS3Client(tempCredentials, amazonS3Config));

        }

I have based it in the AWS documentation you have given.

Hope this helps

Hi Jeffrey were you able to figure the login using temporary credentials ? I have similar requirements

Hi @Jester San Pedro . I have a question

AmazonS3Credentials(). What library is this action in?

Thanks and best regard,

What do you mean by what Library? This Component should be modified.
And this is the AmazonS3Credentials() class is in the AmazonS3.cs file.



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.