while trying to retrieve the temporary credentials from Amazon using AWS SDK , i am facing this issue.

0

hi , i have tried using this 2 types of approaches to retrieve temporary credentials from AWS account , getting the same error as shown in the screenshot . Please let me knw if there are any better approaches or if any fix for the error , Thank you. // 1st apporach

AssumeRoleRequest request = new AssumeRoleRequest();
                request.RoleArn = "arn:aws:iam::532634566192:role/ap-redshift";
                request.RoleSessionName = "newsessionanme";
                client = new AmazonSecurityTokenServiceClient();
                AssumeRoleResponse resp = client.AssumeRole(request);
                Console.WriteLine(resp.Credentials);
                Console.ReadLine();

// 2nd approach

client = new AmazonSecurityTokenServiceClient();
            var response = client.AssumeRole(new AssumeRoleRequest
            {
                RoleArn = "arn:aws:iam::532634566192:role/ap-redshift",
                RoleSessionName = "newsessionanme"
            });
            AssumedRoleUser assumedRoleUser = response.AssumedRoleUser;
            Credentials credentials = response.Credentials;

This is the error i am getting "Unable to get IAM security credentials from EC2 Instance Metadata Service.'" as also shown in the picture .

Enter image description here

asked 3 months ago43 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions