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 CLI fails with Error: Cannot add S3Triggera54de6aa due to a cyclic dependency

See original GitHub issue

Describe the bug I am following the aws amplify photo albums tutorial but when building a new environment the S3 trigger fails with ‘access denied’ when calling S3.getObject().

Is there a separate step required to set permission for the S3 Trigger on the S3 bucket? Perhaps I missed it.

In any event then I tried to run ‘amplify function update’ to give the function access to the S3 bucket and I then get the following error:

Error: Cannot add S3Triggera54de6aa due to a cyclic dependency
    at checkForCyclicDependencies (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/update-amplify-meta.js:188:15)
    at AmplifyToolkit.updateamplifyMetaAfterResourceUpdate [as _updateamplifyMetaAfterResourceUpdate] (/usr/local/lib/node_modules/@aws-amplify/cli/lib/extensions/amplify-helpers/update-amplify-meta.js:114:9)
    at updateFunctionResource (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-function/lib/provider-utils/awscloudformation/index.js:144:29)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Object.executeAmplifyCommand (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-function/lib/index.js:193:5)
    at async executePluginModuleCommand (/usr/local/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js:153:5)
    at async Object.executeCommand (/usr/local/lib/node_modules/@aws-amplify/cli/lib/execution-manager.js:35:9)
    at async Object.run (/usr/local/lib/node_modules/@aws-amplify/cli/lib/index.js:82:9)

Amplify CLI Version 4.29.5

To Reproduce N/A

Expected behavior I would expect the function to work

Screenshots N/A

Desktop (please complete the following information):

  • OS: macOS
  • Node Version. v12.18.1

Additional context N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
waltehcommented, Dec 8, 2020

I just ran into this problem as well, so here is how I ran into it:

  1. used amplify add function to create new function “S3Trigger”
  2. while creating “S3Trigger” I set gave it full create, read, update, delete access on my amplify configured S3 Storage bucket “MyBucket”
  3. used amplify update storage and attempted to make “S3Trigger” the trigger
  4. Amplify CLI fails with the message “Cannot add S3Trigger due to a cyclic dependency”
1reaction
duncangroenewaldcommented, Oct 10, 2020

The issue appears to be that after creating the S3Trigger I added permission to the trigger to access API by using the ‘amplify function update’.

This created a policy with the same name as the S3Trigger’s bucket access policy which clobbered the bucket access policy.

Seems like a flaw in the amplify-cli logic that allows this to happen. Eventually I had to manually rename one of the policies as a workaround but you have to watch this each time you run the amplify-cli or it might get replaced if you subsequently run ‘amplify function update’ or ‘amplify storage update’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Delete an AWS Amplify application
Note: Deleting an Amplify application using the Amplify console or Amplify CLI can fail for many reasons. If you receive an error when ......
Read more >
Amplify API GraphQL Circular Resources Dependency
we experience an issue of Circular dependency between resources: [Precaution, UserProfile, Obligation, CustomResourcesjson, Remembrance, Lookup, ...
Read more >
@aws-amplify/cli - npm
Start using @aws-amplify/cli in your project by running `npm i ... Add a README to your package so that users know how to...
Read more >
Amplify CLI - AWS Amplify Docs
Running the 'amplify add custom' command in your Amplify project provides CDK or CloudFormation starter files along with mechanisms to reference other Amplify- ......
Read more >
AWS Amplify CLI Installation Guide (M1/M2 2022 Mac Edition)
Some examples of these great CLI commands include: amplify add auth : configure an AWS Cognito User Pool and methods for signing-in, including ......
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