Source Repository: daniel-cohen/secretsfetcher
A CLI tool to fetch secrets from a secret management store and write them to the file system as files.
The aws command will fetch multiple secrets and write them as individual files to the output folder
Usage: secretsfetcher aws [flags]
Flags:
We allow configuration in 3 ways leveraging viper (in priority order)
Sample environment variable override values:
"APP_LOGLEVEL": "debug",
"APP_AWS_PREFIXFILTER": "my-app/user-secrest/",
"APP_AWS_PATHTRANSLATION": "@",
"APP_AWS_REGION": "ap-southeast-2"
"APP_AWS_TAGKEYFILTERS": "app,user-type",
"APP_AWS_TAGVALUEFILTERS": "my-app,some-id",
Sample configuration file:
LogLevel: info
Aws:
prefixFilter: "mysecretprefix/"
tagKeyFilters:
- tag_name_prefix1
- tag_name_prefix2
tagValueFilters:
- tag_value_prefix1
Region: ""
PathTranslation: "_"
## Operation modes
The aws secrets fetcher command can operate in 2 modes:
1. Using a secrets manifest file.
Note: Make sure the IAM role policy allows:
```json
"Action": "secretsmanager:GetSecretValue",
```
2. Listing and fetching all secrets using a prefix + tag (key/value) filters.
Make sure your secrets are labeled properly and that the IAM role policy allows:
```json
"Action": "secretsmanager:ListSecrets"
```
Sample IAM policy to allow both modes:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "arn:aws:secretsmanager:us-west-2:111122223333:secret:SOME_SECRET_PREFIX/*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "secretsmanager:ListSecrets",
"Resource": "*"
}
]
}
The secrets manifest file lists secrets to fetch by secretsfetcher. The secrets manifest has a similar structure to the aws SecretProviderClass CRD. As desribed here:
paramters:
Sample manifest file:
provider: aws
secretObjects:
- objectName: "arn:aws:secretsmanager:us-west-2:111122223333:secret:aes128-1a2b3c"
objectType: "secretsmanager"
objectVersion: "ab24b1be-c0a9-4b07-841d-cd9df6f480e9" # [OPTIONAL] object version id, default to latest if empty
- objectName: "MySecret2"
objectType: "secretsmanager"
objectVersionLabel: "AWSCURRENT" # [OPTIONAL] object version stage, default to latest if empty
- objectName: "MySecret3"
objectType: "secretsmanager"
region: ap-southeast-2
pathTranslation: "$"
For comparison, this is a equivalent aws SecretProviderClass :
apiVersion: secrets-store.csi.x-k8s.io/v1alpha1
kind: SecretProviderClass
metadata:
name: aws-secrets
spec:
provider: aws
parameters:
objects: |
array:
- |
objectName: "arn:aws:secretsmanager:us-west-2:111122223333:secret:aes128-1a2b3c"
objectType: "secretsmanager"
objectVersion: "ab24b1be-c0a9-4b07-841d-cd9df6f480e9"
- |
objectName: "MySecret2"
objectType: "secretsmanager"
objectVersionLabel: "AWSCURRENT"
- |
objectName: "MySecret3"
objectType: "secretsmanager"
region: ap-southeast-2
pathTranslation: "$"
You can configure for following search parameters (supported through cli flags, configuration and ENV vars):
Content type
Image
Digest
sha256:d8a9a9f45…
Size
6.8 MB
Last updated
almost 4 years ago
docker pull danielco/secretsfetcher