From 07637490d2d5715c95c87ee6e11bfa5fa43425d3 Mon Sep 17 00:00:00 2001 From: Shashwat Mishra <11258035+secrethash@users.noreply.github.com> Date: Fri, 13 May 2022 23:44:39 +0530 Subject: [PATCH 1/2] Updated with Delete Bucket Job --- README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b4087d0..5eb188f 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ Automatically Provision AWS S3 Buckets for each tenant. It's an Extention for [s ## Concept -The concept is simple. It is to automatically provison a new AWS S3 bucket for tenant on registration and update the same on the central database's tenant table & data coloumn under `tenant_bucket`. +The concept is simple, to automatically provison a new AWS S3 bucket for tenant on registration and update the same on the central database's tenant table & data coloumn under `tenant_bucket`. Then using a bootstrapper updating the bucket in config `filesystems.disks.s3.bucket` during runtime when in Tenant's context and then reverting it back on central context. ### Roadmap - [x] Automatic Bucket Creation - [x] Selecting the created bucket during Tenancy Bootstrapping. -- [ ] Deletion of Bucket when the Tenant is deleted. +- [x] Deletion of Bucket when the Tenant is deleted. - [ ] Testing with Amazon S3 service. > **Note:** I have still not tested this package under ***production*** environment or with a real AWS S3 Bucket. I have only tested it under ***development*** environment using [MinIO](https://min.io/). I will update this after testing it on AWS S3 Bucket with an additional section on AWS IAM Policy Setup for creating the buckets using `aws-sdk-php`. Untill then, if you have tested, a PR is welcome. @@ -71,7 +71,7 @@ Vidwan\TenantBuckets\Bootstrappers\TenantBucketBootstrapper::class #### Part **b**. -Make sure the `s3` is commented in `tenancy.filesystem.disks` config. +Make sure the `s3` is commented in `tenancy.filesystem.disks` config or else it conflicts with the tenancy itself. **File:** `config/tenancy.php` ```php @@ -87,11 +87,13 @@ Make sure the `s3` is commented in `tenancy.filesystem.disks` config. ### 3. Job Pipeline -Add `Vidwan\TenantBuckets\Jobs\CreateTenantBucket` in `JobPipeline::make()` +Add `Vidwan\TenantBuckets\Jobs\CreateTenantBucket` & `Vidwan\TenantBuckets\Jobs\DeleteTenantBucket` in `JobPipeline::make()`. As the name suggests, the former Creates a New Bucket on Tenant Creation and the later Deletes it when a Tenant is being Deleted. **File:** `app/Providers/TenancyServiceProviders.php` ```php + use Vidwan\TenantBuckets\Jobs\CreateTenantBucket; +use Vidwan\TenantBuckets\Jobs\DeleteTenantBucket; ... @@ -114,6 +116,14 @@ use Vidwan\TenantBuckets\Jobs\CreateTenantBucket; })->shouldBeQueued(false), ], ... + Events\DeletingTenant::class => [ + JobPipeline::make([ + DeleteTenantBucket::class, // <-- Place it Here + ])->send(function (Events\DeletingTenant $event) { + return $event->tenant; + })->shouldBeQueued(false), + ], + ... ]; } ``` From b3a10b27728b666c065eab1e1d525afd55f41f9d Mon Sep 17 00:00:00 2001 From: secrethash Date: Fri, 13 May 2022 18:22:52 +0000 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb800af..a84a2ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,29 @@ All notable changes to `tenant-buckets` will be documented in this file. +## Added: Delete Bucket when tenant is deleted - 2022-05-13 + +# Key Changes: + +## Added: + +- `Vidwan\TenantBuckets\Jobs\DeleteTenantBucket::class` Job to delete bucket when tenant is being deleted. + +# Auto-generated Changelog: + +## What's Changed + +- Bump dependabot/fetch-metadata from 1.1.1 to 1.2.0 by @dependabot in https://github.com/vidwanco/tenant-buckets/pull/1 +- Bump dependabot/fetch-metadata from 1.2.0 to 1.2.1 by @dependabot in https://github.com/vidwanco/tenant-buckets/pull/2 +- Bump dependabot/fetch-metadata from 1.2.1 to 1.3.0 by @dependabot in https://github.com/vidwanco/tenant-buckets/pull/4 +- Bump dependabot/fetch-metadata from 1.3.0 to 1.3.1 by @dependabot in https://github.com/vidwanco/tenant-buckets/pull/7 + +## New Contributors + +- @dependabot made their first contribution in https://github.com/vidwanco/tenant-buckets/pull/1 + +**Full Changelog**: https://github.com/vidwanco/tenant-buckets/compare/v0.0.1...v0.1.0 + ## v0.0.1 - 2022-02-13 **Full Changelog**: https://github.com/vidwanco/tenant-buckets/commits/v0.0.1