From ea21b6f2e2282f739ceae0219471216d538cefc5 Mon Sep 17 00:00:00 2001 From: gavinmcnair Date: Wed, 23 Aug 2023 20:28:11 +0100 Subject: [PATCH] Updated the Terraform provider to not need ksocAccount Signed-off-by: gavinmcnair --- internal/ksoc/provider.go | 15 ++++----------- internal/ksoc/resource_aws_register.go | 4 ++-- internal/request/authedrequest.go | 5 +---- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/internal/ksoc/provider.go b/internal/ksoc/provider.go index 55320be..c30f173 100644 --- a/internal/ksoc/provider.go +++ b/internal/ksoc/provider.go @@ -2,6 +2,7 @@ package ksoc import ( "context" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) @@ -19,13 +20,6 @@ func New(version string) func() *schema.Provider { Description: "Ksoc API to target", Required: true, }, - "ksoc_account_id": { - Type: schema.TypeString, - Description: "Customer Ksoc account ID", - ForceNew: true, - Required: true, - Sensitive: true, - }, "access_key_id": { Type: schema.TypeString, Description: "Ksoc Customer Access ID", @@ -59,10 +53,9 @@ type Config struct { func configureProvider(ctx context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { config := Config{ - KsocApiUrl: d.Get("ksoc_api_url").(string), - KsocAccountId: d.Get("ksoc_account_id").(string), - AccessKeyId: d.Get("access_key_id").(string), - SecretKey: d.Get("secret_key").(string), + KsocApiUrl: d.Get("ksoc_api_url").(string), + AccessKeyId: d.Get("access_key_id").(string), + SecretKey: d.Get("secret_key").(string), } return &config, nil diff --git a/internal/ksoc/resource_aws_register.go b/internal/ksoc/resource_aws_register.go index 5b08955..0f97724 100644 --- a/internal/ksoc/resource_aws_register.go +++ b/internal/ksoc/resource_aws_register.go @@ -6,6 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/ksoclabs/terraform-provider-ksoc/internal/request" ) @@ -59,8 +60,7 @@ func resourceAwsRegisterCreate(ctx context.Context, d *schema.ResourceData, meta func resourceAwsRegisterRead(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { config := meta.(*Config) apiUrlBase := config.KsocApiUrl - ksocAccountId := config.KsocAccountId - targetURI := apiUrlBase + "/accounts/" + ksocAccountId + "/cloud/aws/register" + targetURI := apiUrlBase + "/cloud/aws/register" err := d.Set("api_path", targetURI) if err != nil { return diag.Errorf("Error setting api_path: %s", err) diff --git a/internal/request/authedrequest.go b/internal/request/authedrequest.go index ac35187..c3be224 100644 --- a/internal/request/authedrequest.go +++ b/internal/request/authedrequest.go @@ -11,13 +11,10 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/ksoclabs/terraform-provider-ksoc/internal/auth" ) -// -// Longer term all the authBody (apiUrlBase, accessKey, ksocAccountId, SecretKey) should come from a ksocMetadata provider object -// - func AuthenticatedRequest( ctx context.Context, apiUrlBase string,