- ã¯ããã«
- å 責äºé
- CloudFormation ã¹ã¿ãã¯ã®åé¤
- S3 ãã±ããã®åé¤
- ã¾ã¨ã
- ãããã¦èªã¿ãã
ã¯ããã«
å¹´æ«ã§ãããç§ã¯ 12/29 ããä¼æã«å ¥ãããããããæ¸ãã¦ããä»ï¼12/28ï¼ã¯ããååä¼ææ°åã§ãã
ï¼ãªããå½ç¤¾ã®å¹´æ«å¹´å§ä¼æã¯ãã¡ãã®éãã§ãï¼
å¹´æ«ã¨ããã°å¤§æé¤ã§ãããAWSã¢ã«ã¦ã³ããä¸è¦ãªãªã½ã¼ã¹ãåé¤ãã¦æ°å¹´ãè¿ããããã®ã§ããã¨ãããã¨ã§ãæ¬è¨äºã§ã¯ãªã½ã¼ã¹åé¤æã«é¢åãªã¢ã¬ã解決ãããã¼ã«ããç´¹ä»ãã¾ãã
å 責äºé
æ¬è¨äºã§ãç´¹ä»ãããã¼ã«ã¯AWSå ¬å¼ã®ãã®ã§ã¯ãªããªã¼ãã³ã½ã¼ã¹ã®ãã®ã§ãããå©ç¨ã¯èªå·±è²¬ä»»ã§ãé¡ããã¾ãã
CloudFormation ã¹ã¿ãã¯ã®åé¤
ãªã½ã¼ã¹ã®åé¤ã¨ããã°ã¾ãããã§ããã
å人çã«ã¯æ¥µå IaC åãè¡ã£ã¦ããã®ã§ãã¹ã¿ãã¯ãåé¤ãã¦ããã°å¤§åã®ãªã½ã¼ã¹ã¯æ¶ãã¦ãããã¯ãã§ãã
ããã³ã³ã® CloudFormation ç»é¢ããåé¤ã£ã¨...
ãããã¾ãã¯ããã¾ãããæ§ã ãªçç±ã§ã¹ã¿ãã¯åé¤ã妨害ãã¦ãã奴ãããã¾ãã
ä¾ãã°ã S3ãã±ããã¯ä¸ã«ãªãã¸ã§ã¯ããæ ¼ç´ããã¦ããç¶æ ã§ã¯åé¤ãããã¨ãã§ãã¾ããããªãã¸ã§ã¯ãåé¤ -> ãã±ããåé¤ ã®æé ãè¸ãå¿ è¦ãããã¾ãã1ã¤ã2ã¤ã§ããã°åé¡ããã¾ããããç§ã®æ¤è¨¼ç°å¢ã«ã¯ãå ¥ç¤¾ä»¥æ¥æºãè¾¼ãã 大éã®ã¹ã¿ãã¯ãããããé£ããã§ãããããªã¨ãã«ä½¿ããã®ãä»åãç´¹ä»ãããã¼ã«ã§ãã
delstack
delstack ã¯ã¹ã¿ãã¯åé¤ã®é»å®³è¦å ã解決ãã¤ã¤ã¹ã¿ãã¯ã®åé¤ãè¡ã£ã¦ããã¾ããS3 ã®ãªãã¸ã§ã¯ãåé¡ä»¥å¤ã§è§£æ±ºãã¦ãããé»å®³è¦å é㯠README ãåç §ãã¦ãã ããã
ãã£ã¦ã¿ã
ã¤ã³ã¹ãã¼ã«
ä»åã¯CloudShell ä¸ã§åããã¦ã¿ã¾ããã¾ãã¯ã¤ã³ã¹ãã¼ã«ããã
$ curl -fsSL https://raw.githubusercontent.com/go-to-k/delstack/main/install.sh | sh
helpã表示ã§ããã°OKã§ãã
$ delstack -h NAME: delstack - A CLI tool to force delete the entire CloudFormation stack. USAGE: delstack [global options] [arguments...] VERSION: 1.5.0 GLOBAL OPTIONS: --stackName value, -s value CloudFormation stack name --profile value, -p value AWS profile name --region value, -r value AWS region --interactive, -i Interactive Mode (default: false) --help, -h show help --version, -v print the version
ã¾ãã¯1ã¹ã¿ãã¯ã®ã¿åé¤
æ©éåé¤ãã¦ã¿ã¾ãããªãã·ã§ã³ã§ã¹ã¿ãã¯åãæå®ããã°è¯ãããã§ããS3 ã«ãªãã¸ã§ã¯ããå«ã¾ãã¦ãã¦åé¤ã«å¤±æããã¹ã¿ãã¯ãæå®ãã¾ãã
$ delstack -s serverless-fastapi-mangun-example-dev INF Start deletion, serverless-fastapi-mangun-example-dev INF Please wait a few minutes... INF Successfully deleted, serverless-fastapi-mangun-example-dev
1åç¨å¾ ã¤ã¨å½è©²ã¹ã¿ãã¯ã®åé¤ãå®äºããæ¨ããã°ã表示ããã¾ããï¼ã¹ããï¼
DELETE_FAILED
ã¨ãªã£ãã¹ã¿ãã¯éãã¾ã¨ãã¦åé¤
ã¨ããããã§ãæååé¤ã§ DELETE_FAILED
ã¨ãªã£ãã¹ã¿ãã¯éãã©ãã©ãæ¶ãã¦ããã¾ããã¾ãã¯ã¹ãã¼ã¿ã¹ã DELETE_FAILED
ã®ã¹ã¿ãã¯åä¸è¦§ãåå¾æ¹æ³ã確èªãã¾ãã
$ aws cloudformation list-stacks \ --query 'StackSummaries[?StackStatus==`DELETE_FAILED`].[StackName]' \ --output text | tr '\t' '\n' foo-stack bar-stack baz-stack
åºåãããã¹ã¿ãã¯ä¸è¦§ã«åé¡ãªããã¨ã確èªï¼å¤§äºï¼ãããã以ä¸ã®ã¯ã³ã©ã¤ãã¼ã§ãã¼ã³ã¨ã¹ã¿ãã¯éãåé¤ãã¾ãã
$ aws cloudformation list-stacks \ --query 'StackSummaries[?StackStatus==`DELETE_FAILED`].[StackName]' \ --output text | tr '\t' '\n' \ | xargs -I {} delstack -s {}
æéããããã®ã§ãã³ã¼ãã¼ã§ã飲ãã§å¾ ã¡ã¾ãããã
S3 ãã±ããã®åé¤
ãã¦ãå
ã»ã©ã¯ã¤ãã£ã¦ å人çã«ã¯æ¥µå IaC åãè¡ã£ã¦ãã
ãªã©ã¨æ¸ãã¾ããããæåã§ãªã½ã¼ã¹ãä½ããã¨ãããã¾ãããã®ä¸ã§ã大æé¤ããããªã½ã¼ã¹ã®çé ã S3ãã±ããã§ãã
確èªããã¨ãããç§ã®æ¤è¨¼ç°å¢ã«ã¯ä»¥ä¸ã®éã113ã®ãã±ãããããã¾ãããæ°ãåããã¨ãã«åé¤ããããã«ãã¦ãã¾ãããããªãã´ããããããã§ãã
åè¿°ã®éããS3 ãã±ããã®åé¤ã«ã¯äºããªãã¸ã§ã¯ãã®åé¤ãããå¿ è¦ãããã¾ããããããã£ã¦ãããã®ã cls3 ã§ããï¼å ã»ã©ã® delstack ã¨åãä½è ããã§ããï¼
cls3
ãã£ã¦ã¿ã
ã¤ã³ã¹ãã¼ã«
ãã¡ããCloudShell ä¸ã§åããã¦ã¿ã¾ããã¾ãã¯ã¤ã³ã¹ãã¼ã«ããã
$ curl -fsSL https://raw.githubusercontent.com/go-to-k/cls3/main/install.sh | sh
helpã表示ã§ããã°OKã§ãã
$ cls3 -h NAME: cls3 - A CLI tool to clear all objects in S3 Buckets or delete Buckets. USAGE: cls3 [global options] [arguments...] VERSION: 0.15.0 GLOBAL OPTIONS: --bucketName value, -b value [ --bucketName value, -b value ] S3 bucket names(one or more) --profile value, -p value AWS profile name --region value, -r value AWS region --force, -f Delete a bucket together (default: false) --interactive, -i Interactive Mode (default: false) --quiet, -q Not to display a progress bar (default: false) --oldVersionsOnly, -o Delete old version objects only (including all delete-markers) (default: false) --help, -h show help --version, -v print the version
ã¾ãã¯1ãã±ããã®ã¿åé¤
ã¾ãã¯1ãã±ããã®ã¿åé¤ãã¾ãããªãã·ã§ã³ã§ãã±ããåãæå®ããã°OKã§ãã-f
ãªãã·ã§ã³ãã¤ããã¨ãã±ãããåé¤ãã¦ããã¾ããï¼ä»ããªãå ´åã¯ãªãã¸ã§ã¯ãã®åé¤ã®ã¿ï¼
$ cls3 -b your-bucket-name -f INF your-bucket-name Checking... INF your-bucket-name Clearing... 100% |ââââââââââââââââââââââââââââââââââââââââââââââââââ| (215/215) INF your-bucket-name Cleared!!: 215 objects. INF your-bucket-name Deleted!!
215åã®ãªãã¸ã§ã¯ããåé¤ãããã±ãããåé¤ãã¦ããã¾ããã
ã¾ã¨ãã¦åé¤
-b
ãªãã·ã§ã³ã¯è¤æ°æå®å¯è½ã§ãã以ä¸ã®ããã«è¤æ°ãã±ããã¾ã¨ãã¦å¦çã§ãã¾ãã
$ cls3 -b my-bucket-name -b your-bucket-name -f
ä¸è¦ãªãã±ãããã¾ã¨ãã¦åé¤ã§ãã¾ãããã¹ããï¼
ãã±ããä¸è¦§ãåå¾ããã³ãã³ããä¸å¿ç½®ãã¦ããã¾ãã
$ aws s3 ls | awk '{print $3}'
ã¾ã¨ã
AWSç°å¢ã大æé¤ãã¦ãè¯ãæ°å¹´ãè¿ãã¾ãããã