Amazon EventBridge rule to AWS Systems Manager automation
Amazon EventBridge → AWS Systems Manager
Create an EventBridge Rule to trigger an AWS Systems Manager automation runbook.
This pattern will create an EventBridge rule that is configured to trigger when an EC2 instance goes into the "running" state. The rule will then execute the AWSSupport-ConfigureEC2Metadata Automation Runbook against that instance to disable IMDSv1.
Once the stack is deployed, launch a new EC2 Instance, and then navigate to https://console.aws.amazon.com/systems-manager/automation/executions. There will be a new execution of the `AWSSupport-ConfigureEC2Metadata` document against the new instance.
Cleanup
1. Delete the stack: sam delete --stack-name STACK_NAME.
2. Confirm the stack has been deleted: aws cloudformation list-stacks --query "StackSummaries[?contains(StackName,'STACK_NAME')].StackStatus"