Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cfn-stack-event-stream

Package Overview
Dependencies
Maintainers
44
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cfn-stack-event-stream - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

8

index.js

@@ -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 @@

2

package.json
{
"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 @@ }

};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc