Skip to content

Commit

Permalink
resource/alicloud_alb_server_group: Supported protocol set to gRPC, a…
Browse files Browse the repository at this point in the history
…nd health_check_config.health_check_method set to POST
  • Loading branch information
MrWolong committed Jan 16, 2024
1 parent 369a172 commit 1ff1990
Show file tree
Hide file tree
Showing 4 changed files with 302 additions and 297 deletions.
2 changes: 1 addition & 1 deletion alicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ func Provider() terraform.ResourceProvider {
"alicloud_hbr_nas_backup_plan": resourceAlicloudHbrNasBackupPlan(),
"alicloud_hbr_oss_backup_plan": resourceAlicloudHbrOssBackupPlan(),
"alicloud_scdn_domain": resourceAlicloudScdnDomain(),
"alicloud_alb_server_group": resourceAlicloudAlbServerGroup(),
"alicloud_alb_server_group": resourceAliCloudAlbServerGroup(),
"alicloud_data_works_folder": resourceAlicloudDataWorksFolder(),
"alicloud_arms_alert_contact_group": resourceAlicloudArmsAlertContactGroup(),
"alicloud_dcdn_domain_config": resourceAlicloudDcdnDomainConfig(),
Expand Down
210 changes: 105 additions & 105 deletions alicloud/resource_alicloud_alb_server_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ package alicloud

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
"log"
"time"

util "github.com/alibabacloud-go/tea-utils/service"
"github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
)

func resourceAlicloudAlbServerGroup() *schema.Resource {
func resourceAliCloudAlbServerGroup() *schema.Resource {
return &schema.Resource{
Create: resourceAlicloudAlbServerGroupCreate,
Read: resourceAlicloudAlbServerGroupRead,
Update: resourceAlicloudAlbServerGroupUpdate,
Delete: resourceAlicloudAlbServerGroupDelete,
Create: resourceAliCloudAlbServerGroupCreate,
Read: resourceAliCloudAlbServerGroupRead,
Update: resourceAliCloudAlbServerGroupUpdate,
Delete: resourceAliCloudAlbServerGroupDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand All @@ -28,26 +28,87 @@ func resourceAlicloudAlbServerGroup() *schema.Resource {
},
CustomizeDiff: resourceAlbServerGroupCustomizeDiff,
Schema: map[string]*schema.Schema{
"dry_run": {
Type: schema.TypeBool,
"server_group_name": {
Type: schema.TypeString,
Optional: true,
},
"health_check_config": {
"server_group_type": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"Instance", "Ip", "Fc"}, false),
},
"protocol": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: StringInSlice([]string{"HTTP", "HTTPS", "gRPC"}, false),
},
"vpc_id": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"scheduler": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"Sch", "Wlc", "Wrr"}, false),
},
"resource_group_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"sticky_session_config": {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"health_check_connect_port": {
"sticky_session_enabled": {
Type: schema.TypeBool,
Optional: true,
},
"sticky_session_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: StringInSlice([]string{"Insert", "Server"}, false),
},
"cookie": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"cookie_timeout": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(0, 65535),
ValidateFunc: validation.Any(validation.IntInSlice([]int{0}), validation.IntBetween(1, 86400)),
},
},
},
},
"health_check_config": {
Type: schema.TypeSet,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"health_check_enabled": {
Type: schema.TypeBool,
Optional: true,
},
"health_check_connect_port": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: IntBetween(0, 65535),
},
"health_check_host": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -57,19 +118,19 @@ func resourceAlicloudAlbServerGroup() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"HTTP1.0", "HTTP1.1"}, false),
ValidateFunc: StringInSlice([]string{"HTTP1.0", "HTTP1.1"}, false),
},
"health_check_interval": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(1, 50),
ValidateFunc: IntBetween(1, 50),
},
"health_check_method": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"GET", "HEAD"}, false),
ValidateFunc: StringInSlice([]string{"GET", "POST", "HEAD"}, false),
},
"health_check_path": {
Type: schema.TypeString,
Expand All @@ -85,19 +146,19 @@ func resourceAlicloudAlbServerGroup() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(1, 300),
ValidateFunc: IntBetween(1, 300),
},
"healthy_threshold": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(2, 10),
ValidateFunc: IntBetween(2, 10),
},
"unhealthy_threshold": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.IntBetween(2, 10),
ValidateFunc: IntBetween(2, 10),
},
"health_check_codes": {
Type: schema.TypeList,
Expand All @@ -108,127 +169,66 @@ func resourceAlicloudAlbServerGroup() *schema.Resource {
},
},
},
"protocol": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{"HTTPS", "HTTP"}, false),
},
"resource_group_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"scheduler": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"Sch", "Wlc", "Wrr"}, false),
},
"server_group_name": {
Type: schema.TypeString,
Optional: true,
},
"server_group_type": {
Type: schema.TypeString,
ForceNew: true,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"Instance", "Ip", "Fc"}, false),
},
"servers": {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"description": {
Type: schema.TypeString,
Optional: true,
},
"port": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 65535),
},
"server_id": {
Type: schema.TypeString,
Required: true,
},
"server_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: StringInSlice([]string{"Ecs", "Eni", "Eci", "Ip", "Fc"}, false),
},
"server_ip": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"server_type": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"Ecs", "Eni", "Eci", "Ip", "Fc"}, false),
},
"weight": {
"port": {
Type: schema.TypeInt,
Optional: true,
Default: 100,
ValidateFunc: validation.IntBetween(0, 100),
ValidateFunc: IntBetween(0, 65535),
},
"remote_ip_enabled": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
},
},
},
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"sticky_session_config": {
Type: schema.TypeSet,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cookie": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"cookie_timeout": {
"weight": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ValidateFunc: validation.Any(validation.IntInSlice([]int{0}), validation.IntBetween(1, 86400)),
Default: 100,
ValidateFunc: IntBetween(0, 100),
},
"sticky_session_enabled": {
Type: schema.TypeBool,
"description": {
Type: schema.TypeString,
Optional: true,
},
"sticky_session_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{"Insert", "Server"}, false),
"status": {
Type: schema.TypeString,
Computed: true,
},
},
},
ForceNew: true,
},
"tags": tagsSchema(),
"vpc_id": {
Type: schema.TypeString,
"dry_run": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
}
}

