-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from aws-samples/how-to-delete
削除手順の追加
- Loading branch information
Showing
5 changed files
with
51 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# リソースの削除方法 | ||
|
||
以下のコマンドを実行してください。**Cognito UserPool, DynamoDB Table など全てのデータが削除されます。** | ||
|
||
```bash | ||
npm run cdk:destroy | ||
``` | ||
|
||
## エラーになった場合 | ||
|
||
以下のようなエラーが発生することがあります。 | ||
|
||
> **The bucket you tried to delete is not empty. You must delete all versions in the bucket.** | ||
S3 Bucket は削除する時に中身を空にする必要があります。AWS CDK のオプションで `autoDeleteObjects: true` を指定することで、削除の前に中身を自動で空にできるのですが、空にしてから実際に削除するまでの間に新たなファイルが追加されることで、上記エラーが発生します。 | ||
|
||
このエラーが発生した場合は、以下の手順に従って手動で Stack を削除してください。 | ||
|
||
1. [AWS CloudFormation](https://console.aws.amazon.com/cloudformation/home) を開き、GenerativeAiUseCasesStack を選択。 | ||
1. Delete を押下。この際に削除に失敗した S3 Bucket の削除をスキップするか聞かれるため、チェックを入れて削除を実行。 | ||
1. 削除をスキップした S3 Bucket を除いたリソースの削除が完了する。 | ||
1. [Amazon S3](https://s3.console.aws.amazon.com/s3/home) を開き、スキップした S3 Bucket を探す。("generative" 等で検索してください。) | ||
1. Empty (Bucket を空にする) => Delete (Bucket を削除する) を実行 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register'; | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { IConstruct } from 'constructs'; | ||
import { GenerativeAiUseCasesStack } from '../lib/generative-ai-use-cases-stack'; | ||
|
||
class DeletionPolicySetter implements cdk.IAspect { | ||
constructor(private readonly policy: cdk.RemovalPolicy) {} | ||
|
||
visit(node: IConstruct): void { | ||
if (node instanceof cdk.CfnResource) { | ||
node.applyRemovalPolicy(this.policy); | ||
} | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
const stack = new GenerativeAiUseCasesStack(app, 'GenerativeAiUseCasesStack'); | ||
|
||
new GenerativeAiUseCasesStack(app, 'GenerativeAiUseCasesStack'); | ||
cdk.Aspects.of(stack).add(new DeletionPolicySetter(cdk.RemovalPolicy.DESTROY)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters