By centrally managing confidential information in the local environment with 1Password, you can prevent the risk of disclosing API Keys, etc. to github.
Setup
The following two should be installed.
Get AWS access information from 1Password
The following settings can be used to access AWS from your own programs as well as the AWS CLI.
-
Store access information in 1Password
-
Set credential_process in ~/.aws/config
[default]
credential_process = sh -c "op item get 'aws-credential-default' --format json --fields label=aws_access_key_id --fields label=aws_secret_access_key | jq 'map({key: .label, value: .value}) | {Version: 1, AccessKeyId:.[0].value, SecretAccessKey:.[1].value}'"
Retrieve environment variables from 1Password
-
Save API Key in 1Password
-
Set environment variable from 1Password at program runtime
OPENAI_API_KEY=$(op item get OpenAI --fields label=api-key --format json | jq -r '.value') \
python gpt.py