4
4
[ ![ Go Report Card] ( https://goreportcard.com/badge/github.com/LeanerCloud/ec2-instances-info )] ( https://goreportcard.com/report/github.com/LeanerCloud/ec2-instances-info )
5
5
[ ![ GoDoc] ( https://godoc.org/github.com/LeanerCloud/ec2-instances-info?status.svg )] ( http://godoc.org/github.com/LeanerCloud/ec2-instances-info )
6
6
7
- Golang library providing specs and pricing information about AWS resources such as EC2 instances, RDS databases, ElastiCache and OpenSearch clusters.
7
+ Golang library providing specs and pricing information about cloud resources such as:
8
+
9
+ - AWS EC2 instances
10
+ - AWS RDS databases
11
+ - AWS ElastiCache clusters
12
+ - AWS OpenSearch clusters
13
+ - Azure VM instances
8
14
9
15
It is based on the data that is also powering the comprehensive
10
16
[ www.ec2instances.info ] ( http://www.ec2instances.info ) instance comparison
@@ -34,7 +40,9 @@ go get -u github.com/LeanerCloud/ec2-instances-info/...
34
40
35
41
## Usage
36
42
37
- ### One-off usage, with static data
43
+ ### AWS EC2 Usage
44
+
45
+ #### One-off usage, with static data
38
46
39
47
``` golang
40
48
import " github.com/LeanerCloud/ec2-instances-info"
@@ -49,7 +57,7 @@ for _, i := range *data {
49
57
50
58
See the examples directory for a working code example.
51
59
52
- ### One-off usage, with updated instance type data
60
+ #### One-off usage, with updated instance type data
53
61
54
62
``` golang
55
63
import " github.com/LeanerCloud/ec2-instances-info"
@@ -69,7 +77,7 @@ for _, i := range *data {
69
77
}
70
78
```
71
79
72
- ### Continuous usage, with instance type data updated every 2 days
80
+ #### Continuous usage, with instance type data updated every 2 days
73
81
74
82
``` golang
75
83
import " github.com/LeanerCloud/ec2-instances-info"
@@ -85,6 +93,57 @@ for _, i := range *data {
85
93
}
86
94
```
87
95
96
+ ### Azure VM Usage
97
+
98
+ #### Basic usage, with static data
99
+
100
+ ``` golang
101
+ import " github.com/LeanerCloud/ec2-instances-info"
102
+
103
+ data , err := ec2instancesinfo.AzureData () // only needed once
104
+
105
+ // This would print all the available Azure VM instance type names:
106
+ for _ , i := range *data {
107
+ fmt.Println (" Azure VM instance type:" , i.InstanceType )
108
+ }
109
+ ```
110
+
111
+ #### One-off usage, with updated Azure VM data
112
+
113
+ ``` golang
114
+ import " github.com/LeanerCloud/ec2-instances-info"
115
+
116
+ key := " API_KEY" // API keys are available upon demand from [email protected]
117
+
118
+ err := ec2instancesinfo.UpdateAzureData (nil , &key)
119
+ if err != nil {
120
+ fmt.Println (" Couldn't update Azure VM data, reverting to static compile-time data" , err.Error ())
121
+ }
122
+
123
+ data , err := ec2instancesinfo.AzureData () // needs to be called once after data updates
124
+
125
+ // This would print all the available Azure VM instance type names:
126
+ for _ , i := range *data {
127
+ fmt.Println (" Azure VM instance type:" , i.InstanceType )
128
+ }
129
+ ```
130
+
131
+ #### Continuous usage, with Azure VM data updated every 2 days
132
+
133
+ ``` golang
134
+ import " github.com/LeanerCloud/ec2-instances-info"
135
+
136
+ key := " API_KEY"
137
+ go ec2instancesinfo.AzureUpdater (2 , nil , &key); // use 0 or negative values for weekly updates
138
+
139
+ data , err := ec2instancesinfo.AzureData () // only needed once
140
+
141
+ // This would print all the available Azure VM instance type names:
142
+ for _ , i := range *data {
143
+ fmt.Println (" Azure VM instance type:" , i.InstanceType )
144
+ }
145
+ ```
146
+
88
147
## Contributing
89
148
90
149
Pull requests and feedback are welcome.
@@ -97,4 +156,5 @@ The data can be updated for new instance type coverage by running `make`.
97
156
98
157
- Click on the ` Terminal ` then ` New Terminal ` in the top menu
99
158
- In the terminal run ` cd ~/cloudshell_open/ec2-instances-info/examples/instances/ `
100
- - ` go run . ` will run the example code.
159
+ - ` go run . ` will run the example EC2 code.
160
+ - For Azure VM data: ` cd ~/cloudshell_open/ec2-instances-info/examples/azure/ ` and ` go run . `
0 commit comments