
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
cfn makes the following AWS CloudFormation tasks simpler.
daysOld to delete stacks this old.$ npm install cfn --save-dev
Usage
cfn deploy {stack name} {template} [--{param key}={param value}...]
cfn delete {stack name}
cfn outputs {stack name}
Examples
cfn deploy my-stack template.js
cfn deploy your_stack template.yml --ImageId=ami-828283 --VpcId=vpc-828283
cfn delete your_stack
cfn outputs my-stack
Use cfn to create or update an AWS CloudFormation stack. It returns a promise. You can use Node.js modules or standard json or yaml for AWS CloudFormation templates.
const cfn = require('cfn');
// Create or update (if it exists) the Foo-Bar stack with the template.js Node.js module.
cfn('Foo-Bar', __dirname + '/template.js')
.then(function() {
console.log('done');
});
// json
cfn('Foo-Bar', 'template.json');
// yaml
cfn('Foo-Bar2', 'template.yml');
// Verbose Syntax
cfn({
name: 'Foo-Bar',
template: 'template.yaml',
cfParams: {
buildNumber: '123',
},
tags: {
app: 'my app',
department: 'accounting',
},
awsConfig: {
region: 'us-east-2',
accessKeyId: 'akid',
secretAccessKey: 'secret',
},
capabilities: ['CAPABILITY_IAM'],
checkStackInterval: 5000,
});
Delete a stack.
// Delete the Foo-Bar stack
cfn.delete('Foo-Bar');
Cleanup stacks based on regex and daysOld.
// Delete stacks starting with TEST- that are 3 days old or more
cfn.cleanup({
regex: /TEST-/,
minutesOld: 60
})
.then(function() {
console.log('done')
});
Returns a boolean if a stack exists or not
// Returns boolean if stack name 'foo-bar' exists
cfn.stackExists('foo-bar')
.then(function(exists){
if (exists){
//Do something
}
})
Checks if a template is valid
// Validate a template.js Node.js module.
cfn({
template: __dirname + '/template.js',
params: {
foo: 'bar'
},
awsConfig: {
region: 'us-west-2'
}
}).validate()
.then(function(data){
//Stack is valid do something
},
function(err){
//Stack is invalid
})
// Validate a json template.
cfn.validate('us-west-2', 'template.json');
// Validate a yaml template.
cfn.validate('us-west-2', 'template.yml');
Creates or Updates a stack if it already exists. Logs events and returns a Promise.
The name of the stack to Create / Update. If the first arg is a string it is used as name.
Options object. If the first arg is an object it will be used as options.
Path to template (js, yaml or json file), JSON object, serialized JSON string, YAML string, or a S3 Bucket URL. This is optional and if given will override options.template (if present). This arg is helpful if the first arg is the name of the template rather than an options object.
Name of stack.
Path to template (json, yaml or js file), JSON object, serialized JSON string, or a YAML string. If the optional second argument is passed in it will override this.
If set to true create/update and delete runs asynchronously. Defaults to false.
Interpolated parameters into JS module-wrapped CloudFormation templates (only should be used with js files).
A JS module-wrapped template example is shown below:
module.exports = function (params) {
return {
AWSTemplateFormatVersion: '2010-09-09',
Description: 'Test Stack',
Resources: {
testTable: {
Type: 'AWS::DynamoDB::Table',
Properties: {
...
TableName: 'FOO-TABLE-' + params.env
}
}
}
};
};
Is deployed as follows:
cfn({
name: 'Test-Stack',
template: 'template.js',
params: { env: 'dev' }
});
The standard AWS CloudFormation parameters to be passed into the template.
A standard AWS CloudFormation template in yaml format is shown below:
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Test Stack'
Parameters:
env:
Type: String
Description: The environment for the application
Resources:
testTable:
Type: AWS::DynamoDB::Table
Properties:
...
TableName: !Sub FOO-TABLE-${env}
Is deployed as follows:
cfn({
name: 'Test-Stack',
template: 'template.yml',
cfParams: { env: 'dev' }
});
This allows you to pass any config properties allowed by the AWS Node.js SDK
cfn({
name: 'Foo-Bar',
template: _dirname + '/template.js',
awsConfig: {
region: 'us-west-2'
accessKeyId: 'akid',
secretAccessKey: 'secret'
}
}).then(function() {
console.log('done');
});
FAQs
Simple AWS CloudFormation
The npm package cfn receives a total of 2,057 weekly downloads. As such, cfn popularity was classified as popular.
We found that cfn demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.