From cf970042fc3b15dd565a5990de379371c83f7c56 Mon Sep 17 00:00:00 2001 From: Damir Sayfutdinov Date: Mon, 18 Nov 2024 10:59:22 +0300 Subject: [PATCH] Speed up ssh keypair resource Use new method for listing keypairs, which has optional filter by user_id. This works faster when there are a large number of users in the account. --- go.mod | 2 +- go.sum | 4 ++-- selectel/resource_selectel_vpc_keypair_v2.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 9d95c8d0..6b3a0bdf 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/selectel/craas-go v0.3.0 github.com/selectel/dbaas-go v0.12.1 github.com/selectel/domains-go v1.0.2 - github.com/selectel/go-selvpcclient/v3 v3.1.1 + github.com/selectel/go-selvpcclient/v3 v3.2.1 github.com/selectel/iam-go v0.4.1 github.com/selectel/mks-go v0.16.0 github.com/selectel/secretsmanager-go v0.2.1 diff --git a/go.sum b/go.sum index 4b0815dd..cee05dd0 100644 --- a/go.sum +++ b/go.sum @@ -168,8 +168,8 @@ github.com/selectel/dbaas-go v0.12.1 h1:u3mBMoHP/FnHucLqd1QBeBHjQ2WV4S88ewP97gCE github.com/selectel/dbaas-go v0.12.1/go.mod h1:Ffq6RQ4PmgZX8eL9oXsaKDc0lzbCK9wadyDV6AHaz/k= github.com/selectel/domains-go v1.0.2 h1:Si6iGaMnTFJxwiJVI50DOdZnwcxc87kqaWrVQYW0a4U= github.com/selectel/domains-go v1.0.2/go.mod h1:SugRKfq4sTpnOHquslCpzda72wV8u0cMBHx0C0l+bzA= -github.com/selectel/go-selvpcclient/v3 v3.1.1 h1:C1q2LqqosiapoLpnGITGmysg0YCSQYDo2Gh69CioevM= -github.com/selectel/go-selvpcclient/v3 v3.1.1/go.mod h1:NM7IXhh1IzqZ88DOw1Qc5Ez3tULLViXo95l5+rKPuyQ= +github.com/selectel/go-selvpcclient/v3 v3.2.1 h1:ny6WIAMiHzKxOgOEnwcWE79wIQij1AHHylzPA41MXCw= +github.com/selectel/go-selvpcclient/v3 v3.2.1/go.mod h1:3EfSf8aEWyhspOGbvZ6mvnFg7JN5uckxNyBFPGWsXNQ= github.com/selectel/iam-go v0.4.1 h1:grncCGkPVCM6nwqSTk+q15M5ZO6S/Pe0AIbbmKtm6gU= github.com/selectel/iam-go v0.4.1/go.mod h1:OIAkW7MZK97YUm+uvUgYbgDhkI9SdzTCxwd4yZoOR1o= github.com/selectel/mks-go v0.16.0 h1:qE4kMKQQV6iluu1W0WTzu3NJhXghS8GF20fIzV+3FOU= diff --git a/selectel/resource_selectel_vpc_keypair_v2.go b/selectel/resource_selectel_vpc_keypair_v2.go index b4547af9..7069960f 100644 --- a/selectel/resource_selectel_vpc_keypair_v2.go +++ b/selectel/resource_selectel_vpc_keypair_v2.go @@ -92,7 +92,7 @@ func resourceVPCKeypairV2Read(_ context.Context, d *schema.ResourceData, meta in if err != nil { return diag.FromErr(errParseID(objectKeypair, d.Id())) } - existingKeypairs, _, err := keypairs.List(selvpcClient) + existingKeypairs, _, err := keypairs.ListWithOpts(selvpcClient, keypairs.ListOpts{UserID: userID}) if err != nil { return diag.FromErr(errSearchingKeypair(keypairName, err)) }