What does it take to use AWS SSM Session Manager instead of SSH?
AdvancedProductionSecurity and Secrets
Answer
The aws_ssm connection plugin (shipped in the amazon.aws or community.aws collection, depending on version) tunnels commands through SSM, so no inbound port 22, no bastion and no key management are needed.
Requirements: SSM Agent on the instance and an instance profile with AmazonSSMManagedInstanceCore, the session-manager-plugin on the controller, an S3 bucket for module transfer, and controller IAM permissions for ssm:StartSession and the bucket.
[all:vars]
ansible_connection=amazon.aws.aws_ssm
ansible_aws_ssm_bucket_name=acme-ansible-ssm
ansible_aws_ssm_region=ap-south-1
Trade-offs: slower per-task round trips than SSH (consider fewer, larger tasks), and every action is logged in CloudTrail and optionally Session Manager logs, which is useful for audit.
More on Security and Secrets
How do you set up a secure automation user and SSH access?BeginnerHow do you give the automation user sudo with least privilege?IntermediateWhat are the alternatives to Ansible Vault for secrets, and when do you use them?IntermediateHow do you read AWS Secrets Manager and SSM parameters in a playbook?IntermediateHow do you integrate HashiCorp Vault with Ansible?AdvancedHow do you stop secrets from leaking into logs and output?Beginner