https://github.com/eighty4/c2
Cross-platform developer tooling for cloud-init user data
https://github.com/eighty4/c2
cloud-config cloud-init devops linux user-data
Last synced: about 1 month ago
JSON representation
Cross-platform developer tooling for cloud-init user data
- Host: GitHub
- URL: https://github.com/eighty4/c2
- Owner: eighty4
- License: bsd-2-clause
- Created: 2025-04-20T15:37:59.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-10-10T03:15:32.000Z (6 months ago)
- Last Synced: 2025-11-02T21:17:23.175Z (5 months ago)
- Topics: cloud-config, cloud-init, devops, linux, user-data
- Language: TypeScript
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
- Support: docs/SUPPORT.md
Awesome Lists containing this project
README
# Cloud Config
Blow up your `cloud-init` developer workflows!
See the [examples dir](https://github.com/eighty4/c2/tree/main/examples) for
examples running on your local machine or deploying to cloud providers.
## Getting started
```shell
npm i -g @eighty4/c2
c2 -h
```
## Using the CLI program
```
c2 ./cloud_init_dir
# base64 encode your user data
c2 --base64 ./cloud_init_dir
```
## Using the JS API
```
import { buildUserData } from '@eighty4/c2'
const userData: string = await buildUserData('./cloud_init_dir')
```
## Cloud Config data dir
Multiple user data are ordered by filenames and `01_` numbered prefixes help
declare execution order.
```
ls ./cloud_init_dir
01_upgrades.yml
02_security.yml
03_services.sh
```
Shell scripts are supported as `x-shellscript` and YAML is included as
`cloud-config` MIME types.
## Evaluating expressions in user data
Scripts and YAML support two template functions that can be used in
expressions.
### env()
Replaces expression with content of a local environment variable.
```bash
#!/bin/sh
ENV_VAR="${{ env('LOCAL_ENV_VAR') }}"
```
### file()
Looks up a file from your local filesystem and replaces the expression with
its content.
```yaml
#cloud-config
users:
- name: devops-baller
ssh_authorized_keys:
- ${{ file('~/.ssh/my_ssh_key.pub') }}
```
Relative, absolute and `~/` paths are supported.
## Contributing
I use `c2` for initializing Debian cloud instances and locally test with QEMU
and Ubuntu.
Feedback on your use cases and worfklows is greatly appreciated!