s3cleanup

command
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

S3 Cleanup

The `s3cleanup` custom resource is helping cleaning up S3 buckets when deleting a Cloudformation stack. Possible uses are cleaning up artificats from an artificat S3 bucket when deleting a project or cleaning up a S3 bucket before deleting a S3 Bucket resource as the AWS S3 Bucket resource cannot be deleted when it is not empty.

With the flag "ActiveOnlyOnStackDeletion" (default true) is true, The `s3cleanup` custom resource only deletes objects when the stack itself is being deleted. In that case, it also safe to remove the resource from an existing stack.

When the flag "ActiveOnlyOnStackDeletion" is false, the `s3cleanup` custom resource deletes objects when it is deleted. This is mostly useful when regularly replacing the `s3cleanup` custom resource when changing the prefix. An example is the hyperdrive-lambda stack itself: the stack cleans up artifacts from previous version with this mechanism. USE WITH CAUTION: to remove such `s3cleanup` custom resource from a stack without deleting objects, you have to set is the flag "ActiveOnlyOnStackDeletion" to true. Changing the bucket or the prefix will trigger a replacement and therefore a deletion of the resource.

## Syntax

To create an `s3cleanup` resource, add the following resource to your cloudformation template (yaml notation, json is similar)

```yaml MyS3Cleanup:

Type: Custom::S3Cleanup
Properties:
  ServiceToken:
    Fn::ImportValue:
      !Sub ${HyperdriveCore}-S3Cleanup
  ActiveOnlyOnStackDeletion: true
  Bucket: <bucket name>
  Prefix: <prefix>

```

## Properties

`ActiveOnlyOnStackDeletion`

> Informs the resource when to delete objects from the s3 bucket. If the flag is true, then the resource deletes > objects if and only if the stack is being deleted. If the flag is false, then the resource deletes objects if > it is itself being deleted irrespective to the status of the stack.

_Type_: Boolean

_Required_: No

_Update Requires_: no interruption

`Bucket`

> The name of the S3 Bucket to cleanup when the `s3cleanup` resource is deleted while its stack > itself is deleted. > > _Type_: Bucket Name > > _Required_: Yes > > _Update Requires_: replacement

`Prefix`

> A prefix to delete objects. If the prefix is omitted or is empty, then all objects are deleted. > > _Type_: String > > _Required_: No > > _Update Requires_: replacement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL