Bianca Moreira e0216cab5b
Add HCP subcommand -- integrate with HCP library (#23897)
* Add HCP engine token logic

* Update documentation

* Fix content check

* Add changelog entry

* Update changelog/23897.txt

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>

* Update api/client.go

Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>

* Add error when HCP commands failed to be initialize

* Add tests for initHCPcommand function

* Update lib dependency

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Fix docs nav data

* Improve docs sections

* Update hcp lib dependency

* Fix content formatting

* Update lib dependency

* Fix HCPtokenhelper problem

* Fix HCPtokenhelper problem

* Remove HCP env variables

* Remove hcp helper token

* Add error treatment for no valid credential source

* Update website/content/docs/commands/hcp/index.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/disconnect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/connect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/disconnect.mdx

Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>

* Update website/content/docs/commands/hcp/index.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Update website/content/docs/commands/hcp/connect.mdx

Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>

* Modify hcp tests

---------

Co-authored-by: Nick Cabatoff <ncabatoff@hashicorp.com>
Co-authored-by: Chris Capurso <1036769+ccapurso@users.noreply.github.com>
Co-authored-by: Sarah Chavis <62406755+schavis@users.noreply.github.com>
Co-authored-by: Yoko Hyakuna <yoko@hashicorp.com>
2024-01-09 15:29:30 +01:00

61 lines
2.2 KiB
Plaintext

---
layout: docs
page_title: hcp connect - Command
description: |-
Use "hcp connect" command to authenticate users and machines to HCP with explicit
credentials or an HCP token and interactive browser login.
---
# hcp connect
The `hcp connect` command authenticates users and machines to HCP with explicit
credentials or an HCP token and interactive browser login.
By default, the `hcp connect` command uses interactive authentication that requires
users to log into the HashiCorp Cloud Platform with a browser.
Non-interactive login requires a service principal credential that was
previously generated through the HCP portal. The service principal must have
access to the requested organization, project, and HCP Vault cluster.
If authentication succeeds, the Vault CLI saves the returned HCP token and HCP
Vault address in the local cache.
## Examples
Connect to HCP interactively:
```shell-session
$ vault hcp connect
The default web browser has been opened at <auth_url>. Please continue the login in the web browser.
Success!
```
## Usage
The following flags are available in addition to the [standard set of
flags](/vault/docs/commands) included on all commands.
### Command options
- `-client-id` `(string: "")` - Client ID belonging to a service principal
credential generated in the HCP Portal. **Required for non-interactive
authentication**.
- `-secret-id` `(string: "")` - Secret ID belonging to a service principal
credential previously generated in the HCP Portal. **Required for
non-interactive authentication**.
- `-organization-id` `(string: "")` - Optional ID of the desired HCP
organization. If `organization-id` is empty and the user is associated with
multiple HCP organizations, the CLI prompts the user to select from a list
of available organizations.
- `-project-id` `(string: "")` - Optional ID of the desired HCP project. If
`project-id` is empty and the user is associated with more than one HCP
project, the CLI prompts the user to select from a list of available projects.
- `-cluster-id` `(string: "")` - Optional ID of the desired HCP Vault cluster.
If `cluster-id` is empty and the user is associated with multiple HCP clusters,
the CLI prompts the user to select from a list of available clusters.