1
1
Terraform Provider
2
2
==================
3
- - [ ![ Build Status] ( https://travis-ci.org/vmware/terraform-provider-avi.svg?branch=master )] ( https://travis-ci.org/vmware/terraform-provider-avi )
4
3
- [ ![ Gitter chat] ( https://badges.gitter.im/hashicorp-terraform/Lobby.png )] ( https://gitter.im/hashicorp-terraform/Lobby )
5
4
- Website: https://www.terraform.io
6
5
- Mailing list: [ Google Groups] ( http://groups.google.com/group/terraform-tool )
7
6
8
7
<img src =" https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-text.svg " width =" 600px " >
9
8
9
+ Integrating Terraform with Avi Vantage
10
+ --------------------------------------
11
+ Please refer [ this] ( https://avinetworks.com/docs/20.1/integrating-terraform-with-avi-vantage ) article.
12
+
13
+ Developing the Provider or Use Locally Built Provider
14
+ ----------------------------------------------------
15
+ If you wish to work on the provider or want to use the locally built provider,
16
+ you'll first need [ Go] ( http://www.golang.org ) and [ Terraform] ( https://www.terraform.io ) installed on your machine.
17
+ You'll also need to correctly setup a [ GOPATH] ( http://golang.org/doc/code.html#GOPATH ) , as well as adding ` $GOPATH/bin `
18
+ to your ` $PATH ` .
19
+
10
20
Requirements
11
21
------------
12
22
13
- - [ Terraform] ( https://www.terraform.io/downloads.html ) 0.10.x
14
- - [ Go] ( https://golang.org/doc/install ) 1.8 (to build the provider plugin)
23
+ - [ Terraform] ( https://www.terraform.io/downloads.html ) 0.12.x/0.13+ (0.11.x or lower is incompatible)
24
+ - [ Go] ( https://golang.org/doc/install ) 1.13 (to build the provider plugin)
15
25
16
- Usage
17
- ---------------------
26
+ Building The Provider (Terraform v0.12+)
27
+ ----------------------------------------
18
28
19
- Create Avi Provider in terraform plan
29
+ Clone repository to: ` $GOPATH/src/github.com/vmware/ terraform-provider-avi `
20
30
31
+ ``` sh
32
+ $ mkdir -p $GOPATH /src/github.com/vmware; cd $GOPATH /src/github.com/vmware
33
+ $ git clone https://github.com/vmware/terraform-provider-avi.git
21
34
```
22
- # For example, restrict template version in 0.1.x
23
- provider "avi" {
24
- avi_username = "admin"
25
- avi_tenant = "admin"
26
- avi_password = "something"
27
- avi_controller= "42.42.42.42"
28
- }
29
- ```
30
-
31
- Create Avi Pool Example. Here Pool depends on read only tenant data source and another health monitor defined as resource in the terraform plan
32
35
33
- ```
34
- resource "avi_pool" "testpool" {
35
- name= "pool-42",
36
- health_monitor_refs= ["${avi_healthmonitor.test_hm_1.id}"]
37
- tenant_ref= "${data.avi_tenant.default_tenant.id}"
38
- cloud_ref= "${data.avi_cloud.default_cloud.id}"
39
- application_persistence_profile_ref= "${avi_applicationpersistenceprofile.test_applicationpersistenceprofile.id}"
40
- servers {
41
- ip= {
42
- type= "V4",
43
- addr= "10.90.64.66",
44
- }
45
- port= 8080
46
- }
47
- fail_action= {
48
- type= "FAIL_ACTION_CLOSE_CONN"
49
- }
50
- }
36
+ Enter the provider directory and build the provider.
51
37
38
+ ``` sh
39
+ $ cd $GOPATH /src/github.com/vmware/terraform-provider-avi
40
+ $ make
52
41
```
53
-
54
- Reference existing resources as readonly or data sources
42
+ For Terraform v0.12.x to use a locally built version of a provider add following to ~ /.terraformrc on Linux/Unix.
55
43
56
44
```
57
- data "avi_applicationprofile" "system_http_profile" {
58
- name = "System-HTTP "
45
+ providers {
46
+ "avi" = "$GOPATH/bin/terraform-provider-avi "
59
47
}
60
-
61
- application_profile_ref= "${data.avi_applicationprofile.system_https_profile.id}"
62
-
48
+ ```
49
+ Or copy provider binary in ~ ./.terraform/plugins/linux_amd64/
50
+ ``` shell
51
+ $ mkdir -p ~ ./.terraform/plugins/linux_amd64/
52
+ $ cp $GOPATH /bin/terraform-provider-avi ~ ./.terraform/plugins/linux_amd64/
63
53
```
64
54
65
-
66
- Building The Provider
67
- ---------------------
55
+ Building The Provider (Terraform v0.13+)
56
+ ----------------------------------------
68
57
69
58
Clone repository to: ` $GOPATH/src/github.com/vmware/terraform-provider-avi `
70
59
@@ -77,36 +66,104 @@ Enter the provider directory and build the provider
77
66
78
67
``` sh
79
68
$ cd $GOPATH /src/github.com/vmware/terraform-provider-avi
69
+ $ make build13
70
+ ```
71
+ This will put the provider binary in the ~ /.terraform.d/plugins/vmware.com/avi/avi/<provider_version>/$(GOOS)_ $(GOARCH)
72
+ directory.
73
+
74
+ For Terraform v0.13+, to use a locally built version of a provider you must add the following snippet to every
75
+ terraform plan.
76
+ ```
77
+ terraform {
78
+ required_providers {
79
+ avi = {
80
+ source = "vmware.com/avi/avi"
81
+ version = "<provider_version>"
82
+ }
83
+ }
84
+ }
85
+ ```
80
86
87
+ ------
88
+ Usage
89
+ ------
81
90
82
- $ make
91
+ Create Avi Provider in terraform plan
92
+
93
+ ```
94
+ provider "avi" {
95
+ avi_username = "admin"
96
+ avi_tenant = "admin"
97
+ avi_password = "password"
98
+ avi_controller = "x.x.x.x"
99
+ avi_version = "20.1.4"
100
+ }
83
101
```
84
102
85
- Using the provider
86
- ----------------------
87
- ## Fill in for each provider
103
+ Create Avi Pool Example. Here Pool depends on read only tenant data source and another health monitor defined as
104
+ resource in the terraform plan
105
+
106
+ ```
107
+ data "avi_tenant" "default_tenant" {
108
+ name= "admin"
109
+ }
110
+ data "avi_cloud" "default_cloud" {
111
+ name= "Default-Cloud"
112
+ }
113
+
114
+ resource "avi_applicationpersistenceprofile" "test_applicationpersistenceprofile" {
115
+ name = "terraform-app-pers-profile"
116
+ tenant_ref = data.avi_tenant.default_tenant.id
117
+ persistence_type = "PERSISTENCE_TYPE_CLIENT_IP_ADDRESS"
118
+ }
119
+
120
+ resource "avi_healthmonitor" "test_hm_1" {
121
+ name = "terraform-monitor"
122
+ type = "HEALTH_MONITOR_HTTP"
123
+ tenant_ref = data.avi_tenant.default_tenant.id
124
+ }
125
+
126
+ resource "avi_pool" "testpool" {
127
+ name= "pool-42"
128
+ health_monitor_refs = [avi_healthmonitor.test_hm_1.id]
129
+ tenant_ref = data.avi_tenant.default_tenant.id
130
+ cloud_ref = data.avi_cloud.default_cloud.id
131
+ application_persistence_profile_ref= avi_applicationpersistenceprofile.test_applicationpersistenceprofile.id
132
+ servers {
133
+ ip {
134
+ type = "V4"
135
+ addr = "10.90.64.66"
136
+ }
137
+ port= 8080
138
+ }
139
+ fail_action {
140
+ type = "FAIL_ACTION_CLOSE_CONN"
141
+ }
142
+ }
143
+ ```
88
144
89
- Developing the Provider
90
- ---------------------------
145
+ Reference existing resources as readonly or data sources
91
146
92
- 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 ` .
147
+ ```
148
+ data "avi_applicationprofile" "system_http_profile" {
149
+ name= "System-HTTP"
150
+ }
93
151
94
- To compile the provider, run ` make build ` . This will build the provider and put the provider binary in the ` $GOPATH/bin ` directory.
152
+ application_profile_ref= data.avi_applicationprofile.system_https_profile.id
95
153
96
- ``` sh
97
- $ make bin
98
- ...
99
- $ $GOPATH /bin/terraform-provider-avi
100
- ...
101
154
```
155
+ -----------------
102
156
157
+ Test The Provider
158
+ -----------------
103
159
In order to test the provider, you can simply run ` make test ` .
104
160
105
161
``` sh
106
162
$ make test
107
163
```
108
164
109
- In order to run the full suite of Acceptance tests, run ` make testacc ` .
165
+ In order to run the full suite of Acceptance tests, run ` make testacc ` .
166
+ Running the tests for a provider requires version 0.12.26 or higher of the Terraform CLI.
110
167
111
168
* Note:* Acceptance tests create real resources, and often cost money to run.
112
169
0 commit comments