@@ -14,6 +14,7 @@ const FAKE_STS_SESSION_TOKEN = 'STS-AWS-SESSION-TOKEN';
14
14
const FAKE_REGION = 'fake-region-1' ;
15
15
const FAKE_ACCOUNT_ID = '123456789012' ;
16
16
const ROLE_NAME = 'MY-ROLE' ;
17
+ const ROLE_ARN = 'arn:aws:iam::123456789012:role/MY-ROLE' ;
17
18
const ENVIRONMENT_VARIABLE_OVERRIDES = {
18
19
SHOW_STACK_TRACE : 'true' ,
19
20
GITHUB_REPOSITORY : 'MY-REPOSITORY-NAME' ,
@@ -40,7 +41,7 @@ const DEFAULT_INPUTS = {
40
41
'aws-region' : FAKE_REGION ,
41
42
'mask-aws-account-id' : 'TRUE'
42
43
} ;
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 } ;
44
45
45
46
const mockStsCallerIdentity = jest . fn ( ) ;
46
47
const mockStsAssumeRole = jest . fn ( ) ;
@@ -201,7 +202,7 @@ describe('Configure AWS Credentials', () => {
201
202
202
203
await run ( ) ;
203
204
expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
204
- RoleArn : ROLE_NAME ,
205
+ RoleArn : ROLE_ARN ,
205
206
RoleSessionName : 'GitHubActions' ,
206
207
DurationSeconds : 6 * 3600 ,
207
208
Tags : [
@@ -223,7 +224,7 @@ describe('Configure AWS Credentials', () => {
223
224
224
225
await run ( ) ;
225
226
expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
226
- RoleArn : ROLE_NAME ,
227
+ RoleArn : ROLE_ARN ,
227
228
RoleSessionName : 'GitHubActions' ,
228
229
DurationSeconds : 5 ,
229
230
Tags : [
@@ -245,7 +246,7 @@ describe('Configure AWS Credentials', () => {
245
246
246
247
await run ( ) ;
247
248
expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
248
- RoleArn : ROLE_NAME ,
249
+ RoleArn : ROLE_ARN ,
249
250
RoleSessionName : 'MySessionName' ,
250
251
DurationSeconds : 6 * 3600 ,
251
252
Tags : [
@@ -260,14 +261,36 @@ describe('Configure AWS Credentials', () => {
260
261
} )
261
262
} ) ;
262
263
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
+
263
286
test ( 'role external ID provided' , async ( ) => {
264
287
core . getInput = jest
265
288
. fn ( )
266
289
. mockImplementation ( mockGetInput ( { ...ASSUME_ROLE_INPUTS , 'role-external-id' : 'abcdef' } ) ) ;
267
290
268
291
await run ( ) ;
269
292
expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
270
- RoleArn : ROLE_NAME ,
293
+ RoleArn : ROLE_ARN ,
271
294
RoleSessionName : 'GitHubActions' ,
272
295
DurationSeconds : 6 * 3600 ,
273
296
Tags : [
@@ -294,7 +317,7 @@ describe('Configure AWS Credentials', () => {
294
317
295
318
await run ( ) ;
296
319
expect ( mockStsAssumeRole ) . toHaveBeenCalledWith ( {
297
- RoleArn : ROLE_NAME ,
320
+ RoleArn : ROLE_ARN ,
298
321
RoleSessionName : 'GitHubActions' ,
299
322
DurationSeconds : 6 * 3600 ,
300
323
Tags : [
0 commit comments