Home > OS >  Create an AWS credentials file in a Kubernetes pod
Create an AWS credentials file in a Kubernetes pod

Time:07-10

Can I put environment variables to aws credentials file and let aws configure recognize and parse the file? I have tried below. Look like the variable is not parsed by aws configure.

[default]
aws_access_key_id=${TEST_KEY_ID}
aws_secret_access_key=${TEST_SECRET_KEY}
[profile2]
aws_access_key_id=${TEST2_KEY_ID}
aws_secret_access_key=${TEST2_SECRET_KEY}

If I cannot, how can I create an AWS credentials file in a Kubernetes pod? I know we can generate a file using configMap. But I do not want to put key id and secret key in configMap directly since all Kubernetes code will be stored in git repository.

CodePudding user response:

I would suggest you create a new Kubernetes service account and then map it to a specific IAM role.

Reference: https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html

CodePudding user response:

Yes, you can put environment variables into pod. Then, type commands:

aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID 
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set region $AWS_REGION
aws configure set output $AWS_OUTPUT

Files config will automatically be created in pods. You can refer to the yaml file here: https://hub.docker.com/repository/docker/cuongquocvn/aws-cli-kubectl

  • Related