question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amplify function update -> Cannot destructure property 'serviceWalkthroughFilename' of 'serviceMetadata'

See original GitHub issue

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

14

Amplify CLI Version

10.3.1

What operating system are you using?

Windows

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

none

Amplify Categories

auth, analytics, notifications

Amplify Commands

update

Describe the bug

Since 10.3.1, when performing an amplify update, changing resource permissions will result in the following error: Rolling back to 10.0.0 fixes the issue

⚠️ Could not get policies for analytics: projectname Policies cannot be added for analytics TypeError: Cannot destructure property ‘serviceWalkthroughFilename’ of ‘serviceMetadata’ as it is undefined. at Object.getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\provider-utils\awscloudformation\index.js:56:5) at C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:112:32 at Array.forEach (<anonymous>) at getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:102:35) at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (C:\snapshot\repo\build\node_modules@aws-amplify\cli-internal\lib\extensions\amplify-helpers\invoke-plugin-method.js:39:12) at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async getResourcesForCfn (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:183:56) at async askExecRolePermissionsQuestions (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:113:66) at async Object.updateWalkthrough (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\lambda-walkthrough.js:197:38) at async updateFunctionResource (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\index.js:155:22) at async Object.executeAmplifyCommand (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\index.js:267:5)
at async executePluginModuleCommand (C:\snapshot\repo\build\node_modules@aws-amplify\cli-internal\lib\execution-manager.js:142:5) at async executeCommand (C:\snapshot\repo\build\node_modules@aws-amplify\cli-internal\lib\execution-manager.js:40:9) at async Object.run (C:\snapshot\repo\build\node_modules@aws-amplify\cli-internal\lib\index.js:153:5)

Expected behavior

Able to update the resource permissions for a function

Reproduction steps

  1. add api, auth, analytics and notifications to project
  2. Add a lambda function
  3. Update resource permissions using amplify function update, to add permissions to the ‘analytics’ resource

GraphQL schema(s)

# Put schemas below this line


Project Identifier

3bd747f16af991e4d8595be2c88f28e0

Log output

# Put your logs below this line

⚠️ Could not get policies for analytics: projectname
Policies cannot be added for analytics
TypeError: Cannot destructure property 'serviceWalkthroughFilename' of 'serviceMetadata' as it is undefined.
at Object.getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\provider-utils\awscloudformation\index.js:56:5)
    at C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:112:32
    at Array.forEach (<anonymous>)
    at getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:102:35)
    at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\extensions\amplify-helpers\invoke-plugin-method.js:39:12)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async getResourcesForCfn (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:183:56)
    at async askExecRolePermissionsQuestions (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:113:66)
    at async Object.updateWalkthrough (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\lambda-walkthrough.js:197:38)
    at async updateFunctionResource (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\index.js:155:22)
    at async Object.executeAmplifyCommand (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\index.js:267:5)       
    at async executePluginModuleCommand (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:142:5)
    at async executeCommand (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:40:9)
    at async Object.run (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\index.js:153:5)

Additional information

rolling back to 10.0.0 fixes the issue

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ykethancommented, Oct 26, 2022

Hey @conorw, thank you for reaching out. I was able to reproduce the issue with the following steps. CLI version 10.3.2

  1. amplify init
  2. amplify add analytics
  3. amplify add function
amplify add function
? Select which capability you want to add: Lambda function (serverless function)
? Provide an AWS Lambda function name: auth11247eabe9177
? Choose the runtime that you want to use: NodeJS
? Choose the function template that you want to use: Hello World
? Do you want to configure advanced settings? Yes
? Do you want to access other resources in this project from your Lambda function? Yes
? Select the categories you want this function to have access to. analytics
? Select the operations you want to permit on auth11247 create, read

observed the following error.

