Skip to content

Commit aed93cf

Browse files
committed
Address PR feedback
1 parent 8483ee6 commit aed93cf

12 files changed

+78
-28
lines changed

generator/.DevConfigs/8a48524d-da8b-4c04-b57e-ad196a51debb.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"core": {
33
"changeLogMessages": [
4-
"Support Account ID based endpoints. Credential Providers will now attach the account ID to credentials if available and also read from the shared credentials file if set."
4+
"Support Account ID based endpoints. Account-based endpoints help ensure high performance and scalability by using your AWS account ID to route requests for services that support this feature. For more information visit [account id based endpoints on our docs](https://docs.aws.amazon.com/sdkref/latest/guide/feature-account-endpoints.html)."
55
],
66
"type": "patch",
77
"updateMinimum": true

sdk/src/Core/Amazon.Runtime/CredentialManagement/AWSCredentialsFactory.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ private static AWSCredentials GetAWSCredentialsInternal(
202202
switch (profileType)
203203
{
204204
case CredentialProfileType.Basic:
205-
return string.IsNullOrEmpty(options.AwsAccountId) ? new BasicAWSCredentials(options.AccessKey, options.SecretKey) : new BasicAWSCredentials(options.AccessKey, options.SecretKey, options.AwsAccountId);
205+
return new BasicAWSCredentials(options.AccessKey, options.SecretKey, options.AwsAccountId);
206206
case CredentialProfileType.Session:
207-
return string.IsNullOrEmpty(options.AwsAccountId) ? new SessionAWSCredentials(options.AccessKey, options.SecretKey, options.Token) : new SessionAWSCredentials(options.AccessKey, options.SecretKey, options.Token, options.AwsAccountId); ;
207+
return new SessionAWSCredentials(options.AccessKey, options.SecretKey, options.Token, options.AwsAccountId);
208208
case CredentialProfileType.AssumeRole:
209209
case CredentialProfileType.AssumeRoleExternal:
210210
case CredentialProfileType.AssumeRoleMFA:

sdk/src/Core/Amazon.Runtime/Credentials/AssumeRoleAWSCredentials.cs

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public AssumeRoleAWSCredentials(AWSCredentials sourceCredentials, string roleArn
8585
RoleArn = roleArn;
8686
RoleSessionName = roleSessionName;
8787
Options = options;
88-
8988

9089
// Make sure to fetch new credentials well before the current credentials expire to avoid
9190
// any request being made with expired credentials.

sdk/src/Core/Amazon.Runtime/Credentials/AssumeRoleImmutableCredentials.cs

+16-5
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,27 @@ public class AssumeRoleImmutableCredentials : ImmutableCredentials
3737
/// <param name="token">The security token for the credentials.</param>
3838
/// <param name="expiration">The expiration time for the credentials.</param>
3939
public AssumeRoleImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration)
40-
: base(awsAccessKeyId, awsSecretAccessKey, token)
40+
: this (awsAccessKeyId, awsSecretAccessKey, token, expiration, null)
4141
{
42-
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException("token");
43-
Expiration = expiration;
42+
4443

4544
}
4645

47-
public AssumeRoleImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration, string accountId) : this (awsAccessKeyId, awsSecretAccessKey, token, expiration)
46+
/// <summary>
47+
/// Constructs an instance with supplied keys, token, expiration, and account id. When the account id is set
48+
/// and the service supports account id based endpoints, AWS will send the request using the account-based endpoint rather
49+
/// than the regional endpount. Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
50+
/// the request to
51+
/// </summary>
52+
/// <param name="awsAccessKeyId">The AccessKey for the credentials</param>
53+
/// <param name="awsSecretAccessKey">The SecretKey for the credentials.</param>
54+
/// <param name="token">The security token for the credentials.</param>
55+
/// <param name="expiration">The expiration time for the credentials.</param>
56+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
57+
public AssumeRoleImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration, string accountId) : base (awsAccessKeyId, awsSecretAccessKey, token, accountId)
4858
{
49-
AccountId = accountId;
59+
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException("token");
60+
Expiration = expiration;
5061
}
5162
/// <summary>
5263
/// Get a copy of this AssumeRoleImmutableCredentials object.

sdk/src/Core/Amazon.Runtime/Credentials/AssumeRoleWithWebIdentityCredentials.cs

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public partial class AssumeRoleWithWebIdentityCredentials : RefreshingAWSCredent
4747
public const string WebIdentityTokenFileEnvVariable = "AWS_WEB_IDENTITY_TOKEN_FILE";
4848
public const string RoleArnEnvVariable = "AWS_ROLE_ARN";
4949
public const string RoleSessionNameEnvVariable = "AWS_ROLE_SESSION_NAME";
50-
public const string AwsAccountIdEnvVariable = "AWS_ACCOUNT_ID";
5150
private const string RoleSessionNameRegexPattern = @"^[\w+=,.@-]{2,64}$";
5251

5352
#if NET8_0_OR_GREATER

sdk/src/Core/Amazon.Runtime/Credentials/BasicAWSCredentials.cs

+10-6
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,22 @@ public class BasicAWSCredentials : AWSCredentials
3636
/// <summary>
3737
/// Constructs a BasicAWSCredentials object for the specified accessKey and secretKey.
3838
/// </summary>
39-
/// <param name="accessKey"></param>
40-
/// <param name="secretKey"></param>
39+
/// <param name="accessKey">The access key for the credentials.</param>
40+
/// <param name="secretKey">The secret key for the credentials.</param>
4141
public BasicAWSCredentials(string accessKey, string secretKey) : this (accessKey, secretKey, null)
4242
{
4343
}
4444

4545
/// <summary>
46-
/// Constructs a BasicAWSCredentials object for the specified accessKey, secretKey, and accountId
46+
/// Constructs a BasicAWSCredentials object for the specified accessKey, secretKey, and accountId.
47+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
48+
/// using the account-based endpoint rather than the regional endpount.
49+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
50+
/// the request to
4751
/// </summary>
48-
/// <param name="accessKey"></param>
49-
/// <param name="secretKey"></param>
50-
/// <param name="accountId"></param>
52+
/// <param name="accessKey">The access key for the credentials.</param>
53+
/// <param name="secretKey">The secret key for the credentials.</param>
54+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012</param>
5155
public BasicAWSCredentials(string accessKey, string secretKey, string accountId)
5256
{
5357
if (!string.IsNullOrEmpty(accessKey))

sdk/src/Core/Amazon.Runtime/Credentials/GenericContainerCredentials.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected override async Task<CredentialsRefreshState> GenerateNewCredentialsAsy
148148
await Task.Delay(retry.Next()).ConfigureAwait(false);
149149
}
150150

151-
return new CredentialsRefreshState(new ImmutableCredentials(credentials.AccessKeyId, credentials.SecretAccessKey, credentials.Token), credentials.Expiration);
151+
return new CredentialsRefreshState(new ImmutableCredentials(credentials.AccessKeyId, credentials.SecretAccessKey, credentials.Token, credentials.AccountId), credentials.Expiration);
152152
}
153153

