First, you can store AWS Access Key and Secret Key in AWS Secret Manager, but I strongly not recommend that. But I can still offer a solution to easily do that:
- manually put your secret value in json or create one with
pysecret
.
from pysecret import AWSSecret
aws_profile = "my_aws_profile"
aws = AWSSecret(profile_name=aws_profile)
secret_id = "my-example-secret"
secret_data = {
"iam_user_1": {
"access_key": "AAAAAAAAAAAAAAAAAAAAA",
"secret_key": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"iam_user_2": {
"access_key": "BBBBBBBBBBBBBBBBBBBBB",
"secret_key": "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
}
}
aws.deploy_secret(name=secret_id, secret_data=secret_data) # or you can pass kms_key_id if you created a custom kms key
- read your secret value in lambda function or in any of your python code.
aws = AWSSecret(profile_name=aws_profile) # in lambda code, don't need ``profile_name=aws_profile``
access_key = aws.get_secret_value(secret_id="my-example-secret", key="iam_user_1.access_key") # AAAAAAAAAAAAAAAAAAAAA
secret_key = aws.get_secret_value(secret_id="my-example-secret", key="iam_user_1.secret_key") # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
access_key = aws.get_secret_value(secret_id="my-example-secret", key="iam_user_1.access_key") # BBBBBBBBBBBBBBBBBBBBB
secret_key = aws.get_secret_value(secret_id="my-example-secret", key="iam_user_1.secret_key") # YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
I created an open source library called pysecret, here's the documentation of AWS Secret Manager integration: https://github.com/MacHu-GWU/pysecret-project#aws-key-management-service-and-secret-manager-integration

Second
When ever you want to create an AWS Access Key pair, think of who is going to use it, Human or Machine. If it is Machine, please use IAM Role instead of IAM User. If it is Human, the Human should be responsible to securely store it, NOT AWS Secret Manager.
Hope this answers your question.