Skip to content

Commit d324a80

Browse files
author
Roman Snapko
authored
Make Region property optional in Build ARN action (#1699)
Fixes OPS-3129
1 parent ac332ab commit d324a80

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

packages/blocks/aws/src/lib/actions/arn/build-arn-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const buildArnAction = createAction({
1515
}),
1616
region: Property.ShortText({
1717
displayName: 'Region',
18-
required: true,
18+
required: false,
1919
}),
2020
accountId: Property.ShortText({
2121
displayName: 'Account ID',
@@ -33,7 +33,7 @@ export const buildArnAction = createAction({
3333
service,
3434
accountId,
3535
resource: resourceId,
36-
region,
36+
region: region ?? '',
3737
});
3838

3939
return arn;

packages/blocks/aws/test/arn/build-arn-action.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('buildArnAction', () => {
1717
},
1818
region: {
1919
type: 'SHORT_TEXT',
20-
required: true,
20+
required: false,
2121
},
2222
});
2323
});
@@ -36,4 +36,21 @@ describe('buildArnAction', () => {
3636
'arn:aws:ec2:us-west-2:123456789012:i-1234567890abcdef0',
3737
);
3838
});
39+
40+
test.each([undefined, null, ''])(
41+
'should build ARN without region when region=%p',
42+
async (regionVal) => {
43+
const result = await buildArnAction.run({
44+
...jest.requireActual('@openops/blocks-framework'),
45+
propsValue: {
46+
service: 'iam',
47+
region: regionVal as any,
48+
accountId: '123456789012',
49+
resourceId: 'user/David',
50+
},
51+
});
52+
53+
expect(result).toEqual('arn:aws:iam::123456789012:user/David');
54+
},
55+
);
3956
});

0 commit comments

Comments
 (0)