Skip to content

Commit

Permalink
Merge branch 'yandex-cloud:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
suslovsergey authored Jan 26, 2022
2 parents 948010f + 7e6f83f commit 8f23965
Show file tree
Hide file tree
Showing 14 changed files with 126 additions and 38 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down Expand Up @@ -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`
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions website/docs/r/alb_target_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
```
Expand Down Expand Up @@ -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
```
```
4 changes: 2 additions & 2 deletions website/docs/r/cdn_resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/function_iam_binding.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion website/docs/r/mdb_mongodb_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
17 changes: 14 additions & 3 deletions yandex/alb_structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package yandex
import (
"bytes"
"fmt"
"google.golang.org/protobuf/types/known/wrapperspb"
"strings"

"github.com/golang/protobuf/ptypes/wrappers"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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}

Expand All @@ -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,
Expand Down
35 changes: 33 additions & 2 deletions yandex/base_alb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type resourceALBLoadBalancerInfo struct {

BalancerName string
RouterName string
BackendGroupName string
TargetGroupName string
ListenerName string
BalancerDescription string
AllowHTTP10 string
Expand All @@ -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,
Expand Down Expand Up @@ -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}}"
Expand Down Expand Up @@ -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}}
}
Expand All @@ -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}}"]
Expand Down
2 changes: 1 addition & 1 deletion yandex/data_source_yandex_alb_backend_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
29 changes: 29 additions & 0 deletions yandex/data_source_yandex_resourcemanager_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
},
},
},
}
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions yandex/resource_yandex_alb_backend_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func resourceYandexALBBackendGroup() *schema.Resource {
"weight": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
},
"port": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -106,6 +107,7 @@ func resourceYandexALBBackendGroup() *schema.Resource {
"weight": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
},
"port": {
Type: schema.TypeInt,
Expand Down Expand Up @@ -139,6 +141,7 @@ func resourceYandexALBBackendGroup() *schema.Resource {
"weight": {
Type: schema.TypeInt,
Optional: true,
Default: 1,
},
"port": {
Type: schema.TypeInt,
Expand Down
4 changes: 2 additions & 2 deletions yandex/resource_yandex_alb_backend_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := ""
Expand All @@ -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,
),
),
},
Expand Down
38 changes: 15 additions & 23 deletions yandex/resource_yandex_kubernetes_node_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
},
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f23965

Please sign in to comment.