Can we trigger events based on AWS Systems Manager Instance Registration?

0

Hi, We would like to trigger events based on when an instance (EC2 or OnPrem) is registered in Systems Manager, an example, would be to trigger an instance tagging mechanism so that tags are applied as soon as the instance is registered.

I can see PutInventory in Cloudtrail gets created on registration and then occurs every 12h thereafter, but we dont need anything that cyclical. We are considering an Association that is configured without a Schedule, but this triggers runCommand on the instance which is unnecessary data transit across the WAN. It would be good if the event could trigger eventBridge to then trigger a StepFunction, but we're looking for the best trigger.

Does anyone have any suggestions on the best trigger for this?

3 Answers
0

Hi Team, I understand that you would like to trigger events on EC2 Instance managed via Systems Manager. You can trigger events via Event Bridge.

Example for EventBridge :

{
  "source": ["aws.ec2"],
  "detail-type": ["EC2 Instance State-change Notification"],
  "detail": { 
    "state": ["running"],
    "tagSpecificationSet": {
      "items": {
        "tags": {
          "key": ["Name"]
        }
      }
    }
  }
}

Kindly refer the link : https://docs.aws.amazon.com/systems-manager/latest/userguide/running-automations-event-bridge.html

https://aws.amazon.com/blogs/security/how-to-automatically-tag-amazon-ec2-resources-in-response-to-api-events/

Additionally, I am also providing you a Github link for sample resource tagging automation that might help you.

https://github.com/aws-samples/resource-tagging-automation

answered a year ago
  • Hi, thanks for your answer. Will this work for AWS::SSM::ManagedInstance (Hybrid/OnPrem) as well as AWS::SSM::EC2Instance? I see lots of triggers in EventBridge for EC2 but we also need this automation to work primarily against ManagedInstances . Our fleet is 99.9% on prem

0

Hello, Hope you are doing good!! Yes you are right it is for AWS::SSM::EC2Instance. EventBridge delivers a stream of real-time data from your own applications, software-as-a-service (SaaS) applications, and AWS services and routes that data to targets such as AWS Lambda. Yes you are right and I am also sending you a link to check the integration with EventBridge. https://aws.amazon.com/eventbridge/integrations/ https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-saas.html

answered a year ago
0

EventBridge supports events from the following AWS Systems Manager capabilities that you can trigger to on premises and EC2 both. Example you can trigger Automation via Event Bridge to both ( EC2 or On premises).

  • Automation (Events are emitted on a best effort basis.)
  • Change Calendar (Events are emitted on a best effort basis.)
  • Compliance
  • Inventory (Events are emitted on a best effort basis.)
  • Maintenance Windows (Events are emitted on a best effort basis.)
  • Parameter Store (Events are emitted on a best effort basis.)
  • Run Command (Events are emitted on a best effort basis.)
  • State Manager (Events are emitted on a best effort basis.)

https://docs.aws.amazon.com/systems-manager/latest/userguide/monitoring-eventbridge-events.html

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions