Interview Prep/Ansible/Security and Secrets

How do you read AWS Secrets Manager and SSM parameters in a playbook?

IntermediateProductionSecurity and Secrets
Answer
vars:
  db_password: "{{ lookup('amazon.aws.secretsmanager_secret', 'prod/app/db', region='ap-south-1') }}"
  api_key: "{{ lookup('amazon.aws.ssm_parameter', '/prod/app/api_key', region='ap-south-1', decrypt=true) }}"

Lookups run on the control node, using its AWS credentials (an instance role is best). The IAM policy should allow only secretsmanager:GetSecretValue on the specific ARNs. Lookups are re-evaluated every time the variable is used, so assign the value once with set_fact under no_log: true when it is used a lot.

All Ansible questions Roadmap: Ansible

More on Security and Secrets