2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Oracle Cloud Infrastructure】CLI で Vault に Secret を作成する

Posted at

Oracle Cloud Infrastructure(OCI) の Key Management Service である Vault では、暗号鍵だけでなくシークレットも保管できる。

Screen Shot 2021-03-22 at 12.30.27 PM.png1

OCI CLI を使った Secret の作成と、作成した Secret の確認について。

Secret の登録

oci vault secret create-base64 で作成できる。
--vault-id--key-id が必要なので、事前に Vault とマスター鍵を作成しておく必要がある。
なお、管理コンソールからは平文のまま作成することもできるが、CLI からは Base64 値だけのよう。

fish
$ set secretvalue (echo "This is a test value" | base64)
$ echo $secretvalue
VGhpcyBpcyBhIHRlc3QgdmFsdWUK
$ oci vault secret create-base64 -c ocid1.compartment.oc1.exampleuniqueID --secret-name test-value --vault-id ocid1.vault.oc1.ap-tokyo-1.exampleuniqueID --key-id ocid1.key.oc1.ap-tokyo-1.exampleuniqueID --secret-content-content $secretvalue
{
  "data": {
    "compartment-id": "ocid1.compartment.oc1.exampleuniqueID",
    "current-version-number": 1,
    "defined-tags": {
      "control_internal": {
        "owner_id": "${iam.principal.id}",
        "owner_name": "oracleidentitycloudservice/hitsumabushi845@example.com"
      }
    },
    "description": null,
    "freeform-tags": {},
    "id": "ocid1.vaultsecret.oc1.ap-tokyo-1.exampleuniqueID",
    "key-id": "ocid1.key.oc1.ap-tokyo-1.exampleuniqueID",
    "lifecycle-details": null,
    "lifecycle-state": "CREATING",
    "metadata": null,
    "secret-name": "test-value",
    "secret-rules": null,
    "time-created": "2021-03-22T03:22:39.184000+00:00",
    "time-of-current-version-expiry": null,
    "time-of-deletion": null,
    "vault-id": "ocid1.vault.oc1.ap-tokyo-1.exampleuniqueID"
  },
  "etag": "d89a537eba6c2f7652a4cf6647d3cf673b6290bc3423b85a4719e676c0d4c6e6"
}

Secret の確認

oci secrets secret-bundle get で作成済みの Secret を取得する。
Base64 値の場合は jq と組み合わせて以下のようなワンライナーで確認できる。

$ oci secrets secret-bundle get --secret-id ocid1.vaultsecret.oc1.ap-tokyo-1.exampleuniqueID | jq '.data["secret-bundle-content"].content' -r | base64 -d
This is a test value

See also

  1. 図はSpakerDeckから。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?