Skip to content

Commit cc7fc31

Browse files
committed
feat: key directory docs & makefile changes
1 parent c291f9d commit cc7fc31

File tree

2 files changed

+60
-27
lines changed

2 files changed

+60
-27
lines changed

module/move/willbe/template/deploy/key/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
!.gitignore
33
!*.md
44
!pack.sh
5+
-*

module/move/willbe/template/deploy/key/Readme.md

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,82 @@
1-
# Deploy credentials
1+
# Keys
22

3-
A list of all keys you'd need to deploy your project on different hosts.
3+
This document provides a concise example of an environment configuration script, used to set up environment variables for a project.
4+
These variables configure application behavior without altering the code.
45

5-
- [Deploy credentials](#deploy-credentials)
6-
- [Files](#files)
7-
- [Env vars](#env-vars)
6+
- [Keys](#keys)
7+
- [Examples](#examples)
8+
- [`-gcp.sh`](#-gcpsh)
9+
- [`-hetzner.sh`](#-hetznersh)
10+
- [`-aws.sh`](#-awssh)
11+
- [How to Run](#how-to-run)
812
- [Retrieving keys](#retrieving-keys)
913
- [How to get `service_account.json`](#how-to-get-service_accountjson)
1014
- [How to get `SECRET_STATE_ARCHIVE_KEY`](#how-to-get-secret_state_archive_key)
1115
- [How to get `SECRET_CSP_HETZNER`](#how-to-get-secret_csp_hetzner)
1216
- [How to get `SECRET_AWS_ACCESS_KEY_ID` and `SECRET_AWS_ACCESS_KEY`](#how-to-get-secret_aws_access_key_id-and-secret_aws_access_key)
1317

14-
## Files
1518

16-
All secrets can be provided as files in current directory:
19+
## Examples
1720

18-
- [service_account.json](./service_account.json) - default credentials for the service account to use in deployment.
19-
- [rsa_ssh_key](./rsa_ssh_key) - SSH Private key that will be used for redeployment.
20-
- [rsa_ssh_key.pub](./rsa_ssh_key.pub) - SSH Private key that will be used for redeployment.
21-
- [`SECRET_STATE_ARCHIVE_KEY`](./SECRET_STATE_ARCHIVE_KEY) - [📃] base64 encoded AES256 key to encrypt and decrypt .tfstate files.
22-
- [`SECRET_CSP_HETZNER`](./SECRET_CSP_HETZNER) - [📃] Hetzner token for deploying a server.
23-
- [`SECRET_AWS_ACCESS_KEY_ID`](./SECRET_AWS_ACCESS_KEY_ID) - [📃] Access Key ID from AWS Credentials. Created at the same time as the Access Key itself.
24-
- [`SECRET_AWS_ACCESS_KEY`](./SECRET_AWS_ACCESS_KEY) - [📃] Access Key for AWS API. Has to be accompanied with respectful Access Key ID.
21+
### `-gcp.sh`
2522

26-
## Env vars
23+
Contents example for the file `-gcp.sh`. This is a required configuration for all deploy targets.
2724

28-
Some secrets can be presented as an env var:
25+
```bash
26+
#!/bin/bash
27+
CSP=gce
28+
SECRET_STATE_ARCHIVE_KEY=qK1/4m60aZvclYi4bZFeBl8GxpyWcJ2iEevHN+uMy7w=
2929

30-
- [`SECRET_STATE_ARCHIVE_KEY`](./SECRET_STATE_ARCHIVE_KEY) - [📃] base64 encoded AES256 key to encrypt and decrypt .tfstate files.
31-
- [`SECRET_CSP_HETZNER`](./SECRET_CSP_HETZNER) - [📃] Hetzner token for deploying a server.
32-
- [`SECRET_AWS_ACCESS_KEY_ID`](./SECRET_AWS_ACCESS_KEY_ID) - [📃] Access Key ID from AWS Credentials. Created at the same time as the Access Key itself.
33-
- [`SECRET_AWS_ACCESS_KEY`](./SECRET_AWS_ACCESS_KEY) - [📃] Access Key for AWS API. Has to be accompanied with respectful Access Key ID.
30+
FILE_PATH="$( realpath -qms "${BASH_SOURCE[0]:-$PWD}" )"
31+
DIR_PATH="${FILE_PATH%/*}"
32+
head -c -1 << EOF > ${DIR_PATH}/-service_account.json
33+
{
34+
// Your service_account information
35+
}
36+
EOF
37+
```
38+
39+
- `CSP`: (Optional) Specifies deployment to GCE.
40+
- `SECRET_STATE_ARCHIVE_KEY`: Base64 encoded AES256 key to encrypt and decrypt .tfstate files.
41+
- `-service_account.json`: Default credentials for the service account to use in deployment.
42+
43+
### `-hetzner.sh`
44+
45+
Contents example for the file `-hetzner.sh`:
46+
47+
```bash
48+
CSP=hetzner
49+
SECRET_CSP_HETZNER=your_token_here
50+
```
3451

35-
Env vars have a higher priority then the files.
52+
- `CSP`: Specifies deployment to Hetzner.
53+
- `SECRET_CSP_HETZNER`: Hetzner token for deploying a server.
3654

37-
For ENV [📃] secrets values can be placed in files in this directory for automatic exporting to env during deployment.
55+
### `-aws.sh`
3856

39-
Example of a file that will be pulled to env vars:
57+
Contents example for the file `-aws.sh`:
4058

41-
File name: `SECRET_CSP_HETZNER`
42-
File contents:
59+
```bash
60+
CSP=aws
61+
SECRET_AWS_ACCESS_KEY_ID=aws_credentials_here
62+
SECRET_AWS_ACCESS_KEY=aws_credentials_here
4363
```
44-
hetzner_token_123
64+
65+
- `CSP`: Specifies deployment to AWS.
66+
- `SECRET_AWS_ACCESS_KEY_ID`: Access Key ID from AWS Credentials. Created at the same time as the Access Key itself.
67+
- `SECRET_AWS_ACCESS_KEY`: Access Key for AWS API. Has to be accompanied with respectful Access Key ID.
68+
69+
## How to Run
70+
71+
To apply these variables to your current shell session, use:
72+
73+
```bash
74+
. ./key/-gcp.sh
75+
. ./key/-hetzner.sh
4576
```
4677

47-
Will export a variable to env like so `SECRET_CSP_HETZNER=hetzner_token_123`
78+
This command sources the script, making the variables available in your current session and allowing deployment to Hetzner.
79+
Ensure `-env.sh` is in the `key` directory relative to your current location.
4880

4981
## Retrieving keys
5082

0 commit comments

Comments
 (0)