-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaws.js
59 lines (51 loc) · 1.3 KB
/
aws.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
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'us-west-2'});
// Create EC2 service object
var ec2 = new AWS.EC2({apiVersion: '2016-11-15'});
// EC2 instance parameters
var instanceParams = {
ImageId: 'ami-0c55b159cbfafe1f0',
InstanceType: 't2.micro',
KeyName: 'your-key-pair-name',
MinCount: 1,
MaxCount: 1
};
// Create a new EC2 instance
ec2.runInstances(instanceParams, function(err, data) {
if (err) {
console.log("Could not create instance", err);
return;
}
var instanceId = data.Instances[0].InstanceId;
console.log("Created instance", instanceId);
});
// Create S3 service object
var s3 = new AWS.S3({apiVersion: '2006-03-01'});
// S3 bucket parameters
var bucketParams = {
Bucket : 'your-bucket-name'
};
// Create a new S3 bucket
s3.createBucket(bucketParams, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Location);
}
});// Create a new S3 bucket
s3.createBucket(bucketParams, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Location);
}
});
// Create a new S3 bucket
s3.deleteBucket(bucketParams, function(err, data) {
if (err) {
console.log("Error", err);
} else {
console.log("Success", data.Location);
}
});