diff --git a/CHANGELOG.md b/CHANGELOG.md index 931c0d7dc..fe4d7b0aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -## 0.70.0 (Unreleased) +## 0.71.0 (Unreleased) +ENHANCEMENTS: +* allow `initial` of `0` for `yandex_kubernetes_node_group` `auto_scale` policy. + +BUG FIXES: +* alb: fix behavior of attribute `weight` in `http_backend` and `grpc_backend` and `stream_backend` in `yandex_alb_backend_group` resource + +## 0.70.0 (January 17, 2022) FEATURES: * **New Resource:** `yandex_datatransfer_endpoint` * **New Resource:** `yandex_datatransfer_transfer` @@ -80,6 +87,7 @@ BUG FIXES: ## 0.65.0 (October 14, 2021) FEATURES: * mdb: support Schema Registry in `yandex_mdb_kafka_cluster` +* resourcemanager: data source `yandex_resourcemanager_cloud` now provides `folders` attribute FEATURES: * **New Resource:** `yandex_kms_symmetric_key_iam_binding` diff --git a/README.md b/README.md index c0c649c17..bcf3cefc5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,18 @@ $ make build Using the provider ---------------------- If you're building the provider, follow the instructions to [install it as a plugin.](https://www.terraform.io/docs/plugins/basics.html#installing-plugins) After placing it into your plugins directory, run `terraform init` to initialize it. Documentation about the provider specific configuration options can be found on the [provider's website](https://registry.terraform.io/providers/yandex-cloud/yandex/latest/docs). +An example of using an installed provider from local directory: + +Write following config into `~/.terraformrc` +``` +provider_installation { + dev_overrides { + "yandex-cloud/yandex" = "/path/to/local/provider" + } + + direct {} + } +``` Developing the Provider --------------------------- diff --git a/website/docs/d/datasource_resourcemanager_cloud.html.markdown b/website/docs/d/datasource_resourcemanager_cloud.html.markdown index ce2c562a4..45ebbcc5f 100644 --- a/website/docs/d/datasource_resourcemanager_cloud.html.markdown +++ b/website/docs/d/datasource_resourcemanager_cloud.html.markdown @@ -39,3 +39,4 @@ The following attributes are returned: * `name` - Name of the cloud. * `description` - Description of the cloud. * `created_at` - Cloud creation timestamp. +* `folders` - List of folders in the cloud diff --git a/website/docs/r/alb_target_group.html.markdown b/website/docs/r/alb_target_group.html.markdown index b575fc23a..7d901b8d8 100644 --- a/website/docs/r/alb_target_group.html.markdown +++ b/website/docs/r/alb_target_group.html.markdown @@ -19,12 +19,12 @@ resource "yandex_alb_target_group" "foo" { target { subnet_id = "${yandex_vpc_subnet.my-subnet.id}" - address = "${yandex_compute_instance.my-instance-1.network_interface.0.ip_address}" + ip_address = "${yandex_compute_instance.my-instance-1.network_interface.0.ip_address}" } target { subnet_id = "${yandex_vpc_subnet.my-subnet.id}" - address = "${yandex_compute_instance.my-instance-2.network_interface.0.ip_address}" + ip_address = "${yandex_compute_instance.my-instance-2.network_interface.0.ip_address}" } } ``` @@ -77,4 +77,4 @@ A target group can be imported using the `id` of the resource, e.g.: ``` $ terraform import yandex_alb_target_group.default target_group_id -``` \ No newline at end of file +``` diff --git a/website/docs/r/cdn_resource.html.markdown b/website/docs/r/cdn_resource.html.markdown index e79cdfec6..9b08fa355 100644 --- a/website/docs/r/cdn_resource.html.markdown +++ b/website/docs/r/cdn_resource.html.markdown @@ -69,9 +69,9 @@ Resource block supports following options: * `gzip_on` - GZip compression at CDN servers reduces file size by 70% and can be as high as 90%. -* `redirect_http_to_https` - set up a redirect from HTTPS to HTTP. +* `redirect_http_to_https` - set up a redirect from HTTP to HTTPS. -* `redirect_https_to_http` - set up a redirect from HTTP to HTTPS. +* `redirect_https_to_http` - set up a redirect from HTTPS to HTTP. * `custom_host_header` - custom value for the Host header. Your server must be able to process requests with the chosen header. diff --git a/website/docs/r/function_iam_binding.html.markdown b/website/docs/r/function_iam_binding.html.markdown index 84072760b..9288d6727 100644 --- a/website/docs/r/function_iam_binding.html.markdown +++ b/website/docs/r/function_iam_binding.html.markdown @@ -30,4 +30,5 @@ The following arguments are supported: * `members` - (Required) Identities that will be granted the privilege in `role`. Each entry can have one of the following values: * **userAccount:{user_id}**: A unique user ID that represents a specific Yandex account. + * **serviceAccount:{service_account_id}**: A unique service account ID. * **system:{allUsers|allAuthenticatedUsers}**: see [system groups](https://cloud.yandex.com/docs/iam/concepts/access-control/system-group) diff --git a/website/docs/r/mdb_mongodb_cluster.html.markdown b/website/docs/r/mdb_mongodb_cluster.html.markdown index e606e876e..3828a0bd2 100644 --- a/website/docs/r/mdb_mongodb_cluster.html.markdown +++ b/website/docs/r/mdb_mongodb_cluster.html.markdown @@ -142,7 +142,7 @@ The `permission` block supports: * `database_name` - (Required) The name of the database that the permission grants access to. -* `role` - (Optional) The role of the user in this database. For more information see [the official documentation](https://cloud.yandex.com/docs/managed-mongodb/concepts/users-and-roles). +* `roles` - (Optional) The roles of the user in this database. For more information see [the official documentation](https://cloud.yandex.com/docs/managed-mongodb/concepts/users-and-roles). The `database` block supports: diff --git a/yandex/alb_structures.go b/yandex/alb_structures.go index be5bb3c54..edda771bf 100644 --- a/yandex/alb_structures.go +++ b/yandex/alb_structures.go @@ -3,6 +3,7 @@ package yandex import ( "bytes" "fmt" + "google.golang.org/protobuf/types/known/wrapperspb" "strings" "github.com/golang/protobuf/ptypes/wrappers" @@ -1471,12 +1472,13 @@ func flattenALBHTTPBackends(bg *apploadbalancer.BackendGroup) (*schema.Set, erro } flHealthchecks := flattenALBHealthchecks(b.GetHealthchecks()) + weight := getWeight(b.GetBackendWeight()) flBackend := map[string]interface{}{ "name": b.Name, "port": int(b.Port), "http2": b.UseHttp2, - "weight": int(b.BackendWeight.Value), + "weight": weight, "tls": flTls, "load_balancing_config": flLoadBalancingConfig, "healthcheck": flHealthchecks, @@ -1516,11 +1518,12 @@ func flattenALBStreamBackends(bg *apploadbalancer.BackendGroup) (*schema.Set, er } flHealthchecks := flattenALBHealthchecks(b.GetHealthchecks()) + weight := getWeight(b.GetBackendWeight()) flBackend := map[string]interface{}{ "name": b.Name, "port": int(b.Port), - "weight": int(b.BackendWeight.Value), + "weight": weight, "tls": flTls, "load_balancing_config": flLoadBalancingConfig, "healthcheck": flHealthchecks, @@ -1535,6 +1538,13 @@ func flattenALBStreamBackends(bg *apploadbalancer.BackendGroup) (*schema.Set, er return result, nil } +func getWeight(weight *wrapperspb.Int64Value) int { + if weight == nil { + return 1 + } + return int(weight.Value) +} + func flattenALBGRPCBackends(bg *apploadbalancer.BackendGroup) (*schema.Set, error) { result := &schema.Set{F: resourceALBBackendGroupBackendHash} @@ -1559,11 +1569,12 @@ func flattenALBGRPCBackends(bg *apploadbalancer.BackendGroup) (*schema.Set, erro } } flHealthchecks := flattenALBHealthchecks(b.GetHealthchecks()) + weight := getWeight(b.GetBackendWeight()) flBackend := map[string]interface{}{ "name": b.Name, "port": int(b.Port), - "weight": int(b.BackendWeight.Value), + "weight": weight, "tls": flTls, "load_balancing_config": flLoadBalancingConfig, "healthcheck": flHealthchecks, diff --git a/yandex/base_alb_test.go b/yandex/base_alb_test.go index 210cab8a0..193a2859a 100644 --- a/yandex/base_alb_test.go +++ b/yandex/base_alb_test.go @@ -52,6 +52,8 @@ type resourceALBLoadBalancerInfo struct { BalancerName string RouterName string + BackendGroupName string + TargetGroupName string ListenerName string BalancerDescription string AllowHTTP10 string @@ -75,6 +77,8 @@ func albLoadBalancerInfo() resourceALBLoadBalancerInfo { BaseTemplate: testAccALBBaseTemplate(acctest.RandomWithPrefix("tf-instance")), BalancerName: acctest.RandomWithPrefix("tf-load-balancer"), RouterName: acctest.RandomWithPrefix("tf-router"), + BackendGroupName: acctest.RandomWithPrefix("tf-bg"), + TargetGroupName: acctest.RandomWithPrefix("tf-tg"), ListenerName: acctest.RandomWithPrefix("tf-listener"), BalancerDescription: acctest.RandomWithPrefix("tf-load-balancer-description"), AllowHTTP10: albDefaultAllowHTTP10, @@ -345,7 +349,34 @@ data "yandex_alb_load_balancer" "test-alb-ds" { resource "yandex_alb_http_router" "test-router" { name = "{{.RouterName}}" } +{{ if .IsStreamHandler }} +resource "yandex_alb_backend_group" "test-bg" { + name = "{{.BackendGroupName}}" + stream_backend { + name = "test-stream-backend" + port = 8080 + target_group_ids = ["${yandex_alb_target_group.test-target-group.id}"] + load_balancing_config { + panic_threshold = "50" + locality_aware_routing_percent = "35" + strict_locality = "true" + } + healthcheck { + timeout = "10s" + interval = "10s" + http_healthcheck { + host = "tf-test-host" + path = "tf-test-path" + http2 = "true" + } + } + } +} +resource "yandex_alb_target_group" "test-target-group" { + name = "{{.TargetGroupName}}" +} +{{ end }} resource "yandex_alb_load_balancer" "test-balancer" { name = "{{.BalancerName}}" description = "{{.BalancerDescription}}" @@ -399,7 +430,7 @@ resource "yandex_alb_load_balancer" "test-balancer" { stream { {{if .IsStreamHandler}} handler { - backend_group_id = "ds760hlsaj9kj4p01uc7" + backend_group_id = yandex_alb_backend_group.test-bg.id } {{end}} } @@ -422,7 +453,7 @@ resource "yandex_alb_load_balancer" "test-balancer" { {{end}} {{if .IsStreamHandler}} stream_handler { - backend_group_id = "ds760hlsaj9kj4p01uc7" + backend_group_id = yandex_alb_backend_group.test-bg.id } {{end}} certificate_ids = ["{{.CertificateID}}"] diff --git a/yandex/data_source_yandex_alb_backend_group_test.go b/yandex/data_source_yandex_alb_backend_group_test.go index b0de46920..7b545b165 100644 --- a/yandex/data_source_yandex_alb_backend_group_test.go +++ b/yandex/data_source_yandex_alb_backend_group_test.go @@ -160,7 +160,7 @@ func TestAccDataSourceALBBackendGroup_fullWithStreamBackend(t *testing.T) { Config: testALBBackendGroupConfig_basic(BGResource), Check: resource.ComposeTestCheckFunc( testAccDataSourceALBBackendGroupExists(albBgDataSourceResource, &bg), - testAccCheckALBBackendGroupValues(&bg, false, false, false), + testAccCheckALBBackendGroupValues(&bg, false, false, true), testExistsFirstElementWithAttr( albBgDataSourceResource, "stream_backend", "tls", &backendPath, ), diff --git a/yandex/data_source_yandex_resourcemanager_cloud.go b/yandex/data_source_yandex_resourcemanager_cloud.go index 33abcdca9..272a35a3e 100644 --- a/yandex/data_source_yandex_resourcemanager_cloud.go +++ b/yandex/data_source_yandex_resourcemanager_cloud.go @@ -32,6 +32,25 @@ func dataSourceYandexResourceManagerCloud() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "folders": { + Type: schema.TypeList, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "folder_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + }, + }, + }, }, } } @@ -59,6 +78,15 @@ func dataSourceYandexResourceManagerCloudRead(d *schema.ResourceData, meta inter CloudId: cloudID, }) + req := &resourcemanager.ListFoldersRequest{CloudId: cloudID} + it := config.sdk.ResourceManager().Folder().FolderIterator(ctx, req) + var folders []map[string]string + for it.Next() { + id := it.Value().GetId() + name := it.Value().Name + folders = append(folders, map[string]string{"name": name, "folder_id": id}) + } + if err != nil { return fmt.Errorf("failed to resolve data source cloud by id: %v", err) } @@ -67,6 +95,7 @@ func dataSourceYandexResourceManagerCloudRead(d *schema.ResourceData, meta inter d.Set("name", cloud.Name) d.Set("description", cloud.Description) d.Set("created_at", getTimestamp(cloud.CreatedAt)) + d.Set("folders", folders) d.SetId(cloud.Id) return nil diff --git a/yandex/resource_yandex_alb_backend_group.go b/yandex/resource_yandex_alb_backend_group.go index 6256c5464..fdb5a510c 100644 --- a/yandex/resource_yandex_alb_backend_group.go +++ b/yandex/resource_yandex_alb_backend_group.go @@ -69,6 +69,7 @@ func resourceYandexALBBackendGroup() *schema.Resource { "weight": { Type: schema.TypeInt, Optional: true, + Default: 1, }, "port": { Type: schema.TypeInt, @@ -106,6 +107,7 @@ func resourceYandexALBBackendGroup() *schema.Resource { "weight": { Type: schema.TypeInt, Optional: true, + Default: 1, }, "port": { Type: schema.TypeInt, @@ -139,6 +141,7 @@ func resourceYandexALBBackendGroup() *schema.Resource { "weight": { Type: schema.TypeInt, Optional: true, + Default: 1, }, "port": { Type: schema.TypeInt, diff --git a/yandex/resource_yandex_alb_backend_group_test.go b/yandex/resource_yandex_alb_backend_group_test.go index e5b7d7938..11cb888ca 100644 --- a/yandex/resource_yandex_alb_backend_group_test.go +++ b/yandex/resource_yandex_alb_backend_group_test.go @@ -335,7 +335,7 @@ func TestAccALBBackendGroup_streamBackend(t *testing.T) { BGResource := albBackendGroupInfo() BGResource.IsStreamBackend = true - BGResource.IsGRPCCheck = true + BGResource.IsHTTPCheck = true var bg apploadbalancer.BackendGroup backendPath := "" @@ -360,7 +360,7 @@ func TestAccALBBackendGroup_streamBackend(t *testing.T) { albBGResource, "stream_backend", "healthcheck.*.interval", albDefaultInterval, &backendPath, ), testExistsElementWithAttrValue( - albBGResource, "stream_backend", "healthcheck.*.grpc_healthcheck.0.service_name", albDefaultServiceName, &backendPath, + albBGResource, "stream_backend", "healthcheck.*.http_healthcheck.0.host", albDefaultHost, &backendPath, ), ), }, diff --git a/yandex/resource_yandex_kubernetes_node_group.go b/yandex/resource_yandex_kubernetes_node_group.go index e501b62a1..aa3a0e3e4 100644 --- a/yandex/resource_yandex_kubernetes_node_group.go +++ b/yandex/resource_yandex_kubernetes_node_group.go @@ -236,19 +236,22 @@ func resourceYandexKubernetesNodeGroup() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "min": { - Type: schema.TypeInt, - Required: true, - ForceNew: false, + Type: schema.TypeInt, + Required: true, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), }, "max": { - Type: schema.TypeInt, - Required: true, - ForceNew: false, + Type: schema.TypeInt, + Required: true, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), }, "initial": { - Type: schema.TypeInt, - Required: true, - ForceNew: false, + Type: schema.TypeInt, + Required: true, + ForceNew: false, + ValidateFunc: validation.IntAtLeast(0), }, }, }, @@ -616,23 +619,12 @@ func getNodeGroupScalePolicy(d *schema.ResourceData) (*k8s.ScalePolicy, error) { } return nil, fmt.Errorf("no size has been specified for a node group with a fixed scale policy") default: // okAuto - var min, max, initial interface{} - var ok bool - if min, ok = d.GetOk("scale_policy.0.auto_scale.0.min"); !ok { - return nil, fmt.Errorf("no min size has been specified for a node group with an auto scale policy") - } - if max, ok = d.GetOk("scale_policy.0.auto_scale.0.max"); !ok { - return nil, fmt.Errorf("no max size has been specified for a node group with an auto scale policy") - } - if initial, ok = d.GetOk("scale_policy.0.auto_scale.0.initial"); !ok { - return nil, fmt.Errorf("no initial size has been specified for a node group with an auto scale policy") - } return &k8s.ScalePolicy{ ScaleType: &k8s.ScalePolicy_AutoScale_{ AutoScale: &k8s.ScalePolicy_AutoScale{ - MinSize: int64(min.(int)), - MaxSize: int64(max.(int)), - InitialSize: int64(initial.(int)), + MinSize: int64(d.Get("scale_policy.0.auto_scale.0.min").(int)), + MaxSize: int64(d.Get("scale_policy.0.auto_scale.0.max").(int)), + InitialSize: int64(d.Get("scale_policy.0.auto_scale.0.initial").(int)), }, }, }, nil