Skip to content

Commit af5cd87

Browse files
committed
chore(codegen): run codegen for sts client
1 parent 0e462c0 commit af5cd87

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

clients/client-sts/src/defaultStsRoleAssumers.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,24 @@ export const getDefaultRoleAssumer = (
8484
logger: logger as any,
8585
});
8686
}
87-
const { Credentials } = await stsClient.send(new AssumeRoleCommand(params));
87+
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
8888
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
8989
throw new Error(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`);
9090
}
91+
let accountId;
92+
try {
93+
accountId = AssumedRoleUser.Arn.split(":")[4];
94+
} catch (error) {
95+
accountId = undefined;
96+
}
9197
return {
9298
accessKeyId: Credentials.AccessKeyId,
9399
secretAccessKey: Credentials.SecretAccessKey,
94100
sessionToken: Credentials.SessionToken,
95101
expiration: Credentials.Expiration,
96102
// TODO(credentialScope): access normally when shape is updated.
97103
credentialScope: (Credentials as any).CredentialScope,
104+
accountId,
98105
};
99106
};
100107
};
@@ -134,17 +141,24 @@ export const getDefaultRoleAssumerWithWebIdentity = (
134141
logger: logger as any,
135142
});
136143
}
137-
const { Credentials } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
144+
const { Credentials, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
138145
if (!Credentials || !Credentials.AccessKeyId || !Credentials.SecretAccessKey) {
139146
throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${params.RoleArn}`);
140147
}
148+
let accountId;
149+
try {
150+
accountId = AssumedRoleUser.Arn.split(":")[4];
151+
} catch (error) {
152+
accountId = undefined;
153+
}
141154
return {
142155
accessKeyId: Credentials.AccessKeyId,
143156
secretAccessKey: Credentials.SecretAccessKey,
144157
sessionToken: Credentials.SessionToken,
145158
expiration: Credentials.Expiration,
146159
// TODO(credentialScope): access normally when shape is updated.
147160
credentialScope: (Credentials as any).CredentialScope,
161+
accountId,
148162
};
149163
};
150164
};

0 commit comments

Comments
 (0)