由于 dynamodb 表而无法部署 sst 应用程序

发布于 2025-01-12 00:34:55 字数 1952 浏览 0 评论 0原文

我是 aws 和 React 的新手。我昨天有一些代码正在运行(我可以将数据从 React 页面放入 dynamodb 表中)。今天我尝试创建一个新表(称为“事件”),但我没有让它工作。然后,我使用 git 命令“git reset --hard”回滚所有本地更改,并从 aws 管理系统中删除了表“Events”。现在,当我运行“npx sst start”时,我无法部署该应用程序。错误消息如下所示:

C:\Users\nickl\padel\notes>npx sst start
Using stage: admin
Preparing your SST app

=======================
 Deploying debug stack
=======================

Deploying stacks

 ✅  admin-notes-debug-stack (no changes)


Stack admin-notes-debug-stack
  Status: no changes
  Outputs:
    BucketArn: arn:aws:s3:::admin-notes-debug-stack-bucket83908e77-1tywtvoiarr1e
    BucketName: admin-notes-debug-stack-bucket83908e77-1tywtvoiarr1e
    Endpoint: wss://8pi9mbv1qb.execute-api.us-east-1.amazonaws.com/admin


===============
 Deploying app
===============

Deploying stacks
Checking deploy status...
admin-notes-storage | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage | User Initiated
admin-notes-storage | UPDATE_ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage | Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api
Checking deploy status...
admin-notes-storage | UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage
admin-notes-storage | UPDATE_ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | admin-notes-storage

 ❌  admin-notes-storage failed: Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api


Stack admin-notes-storage
  Status: failed
  Error: Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api

Stack admin-notes-api
  Status: not deployed

Stack admin-notes-auth
  Status: not deployed

Stack admin-notes-frontend
  Status: not deployed

Failed to deploy the app

如果您需要代码中的其他内容,请告诉我。

谢谢

I am new to aws and react. I had some code working yesterday (I could put data into a dynamodb table from a React page). Today I tried to create a new table (called Events), but I did not get it to work. I then rolled back all local changes using the git command 'git reset --hard' and deleted the table 'Events' from aws management system. Now I am unable to deploy the app when I run 'npx sst start'. The error message can be seen below:

C:\Users\nickl\padel\notes>npx sst start
Using stage: admin
Preparing your SST app

=======================
 Deploying debug stack
=======================

Deploying stacks

 ✅  admin-notes-debug-stack (no changes)


Stack admin-notes-debug-stack
  Status: no changes
  Outputs:
    BucketArn: arn:aws:s3:::admin-notes-debug-stack-bucket83908e77-1tywtvoiarr1e
    BucketName: admin-notes-debug-stack-bucket83908e77-1tywtvoiarr1e
    Endpoint: wss://8pi9mbv1qb.execute-api.us-east-1.amazonaws.com/admin


===============
 Deploying app
===============

Deploying stacks
Checking deploy status...
admin-notes-storage | UPDATE_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage | User Initiated
admin-notes-storage | UPDATE_ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage | Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api
Checking deploy status...
admin-notes-storage | UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS | AWS::CloudFormation::Stack | admin-notes-storage
admin-notes-storage | UPDATE_ROLLBACK_COMPLETE | AWS::CloudFormation::Stack | admin-notes-storage

 ❌  admin-notes-storage failed: Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api


Stack admin-notes-storage
  Status: failed
  Error: Export admin-notes-storage:ExportsOutputRefEventsTable4B7491D3C6BE5608 cannot be deleted as it is in use by admin-notes-api

Stack admin-notes-api
  Status: not deployed

Stack admin-notes-auth
  Status: not deployed

Stack admin-notes-frontend
  Status: not deployed

Failed to deploy the app

Let me know if you need anything else from the code.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鹊巢 2025-01-19 00:34:55

解决方案是从 aws 管理系统中删除所有堆栈,然后重新创建它们。

Solution was to delete all stacks from the aws management system, and then recreating them.

只等公子 2025-01-19 00:34:55

一个好的做法是首先检查您正在创建的资源是否已经存在于您的阶段中,尤其是在开发过程中。
请注意,如果创建资源时发生任何失败,您将面临堆栈创建失败。
例如,此代码在创建 s3 存储桶之前检查它是否存在:

 async function createS3Bucket(stack: any, bucketName: string): Promise<void> {
const s3 = new AWS.S3();
try {
  // Check if the bucket already exists
  await s3.headBucket({ Bucket: bucketName }).promise();
  console.log(`Bucket "${bucketName}" already exists.`);
} catch (error) {
  // Bucket doesn't exist, create it
  try {
    await s3.createBucket({ Bucket: bucketName }).promise();
    console.log(`Bucket "${bucketName}" created successfully.`);
  } catch (error) {
    console.error('Error creating bucket: ', error);
  }
}

希望这对您将来有所帮助!

A good practice will be to check first if the resources that you are creating already exist in your stage especially while developing.
Note that if any failing occurs while creating a resource, you will face failures in stacks creation.
For example, this code checks if the s3 bucket exists before creating it:

 async function createS3Bucket(stack: any, bucketName: string): Promise<void> {
const s3 = new AWS.S3();
try {
  // Check if the bucket already exists
  await s3.headBucket({ Bucket: bucketName }).promise();
  console.log(`Bucket "${bucketName}" already exists.`);
} catch (error) {
  // Bucket doesn't exist, create it
  try {
    await s3.createBucket({ Bucket: bucketName }).promise();
    console.log(`Bucket "${bucketName}" created successfully.`);
  } catch (error) {
    console.error('Error creating bucket: ', error);
  }
}

Hope this helps you in the future!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文