@@ -14,6 +14,7 @@ const FAKE_STS_SESSION_TOKEN = 'STS-AWS-SESSION-TOKEN';
1414const FAKE_REGION = 'fake-region-1' ;
1515const FAKE_ACCOUNT_ID = '123456789012' ;
1616const ROLE_NAME = 'MY-ROLE' ;
17+ const ROLE_ARN = 'arn:aws:iam::123456789012:role/MY-ROLE' ;
1718const ENVIRONMENT_VARIABLE_OVERRIDES = {
1819 SHOW_STACK_TRACE : 'true' ,
1920 GITHUB_REPOSITORY : 'MY-REPOSITORY-NAME' ,
@@ -40,7 +41,7 @@ const DEFAULT_INPUTS = {
4041 'aws-region' : FAKE_REGION ,
4142 'mask-aws-account-id' : 'TRUE'
4243} ;
43- const ASSUME_ROLE_INPUTS = { ...REQUIRED_INPUTS , 'role-to-assume' : ROLE_NAME , 'aws-region' : FAKE_REGION } ;
44+ const ASSUME_ROLE_INPUTS = { ...REQUIRED_INPUTS , 'role-to-assume' : ROLE_ARN , 'aws-region' : FAKE_REGION } ;
4445
4546const mockStsCallerIdentity = jest . fn ( ) ;
4647const mockStsAssumeRole = jest . fn ( ) ;
@@ -201,7 +202,7 @@ describe('Configure AWS Credentials', () => {
201202
202203 await run ( ) ;
203204 expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
204- RoleArn : ROLE_NAME ,
205+ RoleArn : ROLE_ARN ,
205206 RoleSessionName : 'GitHubActions' ,
206207 DurationSeconds : 6 * 3600 ,
207208 Tags : [
@@ -223,7 +224,7 @@ describe('Configure AWS Credentials', () => {
223224
224225 await run ( ) ;
225226 expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
226- RoleArn : ROLE_NAME ,
227+ RoleArn : ROLE_ARN ,
227228 RoleSessionName : 'GitHubActions' ,
228229 DurationSeconds : 5 ,
229230 Tags : [
@@ -245,7 +246,7 @@ describe('Configure AWS Credentials', () => {
245246
246247 await run ( ) ;
247248 expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
248- RoleArn : ROLE_NAME ,
249+ RoleArn : ROLE_ARN ,
249250 RoleSessionName : 'MySessionName' ,
250251 DurationSeconds : 6 * 3600 ,
251252 Tags : [
@@ -260,14 +261,36 @@ describe('Configure AWS Credentials', () => {
260261 } )
261262 } ) ;
262263
264+ test ( 'role name provided instead of ARN' , async ( ) => {
265+ core . getInput = jest
266+ . fn ( )
267+ . mockImplementation ( mockGetInput ( { ...REQUIRED_INPUTS , 'role-to-assume' : ROLE_NAME , 'aws-region' : FAKE_REGION } ) ) ;
268+
269+ await run ( ) ;
270+ expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
271+ RoleArn : ROLE_ARN ,
272+ RoleSessionName : 'GitHubActions' ,
273+ DurationSeconds : 6 * 3600 ,
274+ Tags : [
275+ { Key : 'GitHub' , Value : 'Actions' } ,
276+ { Key : 'Repository' , Value : ENVIRONMENT_VARIABLE_OVERRIDES . GITHUB_REPOSITORY } ,
277+ { Key : 'Workflow' , Value : ENVIRONMENT_VARIABLE_OVERRIDES . GITHUB_WORKFLOW } ,
278+ { Key : 'Action' , Value : ENVIRONMENT_VARIABLE_OVERRIDES . GITHUB_ACTION } ,
279+ { Key : 'Actor' , Value : GITHUB_ACTOR_SANITIZED } ,
280+ { Key : 'Branch' , Value : ENVIRONMENT_VARIABLE_OVERRIDES . GITHUB_REF } ,
281+ { Key : 'Commit' , Value : ENVIRONMENT_VARIABLE_OVERRIDES . GITHUB_SHA } ,
282+ ]
283+ } )
284+ } ) ;
285+
263286 test ( 'role external ID provided' , async ( ) => {
264287 core . getInput = jest
265288 . fn ( )
266289 . mockImplementation ( mockGetInput ( { ...ASSUME_ROLE_INPUTS , 'role-external-id' : 'abcdef' } ) ) ;
267290
268291 await run ( ) ;
269292 expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
270- RoleArn : ROLE_NAME ,
293+ RoleArn : ROLE_ARN ,
271294 RoleSessionName : 'GitHubActions' ,
272295 DurationSeconds : 6 * 3600 ,
273296 Tags : [
@@ -294,7 +317,7 @@ describe('Configure AWS Credentials', () => {
294317
295318 await run ( ) ;
296319 expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
297- RoleArn : ROLE_NAME ,
320+ RoleArn : ROLE_ARN ,
298321 RoleSessionName : 'GitHubActions' ,
299322 DurationSeconds : 6 * 3600 ,
300323 Tags : [
0 commit comments