aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
184 stars 62 forks source link

amplify_output.json not updated (updated async after a day) after each deployment #2066

Closed scorobogaci closed 1 month ago

scorobogaci commented 1 month ago

Environment information

System:
  OS: macOS 14.5
  CPU: (8) arm64 Apple M1
  Memory: 62.39 MB / 16.00 GB
  Shell: /bin/zsh
Binaries:
  Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
  Yarn: 1.22.19 - /opt/homebrew/bin/yarn
  npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.3.1
  @aws-amplify/backend: 1.3.0
  @aws-amplify/backend-auth: 1.2.0
  @aws-amplify/backend-cli: 1.2.8
  @aws-amplify/backend-data: 1.1.4
  @aws-amplify/backend-deployer: 1.1.4
  @aws-amplify/backend-function: 1.5.0
  @aws-amplify/backend-output-schemas: 1.2.0
  @aws-amplify/backend-output-storage: 1.1.2
  @aws-amplify/backend-secret: 1.1.3
  @aws-amplify/backend-storage: 1.2.0
  @aws-amplify/cli-core: 1.1.3
  @aws-amplify/client-config: 1.3.2
  @aws-amplify/deployed-backend-client: 1.4.1
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.8
  @aws-amplify/platform-core: 1.1.0
  @aws-amplify/plugin-types: 1.3.0
  @aws-amplify/sandbox: 1.2.2
  @aws-amplify/schema-generator: 1.2.4
  aws-amplify: 6.6.2
  aws-cdk: 2.159.1
  aws-cdk-lib: 2.159.1
  typescript: 5.6.2
AWS environment variables:
  AWS_STS_REGIONAL_ENDPOINTS = regional
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
No CDK environment variables

Describe the bug

When using Amplify Gen 2 , and making some updates in data/resource.ts (AppSync schema), the updates on models, configurations are not reflected in amplify_output.json after the deployment succeeded. Even though the logs (deployment logs) shows [INFO]: File written: amplify_outputs.json in fact latest changes are not written there.

Funny fact, if you download the amplify_output.json the next day, changes are reflected ))) The most hilarious bug ever seen I guess (some async things going on)

Here is the backend build in amplify.yml

backend:
  phases:
    build:
      commands:
        - npm ci --cache .npm --prefer-offline
        - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID

Reproduction steps

Given the following schema

const schema = a.schema({
  Account: a.model({
    identity: a.id().required(),
    email: a.email()
  }).identifier(['identity']).authorization(allow => [allow.owner()])
})

Add a new model for example :

const schema = a.schema({
  Todo: a
      .model({
        content: a.string(),
      }).authorization(allow => [allow.owner()]),
  Account: a.model({
    identity: a.id().required(),
    email: a.email()
  }).identifier(['identity']).authorization(allow => [allow.owner()])
})

Expected is that after deployment using CI/CD Gen 2, the types and everything regarding new model should be defined and written in the amplify_outputs.json, while this is not happening (the file get's updated only after a day)

scorobogaci commented 1 month ago

I gave attempted to generate the output explicitly using :

- npx ampx generate outputs --branch $AWS_BRANCH --app-id $AWS_APP_ID

in the backend build like this :

version: 1
backend:
  phases:
    build:
      commands:
        - npm ci --cache .npm --prefer-offline
        - npx ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
        - npx ampx generate outputs --branch $AWS_BRANCH --app-id $AWS_APP_ID

still the amplify_output.json have not been updated

Jay2113 commented 1 month ago

Hi @scorobogaci 👋 , thanks for reaching out. I wasn't able to reproduce this issue with the provided data schema. Can you share the following?

scorobogaci commented 1 month ago

Hi @scorobogaci 👋 , thanks for reaching out. I wasn't able to reproduce this issue with the provided data schema. Can you share the following?

  • Amplify app id
  • amplify_outputs.json file (both the older and the latest). Since these files contain sensitive information, I'd recommend sharing this over a DM on our community discord server. My username is Jay Raval.
  • Were you trying to download the latest outputs file from the console when a deployment was is in progress?

Hello :) No, I have downloaded the amplify_outputs.json after the deployment was finished. I just added a new model for data, then deployed the stack (Ci triggered automatically) and after checking the output, the new model wasn't there in the amplify_outputs.json :(

Jay2113 commented 1 month ago

@scorobogaci can you share the information requested here? Additionally, post a deployment does the AppSync API resource get updated with the new model? Lastly, can you share your entire schema as it will be helpful for us to further investigate into this issue.

Jay2113 commented 1 month ago

I am going to close this thread since we are unable to reproduce this issue. If you continue to experience it, feel free to create a new issue with the requested information. Thanks.