def test_handle_stack_event_raises_exception_on_rollback_complete(self, _): event = { 'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic', 'StackName': 'my-stack', 'LogicalResourceId': 'my-stack', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'ROLLBACK_COMPLETE' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() with self.assertRaises(CfnStackActionFailedException): cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE", "my-stack")
def test_handle_stack_event_raises_exception_on_rollback_complete(self, _): event = { 'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic', 'StackName': 'my-stack', 'LogicalResourceId': 'VPC', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'ROLLBACK_COMPLETE' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() with self.assertRaises(CfnStackActionFailedException): cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE")
def test_handle_stack_event_returns_expected_event(self, _): event = { 'PhysicalResourceId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'StackName': 'my-stack', 'LogicalResourceId': 'my-stack', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'CREATE_COMPLETE' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE", "my-stack") self.assertDictEqual(event, result)
def test_handle_stack_event_returns_none_on_rollback_in_progress_state( self, _): event = { 'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic', 'StackName': 'my-stack', 'LogicalResourceId': 'my-stack', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'ROLLBACK_IN_PROGRESS', 'ResourceStatusReason': 'Foo' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE", "my-stack") self.assertIsNone(result)
def test_handle_stack_event_returns_none_if_event_has_not_expected_state(self, _): event = { 'PhysicalResourceId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'StackName': 'my-stack', 'LogicalResourceId': 'cfn-sphere-test-vpc', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'CREATE_IN_PROGRESS' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE") self.assertIsNone(result)
def test_handle_stack_event_returns_none_if_event_is_no_stack_event(self, _): event = { 'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic', 'StackName': 'my-stack', 'LogicalResourceId': 'Topic', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::SNS::Topic', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'CREATE_COMPLETE' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE", "my-stack") self.assertIsNone(result)
def test_handle_stack_event_returns_none_on_rollback_in_progress_state(self, _): event = { 'PhysicalResourceId': 'arn:aws:sns:eu-west-1:1234567890:my-topic', 'StackName': 'my-stack', 'LogicalResourceId': 'VPC', 'StackId': 'arn:aws:cloudformation:eu-west-1:1234567890:stack/my-stack/my-stack-id', 'ResourceType': 'AWS::CloudFormation::Stack', 'Timestamp': datetime.datetime(2016, 4, 1, 8, 3, 27, 548000, tzinfo=tzutc()), 'EventId': 'my-event-id', 'ResourceStatus': 'ROLLBACK_IN_PROGRESS', 'ResourceStatusReason': 'Foo' } valid_from_timestamp = datetime.datetime(2016, 4, 1, 8, 3, 25, 548000, tzinfo=tzutc()) cfn = CloudFormation() result = cfn.handle_stack_event(event, valid_from_timestamp, "CREATE_COMPLETE") self.assertIsNone(result)