我正在尝试使用 Node SDK 创建一个 ECS 实例,但失败了。我不确定我是否做对了。我可以使用 Portal 和 ROS 创建具有相同配置的 ECS。
//using the SDK for ECS
var ECSClient = require('@alicloud/ecs-2014-05-26');
// crearting the client
var client = new ECSClient({
accessKeyId: 'myaccesskeyid',
accessKeySecret: 'myaccesskeysecret',
endpoint: 'https://ecs.aliyuncs.com'
});
// image id and instance type procured using the OpenApi explorer
var params = {
ImageId: 'winsvr_64_dtcC_1809_en-us_40G_alibase_20190528.vhd',
InstanceType: 'ecs.t1.xsmall',
RegionId: 'ap-south-1'
}
// options
var opts = {
'x-acs-region-id': "ap-south-1"
}
// calling the sdk method to create ecs instance
client.createInstance(params, opts).then((res) => {
console.log(res)
}, (err) => {
console.log('ERROR!!')
console.log(JSON.stringify(err))
});