Could not get policies for analytics: auth11247
Policies cannot be added for analytics
TypeError: Cannot destructure property 'serviceWalkthroughFilename' of 'serviceMetadata' as it is undefined.
    at Object.getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\provider-utils\awscloudformation\index.js:56:5)
    at C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:112:32
    at Array.forEach (<anonymous>)
    at getPermissionPolicies (C:\snapshot\repo\build\node_modules\amplify-category-analytics\lib\index.js:102:35)
    at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\extensions\amplify-helpers\invoke-plugin-method.js:39:12)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async getResourcesForCfn (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:183:56)
    at async askExecRolePermissionsQuestions (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\execPermissionsWalkthrough.js:113:66)
    at async Object.createWalkthrough (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\service-walkthroughs\lambda-walkthrough.js:53:83)
    at async addFunctionResource (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\provider-utils\awscloudformation\index.js:78:9)
    at async Object.executeAmplifyCommand (C:\snapshot\repo\build\node_modules\amplify-category-function\lib\index.js:267:5)
    at async executePluginModuleCommand (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:142:5)
    at async executeCommand (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\execution-manager.js:40:9)
    at async Object.run (C:\snapshot\repo\build\node_modules\@aws-amplify\cli-internal\lib\index.js:153:5)

Note: ran amplify push to check if the Lambda role updates with the policy but did not observe any additional permissions. running update function with resource access permissions shows analytics as not selected.

Marking this as a bug. Thank you for reporting.

0reactions
ykethancommented, Dec 26, 2022

Reopening the issue. Thank you for reporting this, I was able to reproduce this issue. observed the following error when providing Lambda function access to user pool groups.

? Select the categories you want this function to have access to. auth
? Auth has 2 resources in this project. Select the one you would like your Lambda to access test9b389920, userPoolGroups
? Select the operations you want to permit on test9b389920 create, read, update, delete
? Select the operations you want to permit on userPoolGroups create, read, update, delete
Could not get policies for auth: userPoolGroups
Policies cannot be added for auth
TypeError: Cannot destructure property 'serviceWalkthroughFilename' of 'getSupportedServices(...)[service]' as it is undefined.
    at Object.getPermissionPolicies (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/provider-utils/awscloudformation/index.js:359:13)
    at /snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/index.js:319:67
    at Array.forEach (<anonymous>)
    at getPermissionPolicies (/snapshot/repo/build/node_modules/@aws-amplify/amplify-category-auth/lib/index.js:314:37)
    at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/invoke-plugin-method.js:39:12)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async getResourcesForCfn (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/execPermissionsWalkthrough.js:183:56)
    at async askExecRolePermissionsQuestions (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/execPermissionsWalkthrough.js:113:66)
    at async Object.createWalkthrough (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.js:53:83)
    at async addFunctionResource (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/index.js:78:9)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/amplify-category-function/lib/index.js:267:5)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:153:5)

Note: tested when on testing in 11.0.0-beta.3

Could not get policies for auth: userPoolGroups
PluginPolicyAddError: Policies cannot be added for auth
    at askExecRolePermissionsQuestions (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/execPermissionsWalkthrough.js:129:23)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.createWalkthrough (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.js:53:83)
    at async addFunctionResource (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/index.js:78:9)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/amplify-category-function/lib/index.js:268:5)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:119:5)
There was an error adding the function resource
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error in assigning policy to aws function for usergroups ...
I am adding policy via CLI to authorize function to update userpool Groups ... Cannot destructure property > `serviceWalkthroughFilename` of ...
Read more >
How do you use RDS MySQL with AWS AppSync - Reddit
TypeError : Cannot destructure property 'selectedClusterArn' of '(intermediate value)' as it is undefined. at serviceWalkthrough ...
Read more >
amplify-cli - bytemeta
amplify function update -> Cannot destructure property 'serviceWalkthroughFilename' of 'serviceMetadata'. evcodes. evcodes OPEN · Updated 22 hours ago ...
Read more >
Running `amplify api add-graphql-datasource` yields strange ...
Cannot destructure property 'serviceWalkthroughFilename' of 'serviceMetadata' as it is undefined. TypeError: Cannot destructure property ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found