# cloud-toolkit

Standardizes the setup of aws, Datadog and other things

## Available functions

### parameter store

| function   | parameters                              | description                                                                    |
| ---------- | --------------------------------------- | ------------------------------------------------------------------------------ |
| getSecret  | parameter<br/>defaultValue (optional)   | Retrieves a single secret from parameter store by providing the path           |
| getSecrets | parameters<br/>defaultValues (optional) | Retrieves multiple secrets from parameter store by providing an array of paths |

### ses

| function | parameters | description                                    |
| -------- | ---------- | ---------------------------------------------- |
| sendMail | options    | Sends an email via SES or provided SMTP config |

### lambda

| function     | parameters                 | description                                          |
| ------------ | -------------------------- | ---------------------------------------------------- |
| invokeLambda | invocationType<br/>payload | Invokes set lambda with invocations type and payload |

### dynamodb

| function        | parameters                           | description                                              |
| --------------- | ------------------------------------ | -------------------------------------------------------- |
| batchWriteItems | table<br/>items                      | Creates multiple item in a defined table                 |
| deleteItem      | table<br/>key<br/>options (optional) | Deletes database item from defined table by given key    |
| getItem         | table<br/>key<br/>options (optional) | Returns item from Database by defined table and key      |
| putItem         | table<br/>key                        | Creates one item in defined table                        |
| queryTable      | table<br/>options (optional)         | Returns result items of query                            |
| scanTable       | table<br/>options (optional)         | Returns result items of scan                             |
| updateItem      | table<br/>key<br/>options (optional) | Updates item in database by provided table and given key |

### sqs

| function        | parameters                                                                      | description                                              |
| --------------- | ------------------------------------------------------------------------------- | -------------------------------------------------------- |
| deleteQueueItem | queueUrl<br/>receiptHandle                                                      | Deletes item from queue                                  |
| getQueueItems   | queueUrl<br/>maxNumberOfMessages (optional)                                     | Retrieves items from queue                               |
| getQueueUrl     | queueName                                                                       | Returns queue url which is needed for all other requests |
| sendMessage     | queueUrl<br/>message<br/>messageAttributes(optional)<br/>messageDelay(optional) | Creates an item in the queue                             |

### logger

A winston instance will be created with default log levels https://github.com/winstonjs/winston?tab=readme-ov-file#logging

## Releasing pre-release versions

This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/) with support for pre-release channels via dedicated branches.

| Branch  | npm dist-tag | Example version |
| ------- | ------------ | --------------- |
| `next`  | `next`       | `1.2.0-next.1`  |
| `beta`  | `beta`       | `1.2.0-beta.1`  |
| `alpha` | `alpha`      | `1.2.0-alpha.1` |

### How to publish a pre-release

1. **Create or check out the target branch** from the commit you want to release:

   ```sh
   git checkout -b beta   # or alpha / next
   ```

2. **Push the branch** to trigger the CI pipeline:

   ```sh
   git push --force origin HEAD:beta   # or alpha / next
   ```

   The pipeline will automatically run `semantic-release`, which detects the branch name, bumps the version with the appropriate pre-release tag, and publishes it to npm under the matching dist-tag. Check [Actions page](https://github.com/allthings/cloud-toolkit/actions) for the release logs.

3. **Install the pre-release** in another project:

   ```sh
   npm install @allthings/cloud-toolkit@beta   # or @alpha / @next
   ```

   or use exact release (check [versions on npm](https://www.npmjs.com/package/@allthings/cloud-toolkit?activeTab=versions)):

   ```sh
   npm install @allthings/cloud-toolkit@x.x.x-beta.x
   ```

4. **Promote to stable** – once the pre-release is validated, create a PR form your target branch.

> **Note:** commits on pre-release or target branches must still follow the [Conventional Commits](https://www.conventionalcommits.org/) specification so that semantic-release can determine the correct version bump.
