Skip to content

Conversation

@CajuCLC
Copy link

@CajuCLC CajuCLC commented Apr 22, 2025

Issue #, if available:
Issue 137: Pass DEFAULT_API_KEYS via Docker env

Description of changes:

  • Modified api/settings.py to read DEFAULT_API_KEYS from the environment variable.
  • Allows users to set DEFAULT_API_KEYS dynamically through Docker, providing enhanced flexibility for authentication configuration.

Example Docker command to run with custom API key:

docker run -d --name bedrock-gateway \
  -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
  -e AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN \
  -e AWS_REGION=us-east-1 \
  -e DEFAULT_API_KEYS=your_custom_api_key \
  -p 8000:80 \
  bedrock-gateway

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@CajuCLC CajuCLC temporarily deployed to AWS_ROLE_TO_ASSUME April 22, 2025 02:39 — with GitHub Actions Inactive
Copy link
Contributor

@LionsAd LionsAd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer-Review: Looks great to me!

@zxkane
Copy link
Member

zxkane commented Oct 15, 2025

It won't support the hardcoded key. Use the env variables for secrets or api key.

elif api_key_secret_arn:
sm = boto3.client("secretsmanager")
try:
response = sm.get_secret_value(SecretId=api_key_secret_arn)
if "SecretString" in response:
secret = json.loads(response["SecretString"])
api_key = secret["api_key"]
except ClientError:
raise RuntimeError("Unable to retrieve API KEY, please ensure the secret ARN is correct")
except KeyError:
raise RuntimeError('Please ensure the secret contains a "api_key" field')
elif api_key_env:
api_key = api_key_env

@zxkane zxkane closed this Oct 15, 2025
@CajuCLC
Copy link
Author

CajuCLC commented Oct 15, 2025

It won't support the hardcoded key. Use the env variables for secrets or api key.

elif api_key_secret_arn:
sm = boto3.client("secretsmanager")
try:
response = sm.get_secret_value(SecretId=api_key_secret_arn)
if "SecretString" in response:
secret = json.loads(response["SecretString"])
api_key = secret["api_key"]
except ClientError:
raise RuntimeError("Unable to retrieve API KEY, please ensure the secret ARN is correct")
except KeyError:
raise RuntimeError('Please ensure the secret contains a "api_key" field')
elif api_key_env:
api_key = api_key_env

This is not for the secrets or api key. This is for the PASSWORD. But it seems someone removed it on another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants