From e7735c3ee1661ad4269ac9862c61600714668ff0 Mon Sep 17 00:00:00 2001 From: Andrew Garrett <2rs2ts@users.noreply.github.com> Date: Sat, 4 Mar 2017 20:12:55 -0800 Subject: [PATCH] Add event IDs to CF Stack events (#852) So that events can be uniquely identified. I tried to match the format documented here: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-listing-event-history.html --- moto/cloudformation/models.py | 2 ++ tests/test_cloudformation/test_cloudformation_stack_crud.py | 1 + .../test_cloudformation/test_cloudformation_stack_crud_boto3.py | 1 + 3 files changed, 4 insertions(+) diff --git a/moto/cloudformation/models.py b/moto/cloudformation/models.py index a9dda8fdc..e9493b2b6 100644 --- a/moto/cloudformation/models.py +++ b/moto/cloudformation/models.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals from datetime import datetime import json +import uuid import boto.cloudformation from moto.core import BaseBackend @@ -105,6 +106,7 @@ class FakeEvent(object): self.resource_status_reason = resource_status_reason self.resource_properties = resource_properties self.timestamp = datetime.utcnow() + self.event_id = uuid.uuid4() class CloudFormationBackend(BaseBackend): diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud.py b/tests/test_cloudformation/test_cloudformation_stack_crud.py index 7eb563c42..1a2d16e94 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud.py @@ -522,6 +522,7 @@ def test_describe_stack_events_shows_create_update_and_delete(): for event in events: event.stack_id.should.equal(stack_id) event.stack_name.should.equal("test_stack") + event.event_id.should.match(r"[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}") if event.resource_type == "AWS::CloudFormation::Stack": event.logical_resource_id.should.equal("test_stack") diff --git a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py index 98ed213e5..112b8bd04 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py +++ b/tests/test_cloudformation/test_cloudformation_stack_crud_boto3.py @@ -358,6 +358,7 @@ def test_stack_events(): for event in events: event.stack_id.should.equal(stack.stack_id) event.stack_name.should.equal("test_stack") + event.event_id.should.match(r"[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}") if event.resource_type == "AWS::CloudFormation::Stack": event.logical_resource_id.should.equal("test_stack")