This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathawssum-amazon-cloudformation.js
123 lines (94 loc) · 4.24 KB
/
awssum-amazon-cloudformation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// --------------------------------------------------------------------------------------------------------------------
//
// cloudformation.js - class for AWS CloudFormation
//
// Copyright (c) 2011, 2012 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <chilts@appsattic.com>
//
// License: http://opensource.org/licenses/MIT
//
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// requires
// built-ins
var util = require('util');
// dependencies
var _ = require('underscore');
// our own
var awssum = require('awssum');
var amazon = require('awssum-amazon');
var operations = require('./config.js');
// --------------------------------------------------------------------------------------------------------------------
// package variables
var MARK = 'cloudformation: ';
// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html
var endPoint = {};
endPoint[amazon.US_EAST_1] = "cloudformation.us-east-1.amazonaws.com";
endPoint[amazon.US_WEST_1] = "cloudformation.us-west-1.amazonaws.com";
endPoint[amazon.US_WEST_2] = "cloudformation.us-west-2.amazonaws.com";
endPoint[amazon.EU_WEST_1] = "cloudformation.eu-west-1.amazonaws.com";
endPoint[amazon.AP_SOUTHEAST_1] = "cloudformation.ap-southeast-1.amazonaws.com";
endPoint[amazon.AP_SOUTHEAST_2] = "cloudformation.ap-southeast-2.amazonaws.com";
endPoint[amazon.AP_NORTHEAST_1] = "cloudformation.ap-northeast-1.amazonaws.com";
endPoint[amazon.SA_EAST_1] = "cloudformation.sa-east-1.amazonaws.com";
endPoint[amazon.US_GOV_WEST_1] = "cloudformation.us-gov-west-1.amazonaws.com";
var version = '2010-05-15';
// --------------------------------------------------------------------------------------------------------------------
// constructor
var CloudFormation = function(opts) {
var self = this;
// call the superclass for initialisation
CloudFormation.super_.call(this, opts);
// check the region is valid
if ( ! endPoint[opts.region] ) {
throw MARK + "invalid region '" + opts.region + "'";
}
return self;
};
// inherit from Amazon
util.inherits(CloudFormation, amazon.AmazonSignatureV4);
// --------------------------------------------------------------------------------------------------------------------
// methods we need to implement from awssum.js/amazon.js
CloudFormation.prototype.method = function() {
return 'POST';
};
CloudFormation.prototype.host = function() {
return endPoint[this.region()];
};
CloudFormation.prototype.version = function() {
return version;
};
// ----------------------------------------------------------------------------
// AWS Signature v4
CloudFormation.prototype.scope = function() {
return 'cloudformation';
};
CloudFormation.prototype.serviceName = function() {
return 'cloudformation';
};
CloudFormation.prototype.needsTarget = function() {
return false;
};
// This service uses the AWS Signature v4.
// Hopefully, it fulfills : http://docs.amazonwebservices.com/cloudsearch/latest/developerguide/requestauth.html
CloudFormation.prototype.contentType = function() {
return 'application/x-www-form-urlencoded';
};
// --------------------------------------------------------------------------------------------------------------------
// operations on the service
_.each(operations, function(operation, operationName) {
CloudFormation.prototype[operationName] = awssum.makeOperation(operation);
});
// --------------------------------------------------------------------------------------------------------------------
// exports
exports.US_EAST_1 = amazon.US_EAST_1;
exports.US_WEST_1 = amazon.US_WEST_1;
exports.US_WEST_2 = amazon.US_WEST_2;
exports.EU_WEST_1 = amazon.EU_WEST_1;
exports.AP_SOUTHEAST_1 = amazon.AP_SOUTHEAST_1;
exports.AP_SOUTHEAST_2 = amazon.AP_SOUTHEAST_2;
exports.AP_NORTHEAST_1 = amazon.AP_NORTHEAST_1;
exports.SA_EAST_1 = amazon.SA_EAST_1;
exports.US_GOV_WEST = amazon.US_GOV_WEST;
exports.CloudFormation = CloudFormation;
// --------------------------------------------------------------------------------------------------------------------