cfn-stack-event-stream
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -41,2 +41,10 @@ var Readable = require('stream').Readable; | ||
seen[event.EventId] = true; | ||
// If we reach a user initiated event assume this event is the | ||
// initiating event the caller intends to monitor. | ||
if (event.LogicalResourceId === stackName && | ||
event.ResourceType === 'AWS::CloudFormation::Stack' && | ||
event.ResourceStatusReason === 'User Initiated') { | ||
break; | ||
} | ||
} | ||
@@ -43,0 +51,0 @@ |
{ | ||
"name": "cfn-stack-event-stream", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A readable stream of CloudFormation stack events", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,5 +16,4 @@ var test = require('tape'); | ||
test('streams events until stack is complete', {timeout: 60000}, function (assert) { | ||
var events = [], | ||
stackName = 'cfn-stack-event-stream-test-create'; | ||
test('streams events until stack is complete', {timeout: 120000}, function (assert) { | ||
var stackName = 'cfn-stack-event-stream-test-create'; | ||
@@ -25,26 +24,72 @@ cfn.createStack({ | ||
}, function (err) { | ||
assert.ifError(err); | ||
if (err) { | ||
assert.ifError(err); | ||
assert.end(); | ||
return; | ||
} | ||
var events = [ | ||
'CREATE_IN_PROGRESS AWS::CloudFormation::Stack', | ||
'CREATE_IN_PROGRESS AWS::SNS::Topic', | ||
'CREATE_IN_PROGRESS AWS::SNS::Topic', | ||
'CREATE_COMPLETE AWS::SNS::Topic', | ||
'CREATE_COMPLETE AWS::CloudFormation::Stack' | ||
]; | ||
Stream(cfn, stackName) | ||
.on('data', function (e) { | ||
events.push(e); | ||
assert.equal(events[0], e.ResourceStatus + ' ' + e.ResourceType, e.ResourceStatus + ' ' + e.ResourceType); | ||
events.shift(); | ||
}) | ||
.on('end', function () { | ||
cfn.deleteStack({StackName: stackName}, function(err) { | ||
assert.ifError(err); | ||
assert.deepEqual(events.map(function (e) { return e.ResourceStatus; }), [ | ||
'CREATE_IN_PROGRESS', | ||
'CREATE_FAILED', | ||
'ROLLBACK_IN_PROGRESS', | ||
'DELETE_COMPLETE', | ||
'ROLLBACK_COMPLETE' | ||
]); | ||
assert.end(); | ||
}); | ||
updateStack(); | ||
}); | ||
}); | ||
function updateStack() { | ||
// Modify template for update. | ||
var templateUpdated = JSON.parse(JSON.stringify(template)); | ||
templateUpdated.Resources.NewTopic = { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties" : { | ||
"DisplayName": "Topic2" | ||
} | ||
}; | ||
cfn.updateStack({ | ||
StackName: stackName, | ||
TemplateBody: JSON.stringify(templateUpdated) | ||
}, function (err) { | ||
if (err) { | ||
assert.ifError(err); | ||
assert.end(); | ||
return; | ||
} | ||
var events = [ | ||
'UPDATE_IN_PROGRESS AWS::CloudFormation::Stack', | ||
'CREATE_IN_PROGRESS AWS::SNS::Topic', | ||
'CREATE_IN_PROGRESS AWS::SNS::Topic', | ||
'CREATE_COMPLETE AWS::SNS::Topic', | ||
'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS AWS::CloudFormation::Stack', | ||
'UPDATE_COMPLETE AWS::CloudFormation::Stack' | ||
]; | ||
Stream(cfn, stackName) | ||
.on('data', function (e) { | ||
assert.equal(events[0], e.ResourceStatus + ' ' + e.ResourceType, e.ResourceStatus + ' ' + e.ResourceType); | ||
events.shift(); | ||
}) | ||
.on('end', function () { | ||
deleteStack(); | ||
}); | ||
}); | ||
} | ||
function deleteStack() { | ||
cfn.deleteStack({StackName: stackName}, function(err) { | ||
assert.ifError(err); | ||
assert.end(); | ||
}); | ||
} | ||
}); | ||
test('streams events during stack deletion', {timeout: 60000}, function (assert) { | ||
var events = [], | ||
stackName = 'cfn-stack-event-stream-test-delete', | ||
var stackName = 'cfn-stack-event-stream-test-delete', | ||
lastEventId; | ||
@@ -56,3 +101,7 @@ | ||
}, function (err, stack) { | ||
assert.ifError(err); | ||
if (err) { | ||
assert.ifError(err); | ||
assert.end(); | ||
return; | ||
} | ||
Stream(cfn, stackName) | ||
@@ -64,12 +113,19 @@ .on('data', function (e) { | ||
cfn.deleteStack({StackName: stackName}, function(err) { | ||
assert.ifError(err); | ||
if (err) { | ||
assert.ifError(err); | ||
assert.end(); | ||
return; | ||
} | ||
var events = [ | ||
'DELETE_IN_PROGRESS AWS::CloudFormation::Stack', | ||
'DELETE_IN_PROGRESS AWS::SNS::Topic', | ||
'DELETE_COMPLETE AWS::SNS::Topic', | ||
'DELETE_COMPLETE AWS::CloudFormation::Stack' | ||
]; | ||
Stream(cfn, stack.StackId, {lastEventId: lastEventId}) | ||
.on('data', function (e) { | ||
events.push(e); | ||
assert.equal(events[0], e.ResourceStatus + ' ' + e.ResourceType, e.ResourceStatus + ' ' + e.ResourceType); | ||
events.shift(); | ||
}) | ||
.on('end', function () { | ||
assert.deepEqual(events.map(function (e) { return e.ResourceStatus; }), [ | ||
'DELETE_IN_PROGRESS', | ||
'DELETE_COMPLETE' | ||
]); | ||
assert.end(); | ||
@@ -85,7 +141,14 @@ }); | ||
"Description": "cfn-stack-event-stream-test", | ||
"Parameters": { | ||
"TestParameter": { | ||
"Description": "A parameter for testing", | ||
"Type": "String", | ||
"Default": "TestParameterValue" | ||
} | ||
}, | ||
"Resources": { | ||
"Test": { | ||
"Type": "AWS::AutoScaling::LaunchConfiguration", | ||
"Properties": { | ||
"TestTopic" : { | ||
"Type": "AWS::SNS::Topic", | ||
"Properties" : { | ||
"DisplayName": { "Ref": "TestParameter" } | ||
} | ||
@@ -95,1 +158,2 @@ } | ||
}; | ||
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11958
270
0