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
141 stars 46 forks source link

Fresh Deployment with PointInTimeRecovery Fails #1654

Open skorfmann opened 3 weeks ago

skorfmann commented 3 weeks ago

How did you install the Amplify CLI?

npm

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

20

Amplify CLI Version

not sure

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.

import { defineBackend } from '@aws-amplify/backend'; import { auth } from './auth/resource'; import { data } from './data/resource'; import { storage } from './storage/resource';

/**

const dataResources = backend.data.resources;

dataResources.cfnResources.cfnGraphqlApi.xrayEnabled = true; Object.values(dataResources.cfnResources.amplifyDynamoDbTables).forEach((table) => { table.pointInTimeRecoveryEnabled = true; });

Describe the bug

when enabling PIR it seems to fail when deploying from scratch, but works iteratively

Expected behavior

always works

Reproduction steps

enable the PIR and deploy from scratch

Project Identifier

No response

Log output

``` # Put your logs below this line 2024-06-14T12:38:27.467Z [INFO]: CloudFormationDeploymentError: The CloudFormation deployment has failed. 804 Resolution: Find more information in the CloudFormation AWS Console for this stack. 805 Cause: ❌ Deployment failed: Error: The stack named amplify-d2vgttdm5hfz44-nextjs14-branch-303eb35053 failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Received response status [FAILED] from custom resource. Message returned: Backups are being enabled for the table: Post-h5podyoocvdqtcex6vi6tbuii4-NONE. Please retry later (RequestId: ef8a80c8-bfb6-49aa-8d36-40bb72b8a0b1), Embedded stack arn:aws:cloudformation:us-east-1:258175735278:stack/amplify-d2vgttdm5hfz44-nextjs14-branch-303e-amplifyDataPostNestedStackPostNestedStackR-BANCGW57TWX6/9e855760-2a4a-11ef-aee9-12ed87b41109 was not successfully created: The following resource(s) failed to create: [PostTable]. , Embedded stack arn:aws:cloudformation:us-east-1:258175735278:stack/amplify-d2vgttdm5hfz44-nextjs14-branch-303eb35053-data7552DF31-1DU99RJ0TCEHO/6b14da90-2a4a-11ef-a7cd-0e3bb866ed39 was not successfully created: The following resource(s) failed to create: [amplifyDataPostNestedStackPostNestedStackResourceB65AFCD3].  806 2024-06-14T12:38:27.470Z [INFO]: CloudFormationDeploymentError: The CloudFormation deployment has failed. 807 2024-06-14T12:38:27.470Z [INFO]: Resolution: Find more information in the CloudFormation AWS Console for this stack. 808 Cause: ❌ Deployment failed: Error: The stack named amplify-d2vgttdm5hfz44-nextjs14-branch-303eb35053 failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_COMPLETE: Received response status [FAILED] from custom resource. Message returned: Backups are being enabled for the table: Post-h5podyoocvdqtcex6vi6tbuii4-NONE. Please retry later (RequestId: ef8a80c8-bfb6-49aa-8d36-40bb72b8a0b1), Embedded stack arn:aws:cloudformation:us-east-1:258175735278:stack/amplify-d2vgttdm5hfz44-nextjs14-branch-303e-amplifyDataPostNestedStackPostNestedStackR-BANCGW57TWX6/9e855760-2a4a-11ef-aee9-12ed87b41109 was not successfully created: The following resource(s) failed to create: [PostTable]. , Embedded stack arn:aws:cloudformation:us-east-1:258175735278:stack/amplify-d2vgttdm5hfz44-nextjs14-branch-303eb35053-data7552DF31-1DU99RJ0TCEHO/6b14da90-2a4a-11ef-a7cd-0e3bb866ed39 was not successfully created: The following resource(s) failed to create: [amplifyDataPostNestedStackPostNestedStackResourceB65AFCD3].  809 2024-06-14T12:38:27.575Z [ERROR]: !!! Build failed 810 2024-06-14T12:38:27.575Z [INFO]: Please read more about Amplify Hosting's support for SSR frameworks to find if your build failure is related to an unsupported feature: https://docs.aws.amazon.com/amplify/latest/userguide/amplify-ssr-framework-support.html. You may also find this troubleshooting guide useful: https://docs.aws.amazon.com/amplify/latest/userguide/troubleshooting-ssr-deployment.html 811 2024-06-14T12:38:27.575Z [ERROR]: !!! Error: Command failed with exit code 1 812 2024-06-14T12:38:27.576Z [INFO]: # Starting environment caching... 813 2024-06-14T12:38:27.576Z [INFO]: # Environment caching completed 814 ```

Additional information

System: OS: macOS 14.4.1 CPU: (12) arm64 Apple M2 Max Memory: 122.33 MB / 32.00 GB Shell: /bin/zsh Binaries: Node: 20.10.0 - ~/.volta/tools/image/node/20.10.0/bin/node Yarn: 1.22.21 - ~/.volta/tools/image/yarn/1.22.21/bin/yarn npm: 10.2.3 - ~/.volta/tools/image/node/20.10.0/bin/npm pnpm: 9.1.4 - ~/Library/pnpm/pnpm NPM Packages: @aws-amplify/backend: 1.0.3 @aws-amplify/backend-cli: 1.0.4 aws-amplify: 6.3.6 aws-cdk: 2.145.0 aws-cdk-lib: 2.145.0 typescript: 5.4.5 AWS environment variables: AWS_PROFILE = sandbox AWS_STS_REGIONAL_ENDPOINTS = regional AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1 AWS_SDK_LOAD_CONFIG = 1

Before submitting, please confirm:

ykethan commented 3 weeks ago

HeyπŸ‘‹ thanks for raising this! I'm going to transfer this over to our backend repository as this is Gen 2 related.

Quickly tried reproducing this using the following

backend.ts

const backend = defineBackend({
  auth,
  data,
  myApiFunction,
});
backend.data.resources.cfnResources.cfnGraphqlApi.xrayEnabled = true;

const { amplifyDynamoDbTables } = backend.data.resources.cfnResources;
for (const table of Object.values(amplifyDynamoDbTables)) {
  table.pointInTimeRecoveryEnabled = true;
}

data/resource.ts

 Todo: a.model({
      R: a.integer().required(),
      B: a.integer().required(),
      Four: a.integer().required(),
      Six: a.integer().required(),
    }),

test this on a new app and existing app but did not run into this error. From the message Backups are being enabled for the table and the documentation it appears a different process is creating the PITR. was there a pervious build that attempted to enable this or was there any manual changes on the console?

skorfmann commented 2 weeks ago

om the message Backups are being enabled for the table and the documentation it appears a different process is creating the PITR. was there a pervious build that attempted to enable this or was there any manual changes on the console?

Not that I'm aware, I had the amplify sandbox (continuous local sync) running locally, which worked fine. Then when creating the app from scratch in Amplify Hosting I ran into this. Haven't tried to reproduce it again so far. However, the code is public https://github.com/cdk-dev/website/ :)

ykethan commented 2 weeks ago

Hey @skorfmann, thank you for information. Tried forking the repository and enabling the PITR, but did not observe this error. If the issue re-occurs could check the CloudForamtion stack events and the DynamoDB table(PITR tab) on the AWS console if there are any observations that would assist in documenting this behavior.

Jay2113 commented 3 days ago

Hi @skorfmann πŸ‘‹ , just checking in to see whether you are continuing to observe the Backups are being enabled for the table error during the deployment or are you now unblocked?