skip to Main Content

I was trying to get a notification, it doesn’t matter how as though via email, sms, etc. The notification shouldn’t be for state-changes only, which I have already done. Instead, I’d like to be notified when a EIP is disassociated, either network interface or volume is detached, or something bearing on affecting the Ec2 itself.

Is this possible?

I have been working with Amazon EventBridge rules, but I only get captured when is stopped, terminated or running.

2

Answers


  1. Chosen as BEST ANSWER

    So, I figured it out as you said it @paolo. Basically, I have looked for the event on CloudTrail, and match it on Eventbridge; however, I had to do all the Event Patterns separately as follows to make them work.

    For the detach network which is attach to the instance I want to monitor:

    {
    "source": ["aws.ec2"],
    "detail-type": ["AWS API Call via CloudTrail"],
    "detail": {
        "eventSource": ["ec2.amazonaws.com"],
        "eventName": ["DetachNetworkInterface"],
        "requestParameters": {"attachmentId": ["eni-attach-0671ffxxx10bxxx46"]}
    }
    

    And for the instance status

    {
    "source": ["aws.ec2"],
    "detail-type": ["AWS API Call via CloudTrail"],
    "detail": {
        "eventSource": ["ec2.amazonaws.com"],
        "eventName": [
            "RunInstances",
            "StartInstances",
            "StopInstances",
            "TerminateInstances"
        ],
        "requestParameters": {
            "instancesSet": {
                "items": {"instanceId": ["i-09513xxxd3xxxa04"]}
            }
        }
    }
    

    And so on for AIM roles, DetachVolumes, ModifyNetworkInterface, etc.


  2. I’d like to be notified when a EIP is disassociated, either network interface or volume is detached, or something bearing on affecting the Ec2 itself.

    If you want to be notified of a specific event, such as when an EIP is disassociated, I would recommend you use EventBridge with a CloudTrail pattern (in this case, for the DisassociateAddress event).

    If you want to be notified of any changes to the EC2 instance, I would recommend you use Config.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search