diff --git a/Gulpfile.js b/Gulpfile.js index 1e93c1b..9dc1e42 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -7,7 +7,7 @@ var istanbul = require('gulp-istanbul'); var paths = { 'spec' : 'spec/**/*.js', 'lib' : 'lib/**/*.js' -} +}; // Proofread the code gulp.task('lint', function() { diff --git a/lib/questions.js b/lib/questions.js index 5fa0937..0206c56 100644 --- a/lib/questions.js +++ b/lib/questions.js @@ -311,6 +311,16 @@ default: function(answers) { return appendTagDefaultValue(answers, '.pem'); } + }, { + type: 'input', + name: 'ami_id', + message: 'What AMI ID would you like to use? (E.g., ami-47a23a30)', + validate: function(value) { + var regex = regexes.ami; + var errorMessage = 'The AMI ID must begin with \"ami-\" and must end' + + ' with exactly eight lowercase, alphanumeric characters.'; + return validateInput(value, regex, errorMessage); + } }, { type: 'input', name: 'aws_key', diff --git a/lib/regexes.js b/lib/regexes.js index 1d03974..18df02e 100644 --- a/lib/regexes.js +++ b/lib/regexes.js @@ -4,6 +4,12 @@ module.exports = { */ pem: /(.pem)$/, + /** + * The AMI ID must begin with "ami-" and must end with exactly eight, + * lowercase, alphanumeric characters. + */ + ami: /^ami-[a-z0-9]{8}$/, + /** * AWS Key validation * diff --git a/lib/templates/immutable.yaml.mustache b/lib/templates/immutable.yaml.mustache index 11155eb..2700ef2 100644 --- a/lib/templates/immutable.yaml.mustache +++ b/lib/templates/immutable.yaml.mustache @@ -7,8 +7,8 @@ region: '{{ region }}' aws_zone: '{{ aws_zone }}' tasks: - - name: Launch instance (Ubuntu 14.04 hvm) - ec2: image='ami-9eaa1cf6' + - name: Launch Instance + ec2: image='{{ ami_id }}' instance_type="{{=<% %>=}}{{ instance_type }}<%={{ }}=%>" keypair='{{ keypair }}' instance_tags='{"Environment":"{{ environment }}","Class":"{{ className }}-immutable","Name":"{{ appName }} (immutable)"}' diff --git a/spec/lib/questionsSpec.js b/spec/lib/questionsSpec.js index c37c6f5..bdeb0f5 100644 --- a/spec/lib/questionsSpec.js +++ b/spec/lib/questionsSpec.js @@ -2,8 +2,8 @@ var questions = require('../../lib/questions.js'); describe('questions.js', function() { describe('format', function() { - it('should be an array of 24 questions', function() { - expect(questions.length).toEqual(24); + it('should be an array of 25 questions', function() { + expect(questions.length).toEqual(25); }); }); });