- Creating an IAM role for EC2 so Systems Manager can manage the instance.
- Launching an EC2 instance and attaching the IAM instance profile.
- Running an ad-hoc command using Systems Manager Run Command.
- Creating a State Manager association to keep the SSM Agent updated on a schedule.
- The SSM Agent must be installed on the instance. Most Amazon Linux, Amazon Linux 2, and recent Ubuntu AMIs include it. See AWS SSM Agent docs: https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html
- The instance must have network access to Systems Manager endpoints (Internet access or VPC endpoints).
- The EC2 instance must use an instance profile with the
AmazonSSMManagedInstanceCorepolicy. See: https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-instance-profile.html
Before continuing, confirm the instance has the SSM Agent and either internet access or VPC endpoints for Systems Manager. Without network access or the correct IAM permissions, the instance will not appear as a managed node in Systems Manager.
If the instance does not appear in Systems Manager after launch, verify: the instance profile attached includes
AmazonSSMManagedInstanceCore, the SSM Agent is running, and security groups/NACLs and routing allow access to Systems Manager endpoints (or you have configured VPC endpoints).1) Create an EC2-managed IAM role for Systems Manager
Create an IAM role for EC2 and attach the managed policyAmazonSSMManagedInstanceCore. This policy grants the core permissions required for Systems Manager to manage the instance.
- Console flow: IAM → Roles → Create role → Select EC2 as the trusted entity → Attach
AmazonSSMManagedInstanceCore→ Create. - Suggested role name:
SSM-EC2-Role(remember this for the instance profile selection when launching EC2).

2) Launch an EC2 instance and attach the role
When launching the EC2 instance, set the IAM instance profile to the role you created (for example,SSM-EC2-Role) in the Advanced Details section.
- Choose an AMI (one that includes SSM Agent is recommended).
- Choose an instance type (demo uses
t3.micro). - In Advanced Details → IAM instance profile, choose
SSM-EC2-Role. - Configure networking and security groups so the instance can reach Systems Manager endpoints (Internet Gateway/NAT or VPC endpoints).
- Launch the instance and wait until its state is
running.

3) Use Run Command for an ad-hoc operation
Run Command is designed for one-off or interactive tasks across one or many managed instances. For example, use theAWS-UpdateSSMAgent document to update the SSM Agent immediately.
Steps (console):
- Systems Manager → Run Command.
- Choose the document:
AWS-UpdateSSMAgent. - Select targets: choose instances manually, by tags, or by resource group.
- Configure parameters (defaults are usually fine for
AWS-UpdateSSMAgent). - Execute and monitor command status.


- Target(s) selected
- Document chosen (e.g.,
AWS-UpdateSSMAgent) - Confirm parameters and run
- Monitor status and view output per target
4) Use State Manager to enforce desired state on a schedule
State Manager applies a document (an association) to target instances on a schedule or continuously to ensure the desired state is enforced over time. This is ideal for recurring tasks such as keeping the SSM Agent updated across your fleet. Steps (console):- Systems Manager → State Manager → Create association.
- Name the association (e.g.,
Demo-State-Manager). - Select the document:
AWS-UpdateSSMAgent. - Provide parameters (defaults are typically fine).
- Select targets (instances, tags, or all instances).
- Optionally set an association execution role if State Manager needs cross-service permissions.
- Configure a schedule: run once, manual, repeating interval, or a CRON expression.
- (Optional) Configure concurrency, output to S3, severity, and alarms under Options.



Run Command vs State Manager — when to use each
Summary
- Use Run Command for immediate, on-demand tasks like updating the SSM Agent on specific instances.
- Use State Manager to schedule recurring operations and to enforce a desired configuration across your instances.
- Ensure instances have the SSM Agent, correct IAM instance profile (
AmazonSSMManagedInstanceCore), and network access (Internet or VPC endpoints) so they are visible as managed nodes in Systems Manager.
- AWS Systems Manager Run Command: https://docs.aws.amazon.com/systems-manager/latest/userguide/execute-remote-commands.html
- AWS Systems Manager State Manager: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-state-manager.html
- SSM Agent documentation: https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent.html
- Create an IAM instance profile for Systems Manager (
AmazonSSMManagedInstanceCore): https://docs.aws.amazon.com/systems-manager/latest/userguide/setup-instance-profile.html