Skip to content

Commit 7743c56

Browse files
committed
add support to s3:listObjectsV2
1 parent 67e83d1 commit 7743c56

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,12 @@ function getS3ObjectPermissions(action, state) {
588588
const prefix = state.Parameters.Prefix;
589589
let arn;
590590

591-
if (prefix) {
592-
arn = `arn:aws:s3:::${bucket}/${prefix}/${key}`;
593-
} else if (bucket === '*' && key === '*') {
591+
if (bucket === '*' && key === '*') {
594592
arn = '*';
593+
} else if (prefix & key) {
594+
arn = `arn:aws:s3:::${bucket}/${prefix}/${key}`;
595+
} else if (prefix) {
596+
arn = `arn:aws:s3:::${bucket}/${prefix}`;
595597
} else {
596598
arn = `arn:aws:s3:::${bucket}/${key}`;
597599
}
@@ -737,6 +739,9 @@ function getIamPermissions(taskStates) {
737739
case 'arn:aws:states:::s3:putObject':
738740
case 'arn:aws:states:::aws-sdk:s3:putObject':
739741
return getS3ObjectPermissions('s3:PutObject', state);
742+
case 'arn:aws:states:::s3:listObjectsV2':
743+
case 'arn:aws:states:::aws-sdk:s3:listObjectsV2':
744+
return getS3ObjectPermissions('s3:listObjectsV2', state);
740745

741746
default:
742747
if (isIntrinsic(state.Resource) || !!state.Resource.match(/arn:aws(-[a-z]+)*:lambda/)) {

0 commit comments

Comments
 (0)