func resourceAlicloudAlbServerGroupCreate(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudAlbServerGroupCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
var response map[string]interface{}
action := "CreateServerGroup"
Expand Down Expand Up @@ -330,9 +330,9 @@ func resourceAlicloudAlbServerGroupCreate(d *schema.ResourceData, meta interface
return WrapErrorf(err, IdMsg, d.Id())
}

return resourceAlicloudAlbServerGroupUpdate(d, meta)
return resourceAliCloudAlbServerGroupUpdate(d, meta)
}
func resourceAlicloudAlbServerGroupRead(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudAlbServerGroupRead(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
albService := AlbService{client}
object, err := albService.DescribeAlbServerGroup(d.Id())
Expand Down Expand Up @@ -418,7 +418,7 @@ func resourceAlicloudAlbServerGroupRead(d *schema.ResourceData, meta interface{}

return nil
}
func resourceAlicloudAlbServerGroupUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudAlbServerGroupUpdate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
albService := AlbService{client}
var response map[string]interface{}
Expand Down Expand Up @@ -688,9 +688,9 @@ func resourceAlicloudAlbServerGroupUpdate(d *schema.ResourceData, meta interface
d.SetPartial("server_group_name")
}
d.Partial(false)
return resourceAlicloudAlbServerGroupRead(d, meta)
return resourceAliCloudAlbServerGroupRead(d, meta)
}
func resourceAlicloudAlbServerGroupDelete(d *schema.ResourceData, meta interface{}) error {
func resourceAliCloudAlbServerGroupDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*connectivity.AliyunClient)
action := "DeleteServerGroup"
var response map[string]interface{}
Expand Down
Loading

0 comments on commit 1ff1990

Please sign in to comment.