Skip to content

Commit

Permalink
Added support for Tags and TransitiveTagKeys in AssumeRoleAWSCredenti…
Browse files Browse the repository at this point in the history
…alsOptions class.
  • Loading branch information
ashishdhingra committed Jun 17, 2024
1 parent 0181fcd commit 8452aed
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
18 changes: 18 additions & 0 deletions generator/.DevConfigs/32785037-cee6-4781-80bd-ee5d1ad445e4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"services": [
{
"serviceName": "SecurityToken",
"type": "patch",
"changeLogMessages": [
"Added support for Tags and TransitiveTagKeys in ICoreAmazonSTS.CredentialsFromAssumeRoleAuthentication() method."
]
}
],
"core": {
"changeLogMessages": [
"Added Tags and TransitiveTagKeys properties to AssumeRoleAWSCredentialsOptions class."
],
"type": "patch",
"updateMinimum": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Amazon.Runtime.Internal.Util;
using Amazon.Runtime.SharedInterfaces;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;

Expand Down Expand Up @@ -85,5 +86,21 @@ public string MfaTokenCode
/// operation.
/// </summary>
public string SourceIdentity { get; set; }

/// <summary>
/// A list of session tags that you want to pass. Each session tag consists of a key name
/// and an associated value.
/// For more information about session tags, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html">Tagging
/// Amazon Web Services STS Sessions</a> in the <i>IAM User Guide</i>.
/// </summary>
public List<KeyValuePair<string, string>> Tags { get; set; }

/// <summary>
/// A list of keys for session tags that you want to set as transitive. If you set a tag
/// key as transitive, the corresponding key and value passes to subsequent sessions in
/// a role chain. For more information, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_session-tags.html#id_session-tags_role-chaining">Chaining
/// Roles with Session Tags</a> in the <i>IAM User Guide</i>.
/// </summary>
public List<string> TransitiveTagKeys { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* permissions and limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Net;
using System.Linq;
using Amazon.Runtime;
Expand All @@ -23,6 +24,7 @@
using Amazon.SecurityToken.SAML;
using Amazon.Util.Internal;


#if AWS_ASYNC_API
using System.Threading.Tasks;
#endif
Expand Down Expand Up @@ -186,6 +188,16 @@ AssumeRoleImmutableCredentials ICoreAmazonSTS.CredentialsFromAssumeRoleAuthentic
{
request.DurationSeconds = options.DurationSeconds.Value;
}

if (options.Tags != null && options.Tags.Count > 0)
{
request.Tags = options.Tags.Select(kv => new Tag() { Key = kv.Key, Value = kv.Value }).ToList();
}

if (options.TransitiveTagKeys != null && options.TransitiveTagKeys.Count > 0)
{
request.TransitiveTagKeys = options.TransitiveTagKeys;
}
}

var response = AssumeRole(request);
Expand Down

0 comments on commit 8452aed

Please sign in to comment.