Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PluginNotFound Error when trying to add custom resources to a lambda function using amplify cli #11802

Open
2 tasks done
dwrynngs opened this issue Jan 18, 2023 · 3 comments
Open
2 tasks done
Labels
bug Something isn't working custom-cdk Issues related to custom CDK resource functionality p2 platform Issues tied to the general CLI platform

Comments

@dwrynngs
Copy link

How did you install the Amplify CLI?

npm

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

v16.13.2

Amplify CLI Version

10.5.2

What operating system are you using?

Mac

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

NA

Describe the bug

When I use the cli commands 'amplify add function' or 'amplify update function' and select 'resource access permissions' and then select 'custom' I get the following error:

Policies cannot be added for custom
PluginMethodNotFoundError: Method getPermissionPolicies does not exist or is not a function in category plugin: custom.
at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/invoke-plugin-method.js:35:15)
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.updateWalkthrough (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/service-walkthroughs/lambda-walkthrough.js:197:38)
at async updateFunctionResource (/snapshot/repo/build/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/index.js:155:22)
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)

Expected behavior

I would expect that there would be no error and that the file 'backend-config.json' would be auto-populated with the necessary custom resources in the 'dependsOn' for the function in question.

Reproduction steps

******************************** % amplify add function
? Select which capability you want to add: Lambda function (serverless function)
? Provide an AWS Lambda function name: test
? Choose the runtime that you want to use: Python
Only one template found - using Hello World by default.

Available advanced settings:

  • Resource access permissions
  • Scheduled recurring invocation
  • Lambda layers configuration
  • Environment variables configuration
  • Secret values configuration

? 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. custom
? Select the operations you want to permit on [custom resource] read
Policies cannot be added for custom
PluginMethodNotFoundError: Method getPermissionPolicies does not exist or is not a function in category plugin: custom.
at AmplifyToolkit.invokePluginMethod [as _invokePluginMethod] (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/invoke-plugin-method.js:35:15)
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)

You can access the following resource attributes as environment variables from your Lambda function
ENV
REGION
? Do you want to invoke this function on a recurring schedule? (y/N)

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • 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.
@dwrynngs dwrynngs added the pending-triage Issue is pending triage label Jan 18, 2023
@josefaidt
Copy link
Contributor

Hey @dwrynngs 👋 thanks for raising this! Despite the stack trace, this appears to be a duplicate of #9087, where unfortunately adding permissions to custom resources is not currently supported. Please see this comment for a potential workaround.

Marking this issue as a bug for the stack trace.

@josefaidt josefaidt added bug Something isn't working platform Issues tied to the general CLI platform extensibility Issues related to expand or customize current configuration and removed pending-triage Issue is pending triage labels Jan 18, 2023
@dwrynngs
Copy link
Author

Thanks for the comment. I would suggest if this is not currently supported then the option in the cli to add custom resources should be disabled until it it supported. Or there should be some documentation to flag the issue. I think until one of those things happens then this issue should not be closed. Is there any indication when this will be supported?

@josefaidt
Copy link
Contributor

Hey @dwrynngs unfortunately I do not have a timeline to share for this support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working custom-cdk Issues related to custom CDK resource functionality p2 platform Issues tied to the general CLI platform
Projects
None yet
Development

No branches or pull requests

2 participants