public void SecurityTokenServiceAssumeRole() { #region to-assume-a-role-1480532402212 var response = client.AssumeRole(new AssumeRoleRequest { DurationSeconds = 3600, ExternalId = "123ABC", Policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Stmt1\",\"Effect\":\"Allow\",\"Action\":\"s3:*\",\"Resource\":\"*\"}]}", RoleArn = "arn:aws:iam::123456789012:role/demo", RoleSessionName = "Bob" }); AssumedRoleUser assumedRoleUser = response.AssumedRoleUser; Credentials credentials = response.Credentials; integer packedPolicySize = response.PackedPolicySize; #endregion }
private Amazon.SecurityToken.Model.AssumeRoleResponse CallAWSServiceOperation(IAmazonSecurityTokenService client, Amazon.SecurityToken.Model.AssumeRoleRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Security Token Service (STS)", "AssumeRole"); try { #if DESKTOP return(client.AssumeRole(request)); #elif CORECLR return(client.AssumeRoleAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
public void SecurityTokenServiceAssumeRole() { #region to-assume-a-role-1480532402212 var response = client.AssumeRole(new AssumeRoleRequest { ExternalId = "123ABC", Policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Stmt1\",\"Effect\":\"Allow\",\"Action\":\"s3:ListAllMyBuckets\",\"Resource\":\"*\"}]}", RoleArn = "arn:aws:iam::123456789012:role/demo", RoleSessionName = "testAssumeRoleSession", Tags = new List <Tag> { new Tag { Key = "Project", Value = "Unicorn" }, new Tag { Key = "Team", Value = "Automation" }, new Tag { Key = "Cost-Center", Value = "12345" } }, TransitiveTagKeys = new List <string> { "Project", "Cost-Center" } }); AssumedRoleUser assumedRoleUser = response.AssumedRoleUser; Credentials credentials = response.Credentials; int packedPolicySize = response.PackedPolicySize; #endregion }