Skip to content

Commit

Permalink
missing resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Paras Prajapati authored and bcmdarroch committed Mar 8, 2023
1 parent 0d65a39 commit 47f60ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/resources/vault_cluster_admin_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ resource "hcp_vault_cluster_admin_token" "example" {

### Optional

- `project_id` (String) The ID of the HCP project where the HCP Vault cluster is located.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only
Expand Down
16 changes: 15 additions & 1 deletion internal/provider/resource_vault_cluster_admin_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/hashicorp/terraform-provider-hcp/internal/clients"
)

Expand Down Expand Up @@ -42,6 +43,15 @@ func resourceVaultClusterAdminToken() *schema.Resource {
ForceNew: true,
ValidateDiagFunc: validateSlugID,
},
// Optional inputs
"project_id": {
Description: "The ID of the HCP project where the HCP Vault cluster is located.",
Type: schema.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validation.IsUUID,
Computed: true,
},
// computed outputs
"created_at": {
Description: "The time that the admin token was created.",
Expand All @@ -63,10 +73,14 @@ func resourceVaultClusterAdminTokenCreate(ctx context.Context, d *schema.Resourc
client := meta.(*clients.Client)

clusterID := d.Get("cluster_id").(string)
projectID, err := GetProjectID(d.Get("project_id").(string), client.Config.ProjectID)
if err != nil {
return diag.Errorf("unable to retrieve project ID: %v", err)
}

loc := &models.HashicorpCloudLocationLocation{
OrganizationID: client.Config.OrganizationID,
ProjectID: client.Config.ProjectID,
ProjectID: projectID,
}

log.Printf("[INFO] reading Vault cluster (%s) [project_id=%s, organization_id=%s]", clusterID, loc.ProjectID, loc.OrganizationID)
Expand Down

0 comments on commit 47f60ea

Please sign in to comment.