Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bubble out configOptions as provider options #893

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions bigip/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"reflect"
"regexp"
"strings"
"time"

bigip "github.com/f5devcentral/go-bigip"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -85,6 +86,24 @@ func Provider() *schema.Provider {
Description: "Login reference for token authentication (see BIG-IP REST docs for details)",
DefaultFunc: schema.EnvDefaultFunc("BIGIP_LOGIN_REF", "tmos"),
},
"api_timeout": {
Type: schema.TypeInt,
Optional: true,
Description: "A timeout for AS3 requests, represented as a number of seconds. Default: 60",
DefaultFunc: schema.EnvDefaultFunc("API_TIMEOUT", 60),
},
"token_timeout": {
Type: schema.TypeInt,
Optional: true,
Description: "A lifespan to request for the AS3 auth token, represented as a number of seconds. Default: 1200",
DefaultFunc: schema.EnvDefaultFunc("TOKEN_TIMEOUT", 1200),
},
"api_retries": {
Type: schema.TypeInt,
Optional: true,
Description: "Amount of times to retry AS3 API requests. Default: 10.",
DefaultFunc: schema.EnvDefaultFunc("API_RETRIES", 10),
},
},
DataSourcesMap: map[string]*schema.Resource{
"bigip_ltm_datagroup": dataSourceBigipLtmDataGroup(),
Expand Down Expand Up @@ -183,13 +202,20 @@ func Provider() *schema.Provider {
}

func providerConfigure(d *schema.ResourceData, terraformVersion string) (interface{}, diag.Diagnostics) {
configOptions := &bigip.ConfigOptions{
APICallTimeout: (d.Get("api_timeout").(time.Duration) * time.Second),
TokenTimeout: (d.Get("token_timeout").(time.Duration) * time.Second),
APICallRetries: d.Get("api_retries").(int),
}

config := &bigip.Config{
Address: d.Get("address").(string),
Port: d.Get("port").(string),
Username: d.Get("username").(string),
Password: d.Get("password").(string),
Token: d.Get("token_value").(string),
CertVerifyDisable: d.Get("validate_certs_disable").(bool),
ConfigOptions: configOptions,
}
if d.Get("token_auth").(bool) {
config.LoginReference = d.Get("login_ref").(string)
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This provider uses the iControlREST API. All the resources are validated with Bi
~> **NOTE** For AWAF resources, F5 BIG-IP version should be > v16.x , and ASM need to be provisioned.

## Example Usage

```hcl
variable hostname {}
variable username {}
Expand Down Expand Up @@ -45,6 +46,9 @@ provider "bigip" {
- `password` - (type `string`) BIG-IP Password for authentication. Can be set via the `BIGIP_PASSWORD` environment variable.
- `token_auth` - (Optional, Default `true`) Enable to use token authentication. Can be set via the `BIGIP_TOKEN_AUTH` environment variable.
- `token_value` - (Optional) A token generated outside the provider, in place of password
- `api_timeout` - (Optional, type `int`) A timeout for AS3 requests, represented as a number of seconds.
- `token_timeout` - (Optional, type `int`) A lifespan to request for the AS3 auth token, represented as a number of seconds.
- `api_retries` - (Optional, type `int`) Amount of times to retry AS3 API requests.
- `login_ref` - (Optional,Default `tmos`) Login reference for token authentication (see BIG-IP REST docs for details). May be set via the `BIGIP_LOGIN_REF` environment variable.
- `port` - (Optional) Management Port to connect to BIG-IP,this is mainly required if we have single nic BIG-IP in AWS/Azure/GCP (or) Management port other than `443`. Can be set via `BIGIP_PORT` environment variable.
- `validate_certs_disable` - (Optional, Default `true`) If set to true, Disables TLS certificate check on BIG-IP. Can be set via the `BIGIP_VERIFY_CERT_DISABLE` environment variable.
Expand Down
57 changes: 55 additions & 2 deletions vendor/github.com/f5devcentral/go-bigip/bigip.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.