Skip to content

Commit

Permalink
fix: issue #6131 e2e fix
Browse files Browse the repository at this point in the history
  • Loading branch information
akshbhu committed Feb 1, 2021
1 parent b09ccf0 commit 32c38f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
9 changes: 6 additions & 3 deletions packages/amplify-category-storage/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ async function getPermissionPolicies(context, resourceOpsMapping) {

if (providerPlugin) {
const providerController = require(`./provider-utils/${providerPlugin}`);
const { policies, attributes } = providerController.getPermissionPolicies(
const { policy, attributes } = providerController.getPermissionPolicies(
context,
service,
resourceName,
resourceOpsMapping[resourceName],
);

permissionPolicies.push(...policies);
if (Array.isArray(policy)) {
permissionPolicies.push(...policy);
} else {
permissionPolicies.push(policy);
}
resourceAttributes.push({ resourceName, attributes, category });
} else {
context.print.error(`Provider not configured for ${category}: ${resourceName}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,7 @@ function convertToCRUD(parameters, answers) {
}

export const getIAMPolicies = (resourceName, crudOptions) => {
let policies = [];
let policy = [];
let actions = new Set();

crudOptions.forEach(crudOption => {
Expand All @@ -1323,8 +1323,8 @@ export const getIAMPolicies = (resourceName, crudOptions) => {
});

actions = Array.from(actions);
let listBucketPolicy = {};
if (actions.includes('s3:ListBucket')) {
let listBucketPolicy = {};
listBucketPolicy = {
Effect: 'Allow',
Action: 's3:ListBucket',
Expand All @@ -1343,8 +1343,9 @@ export const getIAMPolicies = (resourceName, crudOptions) => {
],
};
actions = actions.filter(action => action != 's3:ListBucket');
policy.push(listBucketPolicy);
}
let policy = {
let s3ObjectPolicy = {
Effect: 'Allow',
Action: actions,
Resource: [
Expand All @@ -1362,11 +1363,10 @@ export const getIAMPolicies = (resourceName, crudOptions) => {
},
],
};
// push both policies
policies.push(policy, listBucketPolicy);
policy.push(s3ObjectPolicy);
const attributes = ['BucketName'];

return { policies, attributes };
return { policy, attributes };
};

function getTriggersForLambdaConfiguration(protectionLevel, functionName) {
Expand Down

0 comments on commit 32c38f5

Please sign in to comment.