Skip to content

Commit

Permalink
fix: add sharedId in externalAuthEnable() (#7315)
Browse files Browse the repository at this point in the history
This commit updates externalAuthEnable() to include the auth
sharedId when creating an auth resource. The sharedId is given
the lowest priority in the authProps object so that it will not
overwrite any previously existing sharedId. It also uses the
sharedId from cognito-defaults for consistency. This change
prevents the creation of "snsundefined" roles.


Co-authored-by: Colin Ihrig <colihrig@amazon.com>
  • Loading branch information
cjihrig and cjihrig-aws committed May 24, 2021
1 parent eb1ee9c commit fd552b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/amplify-category-auth/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const category = 'auth';

const _ = require('lodash');
const uuid = require('uuid');
const path = require('path');
const sequential = require('promise-sequential');

Expand Down Expand Up @@ -72,7 +71,6 @@ async function externalAuthEnable(context, externalCategory, resourceName, requi
.projectName.toLowerCase()
.replace(/[^A-Za-z0-9_]+/g, '_');
let currentAuthParams;
const [sharedId] = uuid().split('-');

const immutables = {};

Expand Down Expand Up @@ -115,7 +113,8 @@ async function externalAuthEnable(context, externalCategory, resourceName, requi
const authPropsValues = authExists
? Object.assign(defaults.functionMap[requirements.authSelections](currentAuthName), currentAuthParams, immutables, requirements)
: Object.assign(defaults.functionMap[requirements.authSelections](currentAuthName), requirements, {
resourceName: `cognito${sharedId}`,
resourceName: `cognito${defaults.sharedId}`,
sharedId: defaults.sharedId,
}); //eslint-disable-line
/* eslint-enable */
const { roles } = defaults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ module.exports = {
withSocialDefaults,
entityKeys,
roles,
sharedId,
};

0 comments on commit fd552b4

Please sign in to comment.