Skip to content

Commit b966d05

Browse files
Updated the document with detailed information (#9)
* Updated the document with detailed information * Updated the release version number * Updated terraform and go version
1 parent 216679d commit b966d05

File tree

1 file changed

+63
-18
lines changed

1 file changed

+63
-18
lines changed

README.md

Lines changed: 63 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,32 @@ CloudStack Terraform Provider
44
Requirements
55
------------
66

7-
- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
8-
- [Go](https://golang.org/doc/install) 1.8 (to build the provider plugin)
7+
- [Terraform](https://www.terraform.io/downloads.html) 1.0.x
8+
- [Go](https://golang.org/doc/install) 1.16+ (to build the provider plugin)
99

10-
Building The Provider
11-
---------------------
10+
Using the Provider from Terrafrom registry
11+
------------------------------------------
12+
To install the CloudStack provider, copy and paste the below code into your Terraform configuration. Then, run terraform init.
13+
```sh
14+
terraform {
15+
required_providers {
16+
cloudstack = {
17+
source = "cloudstack/cloudstack"
18+
version = "0.4.0"
19+
}
20+
}
21+
}
22+
23+
provider "cloudstack" {
24+
# Configuration options
25+
}
26+
```
27+
For more details on how to install and use the provider, visit https://registry.terraform.io/providers/cloudstack/cloudstack/latest/docs
28+
29+
Developing the Provider
30+
---------------------------
31+
32+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.16+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
1233

1334
Clone repository to: `$GOPATH/src/github.com/apache/cloudstack-terraform-provider`
1435

@@ -17,25 +38,19 @@ $ mkdir -p $GOPATH/src/github.com/apache; cd $GOPATH/src/github.com/apache
1738
$ git clone [email protected]:apache/cloudstack-terraform-provider
1839
```
1940

41+
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
42+
2043
Enter the provider directory and build the provider
2144

2245
```sh
2346
$ cd $GOPATH/src/github.com/apache/cloudstack-terraform-provider
2447
$ make build
48+
$ ls $GOPATH/bin/terraform-provider-cloudstack
2549
```
26-
27-
Developing the Provider
28-
---------------------------
29-
30-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.8+ is *required*). You'll also need to correctly setup a [GOPATH](http://golang.org/doc/code.html#GOPATH), as well as adding `$GOPATH/bin` to your `$PATH`.
31-
32-
To compile the provider, run `make build`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
33-
50+
Once the build is ready, you have to copy the binary into Terraform locally (version appended).
51+
On Linux this path is at ~/.terraform.d/plugins, and on Windows at %APPDATA%\terraform.d\plugins.
3452
```sh
35-
$ make bin
36-
...
37-
$ $GOPATH/bin/cloudstack-terraform-provider
38-
...
53+
$ ls ~/.terraform.d/plugins/registry.terraform.io/cloudstack/cloudstack/0.4.0/linux_amd64/terraform-provider-cloudstack_v0.4.0
3954
```
4055

4156
Testing the Provider
@@ -50,8 +65,8 @@ $ make test
5065
In order to run the full suite of Acceptance tests you will need to run the CloudStack Simulator. Please follow these steps to prepare an environment for running the Acceptance tests:
5166

5267
```sh
53-
$ docker pull svanharmelen/simulator:4.12.0.0
54-
$ docker run -d -p 8080:8080 --name cloudstack svanharmelen/simulator:4.12.0.0
68+
$ docker pull cloudstack/simulator
69+
$ docker run --name simulator -p 8080:5050 -d cloudstack/simulator
5570
```
5671

5772
When Docker started the container you can go to http://localhost:8080/client and login to the CloudStack UI as user `admin` with password `password`. It can take a few minutes for the container is fully ready, so you probably need to wait and refresh the page for a few minutes before the login page is shown.
@@ -76,6 +91,36 @@ In order for all the tests to pass, you will need to create a new (empty) projec
7691
$ make testacc
7792
```
7893

94+
Sample Terraform configuration
95+
------------------------------
96+
Below is an example configuration to initialize provider and create a Virtual Machine instance
97+
98+
```sh
99+
$ cat provider.tf
100+
terraform {
101+
required_providers {
102+
cloudstack = {
103+
source = "cloudstack/cloudstack"
104+
version = "0.4.0"
105+
}
106+
}
107+
}
108+
109+
provider "cloudstack" {
110+
# Configuration options
111+
api_url = "${var.cloudstack_api_url}"
112+
api_key = "${var.cloudstack_api_key}"
113+
secret_key = "${var.cloudstack_secret_key}"
114+
}
115+
116+
resource "cloudstack_instance" "web" {
117+
name = "server-1"
118+
service_offering = "Small Instance"
119+
network_id = "df5fc279-86d5-4f5d-b7e9-b27f003ca3fc"
120+
template = "616fe117-0c1c-11ec-aec4-1e00610002a9"
121+
zone = "2b61ed5d-e8bd-431d-bf52-d127655dffab"
122+
}
123+
```
79124
## History
80125

81126
This codebase relicensed under APLv2 and donated to the Apache CloudStack

0 commit comments

Comments
 (0)