I'm working on a Terraform project where I need to create an AWS IAM user and generate programmatic access keys for them. My current approach involves exporting these keys through the outputs.tf file and then using them in a separate module linked to AWS Secrets Manager for secure storage.
I have concerns about this method, particularly regarding the security implications of exposing access keys, even temporarily, in the Terraform state file (terraform.state). While I understand the importance of securing the state file, I'm wondering if this approach is standard or advisable.
An alternative I'm considering is creating the IAM user and keys outside of Terraform and then injecting the access keys into the project via the terraform.tfvars file.
Could someone advise on the best practices for this scenario? Specifically, I'm interested in:
The pros and cons of managing IAM users and their access keys directly within Terraform, especially concerning security best practices.
Whether creating IAM users outside of Terraform and then passing the keys through terraform.tfvars is a safer or more recommended approach.
Any other considerations or recommended strategies for securely managing IAM credentials in Terraform configurations.
Thank you in advance for your insights and recommendations!