---
title: Charmhub | Deploy Vault using Charmhub - The Open Operator Collection
description: Deploy the latest version of Vault as a Kubernetes Operator on any cloud.
url: https://charmhub.io/vault-k8s/libraries/vault_s3
---

# Vault

[Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

* [Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

Platform:

2.0/stable 590

```
juju deploy vault-k8s --channel 2.0/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/vault-k8s/libraries/vault_s3#drawer)

## charms.vault\_k8s.v0.vault\_s3

* [*Docstrings*Docstrings](https://charmhub.io/vault-k8s/libraries/vault_s3)
  [*Code*Source code](https://charmhub.io/vault-k8s/libraries/vault_s3/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.vault_k8s.v0.vault_s3
    ```

    [Download vault\_s3.py](https://charmhub.io/vault-k8s/libraries/vault_s3/download)
  + *Last updated* 27 Sep 2024
  + *Revision* Library version 0.3

S3 helper functions for Vault charms.

##### Usage

Add the following dependencies to the charm's requirements.txt file:

```
```
boto3
boto3-stubs[s3]
```
```

---

Index

* [class LogAdapter](https://charmhub.io/vault-k8s/libraries/vault_s3#logadapter)
* + [def process(
    self,
    msg,
    kwargs)](https://charmhub.io/vault-k8s/libraries/vault_s3#logadapter-process)
* [class S3Error](https://charmhub.io/vault-k8s/libraries/vault_s3#s3error)
* [class S3](https://charmhub.io/vault-k8s/libraries/vault_s3#s3)
* + [def \_\_init\_\_(
    self,
    access\_key,
    secret\_key,
    endpoint,
    region)](https://charmhub.io/vault-k8s/libraries/vault_s3#s3-__init__)
* + [def create\_bucket(
    self,
    bucket\_name)](https://charmhub.io/vault-k8s/libraries/vault_s3#s3-create_bucket)
* + [def upload\_content(
    self,
    content,
    bucket\_name,
    key)](https://charmhub.io/vault-k8s/libraries/vault_s3#s3-upload_content)
* + [def get\_object\_key\_list(
    self,
    bucket\_name,
    prefix)](https://charmhub.io/vault-k8s/libraries/vault_s3#s3-get_object_key_list)
* + [def get\_content(
    self,
    bucket\_name,
    object\_key)](https://charmhub.io/vault-k8s/libraries/vault_s3#s3-get_content)

#### class LogAdapter

Description

Adapter for the logger to prepend a prefix to all log lines. None

Methods

LogAdapter.
process(

*self*

,
msg

,
kwargs
)

Description

Decides the format for the prepended text. None

#### class S3Error

Description

Base class for S3 errors. None

#### class S3

Description

A class representing an S3 session allowing S3 operations. None

Methods

S3.
\_\_init\_\_(

*self*

,
access\_key: str

,
secret\_key: str

,
endpoint: str

,
region
)

S3.
create\_bucket(

*self*

,
bucket\_name: str
)

Create S3 bucket.

Arguments

bucket\_name

S3 bucket name to be created.

Returns

bool

True if the bucket was created, False otherwise.

Description

If the bucket already exists, it will be skipped.

S3.
upload\_content(

*self*

,
content

,
bucket\_name: str

,
key: str
)

Upload the provided contents to the provided S3 bucket.

Arguments

content

File like object containing the content to upload.

bucket\_name

S3 bucket name.

key

S3 object key.

Returns

bool

True if the upload was successful, False otherwise.

S3.
get\_object\_key\_list(

*self*

,
bucket\_name: str

,
prefix: str
)

Get list of object key in an S3 bucket.

Arguments

bucket\_name

S3 bucket name.

prefix

Prefix to filter object keys by.

Returns

List[str]

List of object keys.

S3.
get\_content(

*self*

,
bucket\_name: str

,
object\_key: str
)

Get object content from S3 bucket by key.

Arguments

bucket\_name

S3 bucket name.

object\_key

S3 object key.

Returns

File like object with the content of the S3 object, or None if the object does not exist.
