Utility methods for AMI.
$ npm install ami-motley-tool
var AmiMotleyTool = require("ami-motley-tool");
var amt = new AmiMotleyTool();
amt.getSortedGroupImages({ Name: "Foo", Role: "Web Server" }, "BuildNo").then(function(images) {
...
}).catch(function(err) {
console.log(err.stack);
});
amt.createImageAndSnapshotWithTags({ Name: "ami001", InstanceId: "i-123123123" }, function() { console.log("wait for creating AMI..."); }).then(function(imageId) {
...
}).catch(function(err) {
console.log(err.stack);
});
See source.
method | arg1 | arg2 | arg3 | return | description |
---|---|---|---|---|---|
getTagValue | description (instance, image, other AWS resources){ Xxx: "yyy", Tags: [ { Name: "foo1", Value: "bar1" }, { Name: "foo2", Value: "bar2" } ] } |
key"foo1" |
"bar1" (or null) |
get target tag value from description of image or instance. | |
covertTagsToMap | tags[ { Name: "foo", Value: "bar" }, { Name: "foo2", Value: "bar2" }... ] |
{ foo: bar, foo2: bar2 } |
convert tags to map. | ||
getFilters | groupTag{ foo: "bar", foo2: "bar2" } |
[ { Name: "tag:foo", Values: [ "bar" ] }, { Name: "tag:foo2", Values: [ "bar2" ] }... ] |
get filters from group. |
method | arg1 | arg2 | arg3 | return | description |
---|---|---|---|---|---|
getGroupImages | groupTag{ foo: "bar", foo2: "bar2" } |
Promise (images) |
get filtered (groupTag) images. groupTag is tag set. | ||
getSortedGroupImages | groupTag{ foo: "bar", foo2: "bar2" } |
versionTag"BuildNo" |
Promise (images) |
get filtered (groupTag) and sorted (versionTag ASC as string) images. groupTag is tag set. | |
deleteOldImagesAndSnapshots | groupTag{ foo: "bar", foo2: "bar2" } |
versionTag"BuildNo" |
callbackWait | Promise | delete old images and snapshots in target group. (keep latest one) |
getUsedImageIds | targetTag{ foo: "bar", foo2: "bar2" } |
Promise | get used image IDs in target group. (AutoScalingGroup and EC2 Instance) | ||
deleteUnusedImagesAndSnapshots | groupTag{ foo: "bar", foo2: "bar2" } |
targetTag{ foo: "bar", foo2: "bar2" } |
callbackWait | Promise | delete unused images and snapshots in target group. (AutoScalingGroup and EC2 Instance) |
createImageAndSnapshotWithTags | opts (InstanceId and Name required. AWS CreateImage Property) |
callbackWait | Promise (imageId) |
create image and snapshots with tags of target instance. Tag keys starting with "aws:" are reserved. | |
setTagsToImage | imageId | tags | Promise | set tags to image. | |
setTagsToSnapshot | imageId | tags | Promise | set tags to snapshot. | |
waitAvailableAmi | imageId | callbackWait | Promise true:AMI launched. false:AMI launch failed.) |
wait available AMI. | |
waitUnavailableAmi | imageId | callbackWait | Promise true:AMI unavailable. false:error.) |
wait unavailable AMI. |
Copyright 2016 t-yamo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.