# 1Password Service Accountsを初めて使う

### **1Password Service Accountsを初めて使う** <a href="#yix8chij2yvl" id="yix8chij2yvl"></a>

1Password Service Accountsを使うと、追加のサービスを導入することなく、アプリケーションとインフラ内のシークレット管理を自動化するツールを構築できます。

サービスアカウントは次のことができます。

* アイテムをCreate、編集、削除、共有する。
* 保管庫をCreateする。
* 保管庫を削除する。\
  サービスアカウントは、自分がCreateした保管庫のみを削除できます。[サービスアカウントのセキュリティー](https://developer.1password.com/docs/service-accounts/security/)を参照してください。
* ユーザーとグループに関する情報を取得する。

各サービスアカウントには、認証用の環境変数として提供できる[サービスアカウントトークン](https://developer.1password.com/docs/service-accounts/security/#service-accounts-and-token-generation)があります。サービスアカウントがアクセスできる保管庫と、各保管庫での権限を選択できます。

<https://youtu.be/E3HKeG9P8HA><br>

制限事項

サービスアカウントには次の制限があります。

* サービスアカウントには[レート制限があり、リクエストクォータがあります](https://developer.1password.com/docs/service-accounts/rate-limits/)。
* 組み込みの[個人用](https://support.1password.com/1password-glossary/#personal-vault)、[プライベート](https://support.1password.com/1password-glossary/#private-vault)、[従業員用](https://support.1password.com/1password-glossary/#employee-vault)コンテナー、またはデフォルトの[共有](https://support.1password.com/1password-glossary/#shared-vault)コンテナーへのアクセス権をサービスアカウントに付与することはできません。
* サービスアカウントは、1Password CLI バージョン 2.18.0 以降でのみ機能します。「[1Password CLI でサービスアカウントを使う](https://developer.1password.com/docs/service-accounts/use-with-1password-cli/)」を参照してください。
* [Kubernetes Operator](https://developer.1password.com/docs/k8s/k8s-integrations/#kubernetes-operator)ではサービスアカウントは使えません（[Kubernetes Secrets Injector](https://developer.1password.com/docs/k8s/k8s-integrations/#kubernetes-injector)のみ使えます）。

### **必要条件** <a href="#t4nqdsvfephi" id="t4nqdsvfephi"></a>

サービスアカウントをCreateって使う前に、次のことを行う必要があります。

* [1Passwordにサインアップする。](https://1password.com/pricing)
* サービスアカウントをCreateするための適切なアカウント権限を持っていること。

サービスアカウントをCreateするオプションが表示されない場合は、管理者に[サービスアカウントのCreateと管理のアクセス権を付与する](https://developer.1password.com/docs/service-accounts/manage-service-accounts#manage-who-can-create-service-accounts)よう依頼してください。

### **サービスアカウント** <a href="#e2yhqqml2hzs" id="e2yhqqml2hzs"></a>

1Password.comまたは[1Password CLI](https://developer.1password.com/docs/cli/)を使ってサービスアカウントをCreateできます。サービスアカウントをCreateした後は、保管庫をCreateする機能や保管庫に対する権限を編集することはできません。

* 1Password.com

1Password.comでサービスアカウントをCreateするには以下のようにします。

①1Password.com のアカウントに[サインイン](https://start.1password.com/signin)します。\
②サイドバーで\[Developer Tools]を選択します。既にアクティブなDeveloper Toolsがある場合は、「Developer Tools」ページの上部にある\[Directory]を選択します。\
③「Infrastructure Secrets Management」で、[「Other」](https://start.1password.com/developer-tools/infrastructure-secrets)を選択します。\
④\[Create a Service Account]を選択し、画面の指示に従います。

* * 1\. サービスアカウントの名前を選択します。
  * 2\. サービスアカウントが保管庫をCreateできるかどうかを選択します。
  * 3\. サービスアカウントがアクセスできる保管庫を選択します。\
    組み込みの個人用、プライベート、従業員用保管庫、またはデフォルトの共有保管庫へのアクセス権をサービスアカウントに付与することはできません。
  * 4\. 設定アイコ&#x30F3;**⚙**&#x3092;選択をクリックして、サービスアカウントが保管庫内で持つ権限を選択します。これは後で変更できません。
  * 5\. \[Create Account]を選択して サービスアカウントをCreateします。
  * 6\. \[Save in 1Password]を選択して、サービスアカウントトークンを 1Password アカウントにSaveします。次のウィンドウで、アイテムの名前を入力し、Save先の保管庫を選択します。

🔥危険\
サービスアカウントCreateウィザードでは、サービスアカウントトークンが1度だけ表示されます。**トークンを紛失しないように、すぐに1PasswordにSaveしてください。**&#x3053;のトークンはパスワードのように扱い、平文でSaveしないでください。

* 1Password CLI

1Password CLIでサービスアカウントをCreateするには以下のようにします。\
①お使いのマシンに1Password CLIの最新バージョンがあることを確認してください。\
②op service-account createコマンドを使って新しいサービスアカウントをCreateします。

$ op service-account create \<serviceAccountName> --expires-in \<duration> --vault \<vault-name:\<permission>,\<permission>

* 利用可能なパーミッション： read\_items、 write\_items（read\_itemsが必要）、 share\_items（read\_itemsが必要）
* サービスアカウントが新しいデータ保管庫をCreateできるようにするには、--can-create-vaultsフラグを含めます。
* サービスアカウント名またはデータ保管庫名にスペースが含まれる場合は、その名前を引用符で囲みます（例："My Service Account"）。文字列にスペースが含まれない場合は、引用符で囲む必要はありません（例：myServerName）。
* サービスアカウントは、Create後に変更することはできません。変更が必要な場合は、サービスアカウントを失効させ、新しいアカウントをCreateしてください。

③サービスアカウントトークンを1PasswordアカウントにSaveします。\
④1Password CLIでサービスアカウントの使用を開始する場合は、トークンを環境変数OP\_SERVICE\_ACCOUNT\_TOKENにエクスポートします。

例えばProductionという名前のデータ保管庫に読み取り権限と書き込み権限を持ち、新しいデータ保管庫をCreateでき、24時間で有効期限が切れるMy Service Accountという名前のサービスアカウントをCreateるには次のように入力します。\
$ op service-account create "My Service Account" --can-create-vaults --expires-in 24h --vault Production:read\_items,write\_items

🔥危険\
1Password CLIはサービスアカウントトークンを一度しか返しません。**トークンを紛失しないように、すぐに1PasswordにSaveしてください。**&#x3053;のトークンはパスワードのように扱い、平文でSaveしないでください。

⚠️注意\
[サインインアドレス](https://support.1password.com/1password-glossary/#sign-in-address)を変更した場合は、[サービスアカウントトークンをローテートする](https://developer.1password.com/docs/service-accounts/manage-service-accounts#rotate-token)必要があります。

### **次のステップ** <a href="#id-59w7o6m41h8h" id="id-59w7o6m41h8h"></a>

サービスアカウントの使用方法については、以下を参照してください。

* [1Password CLIでサービスアカウントを使用します。](https://developer.1password.com/docs/service-accounts/use-with-1password-cli/)
* [サービスアカウントを管理します。](https://developer.1password.com/docs/service-accounts/manage-service-accounts/)
* [サービスアカウントをCI/CDパイプラインと統合します。](https://developer.1password.com/docs/ci-cd/)
* [サービスアカウントをKubernetesと統合します。](https://developer.1password.com/docs/k8s/k8s-integrations/)

💡ヘルプが必要ですか?

[開発者向けのSlackワークスペースに参加して](https://developer.1password.com/joinslack)質問したりフィードバックを提供したりしてください。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://manual.dxable.com/1password/get-started-with-1password-service-accounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
