0
votes

I have an OpenShift cluster running in AWS that dynamically creates volumes for projects. I need all my resources (EC2 instances, EBS Volumes, etc.) to have some required and enforced tags. However, volumes created by OpenShift/Kubernetes only come with a few default tags and I cannot, from the OpenShift side, add custom tags.

I would like, when volumes are attached to an instance, to have volumes inherit the tags from the instance they are attached to. I already have a lambda script which can do this, but the CloudWatch event for attachVolume only triggers when a volume FAILS to attach. Is there a way to trigger a CloudWatch event to trigger when a volume successfully attaches to an instance?

My Useless CloudWatch Event:

{
  "source": [
    "aws.ec2"
  ],
  "detail-type": [
    "EBS Volume Notification"
  ],
  "detail": {
    "event": [
      "attachVolume"
    ]
  }
}
1

1 Answers

0
votes

This CloudWatch Event Rule will be triggered when an EBS AttachVolume occurs:

{
  "source": [
    "aws.ec2"
  ],
  "detail-type": [
    "AWS API Call via CloudTrail"
  ],
  "detail": {
    "eventSource": [
      "ec2.amazonaws.com"
    ],
    "eventName": [
      "AttachVolume"
    ]
  }
}