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

VpcPeer: Improves the invoking vpcpeer api method and supports refreshing credential automatically #7823

Closed
wants to merge 3 commits into from
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
288 changes: 156 additions & 132 deletions alicloud/connectivity/client.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions alicloud/connectivity/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Config struct {
SecurityToken string
OtsInstanceName string
AccountId string
AccountType string
Protocol string
ClientReadTimeout int
ClientConnectTimeout int
Expand Down
340 changes: 318 additions & 22 deletions alicloud/connectivity/endpoint.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions alicloud/connectivity/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package connectivity

import "strings"

func ConvertKebabToSnake(s string) string {
return strings.ReplaceAll(s, "-", "_")
}
10 changes: 2 additions & 8 deletions alicloud/data_source_alicloud_vpc_peer_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/PaesslerAG/jsonpath"
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"
Expand Down Expand Up @@ -145,16 +144,11 @@ func dataSourceAlicloudVpcPeerConnectionsRead(d *schema.ResourceData, meta inter
}
status, statusOk := d.GetOk("status")
var response map[string]interface{}
conn, err := client.NewVpcpeerClient()
if err != nil {
return WrapError(err)
}
var err error
for {
runtime := util.RuntimeOptions{}
runtime.SetAutoretry(true)
wait := incrementalWait(3*time.Second, 3*time.Second)
err = resource.Retry(5*time.Minute, func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2022-01-01"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("VpcPeer", "2022-01-01", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
6 changes: 3 additions & 3 deletions alicloud/data_source_alicloud_vpc_peer_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ variable "name" {
}
data "alicloud_account" "default" {}

data "alicloud_vpcs" "default" {
name_regex = "^default-NODELETING$"
resource "alicloud_vpc" "default" {
vpc_name = var.name
}

resource "alicloud_vpc_peer_connection" "default" {
peer_connection_name = var.name
vpc_id = data.alicloud_vpcs.default.ids.0
accepting_ali_uid = data.alicloud_account.default.id
accepting_region_id = "%s"
accepting_vpc_id = data.alicloud_vpcs.default.ids.1
accepting_vpc_id = alicloud_vpc.default.id
description = var.name
}

Expand Down
Loading
Loading