[![NPM version](https://badge.fury.io/js/cdk-s3bucket-ng.svg)](https://badge.fury.io/js/cdk-s3bucket-ng)
[![PyPI version](https://badge.fury.io/py/cdk-s3bucket-ng.svg)](https://badge.fury.io/py/cdk-s3bucket-ng)
![Release](https://github.com/neilkuan/cdk-s3bucket/workflows/release/badge.svg)
![Downloads](https://img.shields.io/badge/-DOWNLOADS:-brightgreen?color=gray)
![npm](https://img.shields.io/npm/dt/cdk-s3bucket-ng?label=npm&color=orange)
![PyPI](https://img.shields.io/pypi/dm/cdk-s3bucket-ng?label=pypi&color=blue)
# cdk-s3bucket-ng
cdk-s3bucket-ng is an AWS CDK construct library that provides a drop-in replacement for the Bucket construct with the capability to remove non-empty S3 buckets.
## Install
```bash
Use the npm dist tag to opt in CDKv1 or CDKv2:
// for CDKv2
npm install cdk-s3bucket-ng
or
npm install cdk-s3bucket-ng@latest
// for CDKv1
npm install cdk-s3bucket-ng@cdkv1
```
# Why
Sometime we just do some lab , create a S3 Bucket.
Want to destroy resource , after Lab finished.
But We forget delete Object in S3 Bucket first , so destroy will fail.
`cdk-s3bucket-ng` can help delete object when cdk destroy , just add `removalPolicy: RemovalPolicy.DESTROY` property .
You never have to delete objects yourself, and the usage is almost the same as the native @aws-cdk/aws-s3.Bucket
## Now Try It !!!
# Sample
```python
# Example automatically generated from non-compiling source. May contain errors.
import { App, Stack, CfnOutput, RemovalPolicy } from '@aws-cdk/core';
import { BucketNg } from 'cdk-s3bucket-ng';
import * as s3deploy from '@aws-cdk/aws-s3-deployment';
// Create a S3 , add props "removalPolicy: RemovalPolicy.DESTROY".
const bucket = new BucketNg(stack, 'Bucket',{
removalPolicy: RemovalPolicy.DESTROY,
});
//Upload temp file .
new s3deploy.BucketDeployment(stack, 'addResource', {
sources: [s3deploy.Source.asset('./testdir')],
destinationBucket: bucket,
});
// Get S3 Resource via bucket.s3Bucket ...
new CfnOutput(stack, 'BucketName', { value: bucket.bucketName });
```
```bash
# create temp file .
mkdir ./testdir
touch ./testdir/{a.txt,b.txt,c.txt}
ls ./testdir
a.txt b.txt c.txt
```
### To deploy
```bash
cdk deploy
```
### To destroy
```bash
# will delete object in S3 , and delete S3 Bucket
cdk destroy
```
## :clap: Supporters
[![Stargazers repo roster for @neilkuan/cdk-s3bucket](https://reporoster.com/stars/neilkuan/cdk-s3bucket)](https://github.com/neilkuan/cdk-s3bucket/stargazers)
PyPI 官网下载 | cdk-s3bucket-ng-1.1.267.tar.gz
版权申诉
54 浏览量
2022-01-26
19:46:45
上传
评论
收藏 25KB GZ 举报
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
最新资源
- 本科毕业设计基于C# wpf人脸识别的考勤系统的设计与实现源码.zip
- 基于Ruoyi+uniapp实现学生考勤系统 学生考勤源码+项目说明.zip
- feae6bc968ca68a099455d8b8a8dea35
- 基于Pytorch训练CIRAR10上分类算法.zip
- Pytorch-pytorch深度学习教程之Tensorboard.zip
- 基于C++和Python开发yolov8-face作为人脸检测器dlib作为人脸识别器的人脸考勤系统源码+项目说明.zip
- Pytorch-pytorch深度学习教程之变分自动编码器.zip
- Pytorch-pytorch深度学习教程之神经风格迁移.zip
- Pytorch-pytorch深度学习教程之深度残差网络.zip
- Pytorch-pytorch深度学习教程之循环神经网络.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0