154154
/// <summary>

sdk/src/Core/Amazon.Runtime/Credentials/ImmutableCredentials.cs

+12-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ public class ImmutableCredentials
4949

5050
/// <summary>
5151
/// Gets the AccountId property for the current credentials.
52+
/// The account id is your 12 digit account number with no hypens. For example: 123456789012.
53+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
54+
/// using the account-based endpoint rather than the regional endpount.
55+
/// Account-based endpoints take the form https://accountid.ddb.region.amazonaws.com
5256
/// </summary>
53-
public string AccountId { get; protected set; }
57+
public string AccountId { get; private set; }
5458
#endregion
5559

5660

@@ -76,11 +80,15 @@ public ImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, st
7680

7781
/// <summary>
7882
/// Constructs an ImmutableCredentials object with supplied accessKey, secretKey, and aws account id.
83+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
84+
/// using the account-based endpoint rather than the regional endpount.
85+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
7986
/// </summary>
80-
/// <param name="awsAccessKeyId"></param>
81-
/// <param name="awsSecretAccessKey"></param>
87+
/// <param name="awsAccessKeyId">The access key for the credentials.</param>
88+
/// <param name="awsSecretAccessKey">The secret access key for the credentials.</param>
8289
/// <param name="token">Optional. Can be set to null or empty for non-session credentials.</param>
83-
/// <param name="accountId">Optional. If <see cref="AccountIdEndpointMode"/> is set to preferred or required, the account id will be used in endpoint resolution.</param>
90+
/// <param name="accountId">Optional. If <see cref="AccountIdEndpointMode"/> is set to preferred or required, the account id will be used in endpoint resolution.
91+
/// The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
8492
public ImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, string accountId) : this(awsAccessKeyId, awsSecretAccessKey, token)
8593
{
8694
AccountId = accountId;

sdk/src/Core/Amazon.Runtime/Credentials/ProcessAWSCredentials.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,23 @@ public class ProcessAWSCredentials : RefreshingAWSCredentials
5353
#endregion
5454

5555
#region Public constructors
56+
/// <summary>
57+
/// Constructs an instance of credentials that can be retrieved by running an external process.
58+
/// </summary>
59+
/// <param name="processCredentialInfo">Contains the executable information to be used by the process credential retriever.</param>
5660
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
5761
public ProcessAWSCredentials(string processCredentialInfo) : this(processCredentialInfo, null)
5862
{
5963

6064
}
6165

62-
66+
/// <summary>
67+
/// Constructs an instance of credentials that can be retrieved by running an external process.
68+
/// </summary>
69+
/// <param name="processCredentialInfo">Contains the executable information to be used by the process credential retriever</param>
70+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012
71+
/// If account id is fetched from the executable then that will be used instead of the one set in the constructor.
72+
/// </param>
6373
public ProcessAWSCredentials(string processCredentialInfo, string accountId)
6474
{
6575
processCredentialInfo = processCredentialInfo.Trim();

sdk/src/Core/Amazon.Runtime/Credentials/SAMLImmutableCredentials.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,17 @@ public SAMLImmutableCredentials(string awsAccessKeyId,
6363
}
6464

6565
/// <summary>
66-
/// Constructs an instance with supplied keys SAML assertion data, and an account id
66+
/// Constructs an instance with supplied keys SAML assertion data, and an account id.
67+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
68+
/// using the account-based endpoint rather than the regional endpount.
69+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
6770
/// </summary>
6871
/// <param name="awsAccessKeyId"></param>
6972
/// <param name="awsSecretAccessKey"></param>
7073
/// <param name="token"></param>
7174
/// <param name="expires"></param>
7275
/// <param name="subject"></param>
73-
/// <param name="accountId"></param>
76+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
7477
public SAMLImmutableCredentials(string awsAccessKeyId,
7578
string awsSecretAccessKey,
7679
string token,
@@ -84,11 +87,14 @@ public SAMLImmutableCredentials(string awsAccessKeyId,
8487
}
8588
/// <summary>
8689
/// Constructs an instance with supplied keys and SAML assertion data and an account id.
90+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
91+
/// using the account-based endpoint rather than the regional endpount.
92+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
8793
/// </summary>
8894
/// <param name="credentials"></param>
8995
/// <param name="expires"></param>
9096
/// <param name="subject"></param>
91-
/// <param name="accountId"></param>
97+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
9298
public SAMLImmutableCredentials(ImmutableCredentials credentials,
9399
DateTime expires,
94100
string subject,

sdk/src/Core/Amazon.Runtime/Credentials/SessionAWSCredentials.cs

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ public SessionAWSCredentials(string awsAccessKeyId, string awsSecretAccessKey, s
3535
{
3636
}
3737

38+
/// <summary>
39+
/// Constructs a SessionAWSCredentials object for the specified accessKey, secretKey, and account id.
40+
/// When the account id is set and the service supports account id based endpoints, AWS will send the request
41+
/// using the account-based endpoint rather than the regional endpount.
42+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
43+
/// </summary>
44+
/// <param name="awsAccessKeyId"></param>
45+
/// <param name="awsSecretAccessKey"></param>
46+
/// <param name="token"></param>
47+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
48+
/// <exception cref="ArgumentNullException"></exception>
3849
public SessionAWSCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, string accountId)
3950
{
4051
if (string.IsNullOrEmpty(awsAccessKeyId)) throw new ArgumentNullException("awsAccessKeyId");

sdk/src/Core/Amazon.Runtime/Credentials/_bcl+netstandard/SSOImmutableCredentials.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,21 @@ public SSOImmutableCredentials(
4444
}
4545

4646
/// <summary>
47-
/// Constructs an instance with supplied keys, token, expiration, and account id
47+
/// Constructs an instance with supplied keys, token, expiration, and account id.
48+
/// When the account id is set and the service supports account id based endpoints,
49+
/// AWS will send the request using the account-based endpoint rather than the regional endpount.
50+
/// Account-based endpoints take the form https://<paramref name="accountId"/>.ddb.region.amazonaws.com
4851
/// </summary>
4952
/// <param name="awsAccessKeyId"></param>
5053
/// <param name="awsSecretAccessKey"></param>
5154
/// <param name="token"></param>
5255
/// <param name="expiration"></param>
53-
/// <param name="accountId"></param>
56+
/// <param name="accountId">The account id for the credentials. The account id is your 12 digit account number with no hyphens. For example: 123456789012.</param>
5457
/// <exception cref="ArgumentNullException"></exception>
5558
public SSOImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration, string accountId) : base(awsAccessKeyId, awsSecretAccessKey, token, accountId)
5659
{
5760
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException(nameof(token));
5861
Expiration = expiration;
59-
AccountId = accountId;
6062
}
6163

6264
/// <summary>

0 commit comments

Comments
 (0)