Skip to content

Commit

Permalink
Merge pull request #43 from radify/adds-ami-instance-question
Browse files Browse the repository at this point in the history
Adds ami id question
  • Loading branch information
gavD committed Sep 8, 2015
2 parents 631ca46 + 9eaa9be commit 3d096f8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var istanbul = require('gulp-istanbul');
var paths = {
'spec' : 'spec/**/*.js',
'lib' : 'lib/**/*.js'
}
};

// Proofread the code
gulp.task('lint', function() {
Expand Down
10 changes: 10 additions & 0 deletions lib/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions lib/regexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
4 changes: 2 additions & 2 deletions lib/templates/immutable.yaml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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)"}'
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/questionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});

0 comments on commit 3d096f8

Please sign in to comment.