From d1608d7a7f3483f45146d7e14d000d8f97186cac Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 12 Mar 2021 17:38:58 -0600 Subject: [PATCH] Expose etcd client MaxCallSendMsgSize config The etcdv3 client has a default request send limit of 2.0 MiB. This change exposes the configuration option to increase that limit enabling larger state using the etcdv3 backend. This also requires that the corresponding --max-request-bytes flag be increased on the server side. The default there is 1.5 MiB. Fixes https://github.com/hashicorp/terraform/issues/25745 --- internal/backend/remote-state/etcdv3/backend.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/backend/remote-state/etcdv3/backend.go b/internal/backend/remote-state/etcdv3/backend.go index 598f31583e..7285bda968 100644 --- a/internal/backend/remote-state/etcdv3/backend.go +++ b/internal/backend/remote-state/etcdv3/backend.go @@ -15,6 +15,7 @@ const ( usernameEnvVarName = "ETCDV3_USERNAME" passwordKey = "password" passwordEnvVarName = "ETCDV3_PASSWORD" + maxRequestBytesKey = "max_request_bytes" prefixKey = "prefix" lockKey = "lock" cacertPathKey = "cacert_path" @@ -49,6 +50,13 @@ func New() backend.Backend { DefaultFunc: schema.EnvDefaultFunc(passwordEnvVarName, ""), }, + maxRequestBytesKey: &schema.Schema{ + Type: schema.TypeInt, + Optional: true, + Description: "The max request size to send to etcd.", + Default: 0, + }, + prefixKey: &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -128,6 +136,9 @@ func (b *Backend) rawClient() (*etcdv3.Client, error) { if v, ok := b.data.GetOk(passwordKey); ok && v.(string) != "" { config.Password = v.(string) } + if v, ok := b.data.GetOk(maxRequestBytesKey); ok && v.(int) != 0 { + config.MaxCallSendMsgSize = v.(int) + } if v, ok := b.data.GetOk(cacertPathKey); ok && v.(string) != "" { tlsInfo.TrustedCAFile = v.(string) }