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

Storage definition with multiple path authorisation types throws a circular dependency error. #2307

Open
peterg9apps opened this issue Dec 8, 2024 · 1 comment
Labels
pending-response Issue is pending response from author pending-triage Incoming issues that need categorization sandbox Related to the sandbox experience

Comments

@peterg9apps
Copy link

peterg9apps commented Dec 8, 2024

Environment information

System:
  OS: macOS 14.1.1
  CPU: (8) arm64 Apple M1
  Memory: 160.92 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.4.0 - /opt/homebrew/bin/node
  Yarn: undefined - undefined
  npm: 9.7.2 - /opt/homebrew/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.5.0
  @aws-amplify/backend: 1.8.0
  @aws-amplify/backend-auth: 1.4.1
  @aws-amplify/backend-cli: 1.4.2
  @aws-amplify/backend-data: 1.2.1
  @aws-amplify/backend-deployer: 1.1.10
  @aws-amplify/backend-function: 1.8.0
  @aws-amplify/backend-output-schemas: 1.4.0
  @aws-amplify/backend-output-storage: 1.1.3
  @aws-amplify/backend-secret: 1.1.5
  @aws-amplify/backend-storage: 1.2.3
  @aws-amplify/cli-core: 1.2.0
  @aws-amplify/client-config: 1.5.2
  @aws-amplify/deployed-backend-client: 1.4.2
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.9
  @aws-amplify/platform-core: 1.2.2
  @aws-amplify/plugin-types: 1.5.0
  @aws-amplify/sandbox: 1.2.6
  @aws-amplify/schema-generator: 1.2.5
  aws-amplify: 6.10.0
  aws-cdk: 2.171.0
  aws-cdk-lib: 2.171.0
  typescript: 5.7.2

Error output

Error: ❌ amplify-awsamplifygen2-sandbox-a0b1e796f6 failed: ValidationError: Circular dependency between resources: [storage0EC3F24A, auth179371D7, MSCustomStack0E6FAF4A, data7552DF31, MediaConverterStackB4ED21B8, DataBackupStack16EBFB3F]

Caused By: ❌ amplify-awsamplifygen2-sandbox-a0b1e796f6 failed: ValidationError: Circular dependency between resources: [storage0EC3F24A, auth179371D7, MSCustomStack0E6FAF4A, data7552DF31, MediaConverterStackB4ED21B8, DataBackupStack16EBFB3F]

Describe the bug

The following storage definition causes a circular dependency issue when adding allow.guest.to(['read']) and deployment of the amplify project fails.

Reproduction steps

import * as backend from '@aws-amplify/backend';
import { s3created } from '../functions/s3created/resource.js';

export const storage = backend.defineStorage({
  name: 'files',
  versioned: false,
  access: (allow) => ({
    'alpha/*': [
      allow.resource(s3created).to(['read', 'write', 'delete'])
    ],
    'beta/*': [
      allow.guest.to(['read'])
    ],
  })
});
@peterg9apps peterg9apps added the pending-triage Incoming issues that need categorization label Dec 8, 2024
@ykethan
Copy link
Member

ykethan commented Dec 9, 2024

Hey @peterg9apps, thank you for reaching out. The circular dependency issue will typically occurs when referencing resources between stacks.
I would suggest breaking the circular dependency but creating the custom resources in the same stack as the resources you are trying to interact with.
you can reference the existing Amplify created resources stack for example auth stack

backend.auth.stack 

@ykethan ykethan added sandbox Related to the sandbox experience pending-response Issue is pending response from author labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-response Issue is pending response from author pending-triage Incoming issues that need categorization sandbox Related to the sandbox experience
Projects
None yet
Development

No branches or pull requests

2 participants