Here are the steps to inject AWS secrets into a HarperDB container using Python:
- Create a secret in AWS Secrets Manager by logging into the AWS console and accessing the AWS cloud shell. Use a temporary file to store the secret in JSON format and create the secret using the AWS CLI.
- Set up a user in AWS IAM with appropriate permissions. Create a user, group, and attach the user to the group.
- Define a policy that allows getting the secret value from the specific secret ARN. Save the policy in a JSON file and use envsubst to replace the environment variable in the file.
- Create the policy and retrieve the policy ARN. Attach the policy to the group.
- Create an access key for the user and share it with the development team for authentication.
- Set up the developer's machine by installing the AWS CLI, creating a .env file with the necessary configuration and credentials, and exporting the environment variables.
- Retrieve the secret from the developer's machine using the AWS CLI to ensure it is working.
- Test with Docker by retrieving the secrets with AWS CLI, setting them as environment variables on the local system, and passing them to the HarperDB container.
- Verify the values of the environment variables in the running HarperDB container.
- Try retrieving the secret using Python code by installing boto3 and python-dotenv. Run the provided Python code locally to retrieve the secret from AWS Secrets Manager and create files for each key-value pair.
Make sure to follow the necessary installations, configurations, and commands for each step to inject the AWS secrets successfully.