Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vidwanco/tenant-buckets into main
Browse files Browse the repository at this point in the history
  • Loading branch information
secrethash committed May 21, 2022
2 parents 8f51563 + b3a10b2 commit cc8acef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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;

...

Expand All @@ -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),
],
...
];
}
```
Expand Down

0 comments on commit cc8acef

Please sign in to comment.