Skip to content

Commit

Permalink
Updated the Terraform provider to not need ksocAccount
Browse files Browse the repository at this point in the history
Signed-off-by: gavinmcnair <[email protected]>
  • Loading branch information
gavinmcnair committed Aug 23, 2023
1 parent 95f38fe commit ea21b6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
15 changes: 4 additions & 11 deletions internal/ksoc/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions internal/ksoc/resource_aws_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions internal/request/authedrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ea21b6f

Please sign in to comment.