tomy_125 の メモ

個人的な見解や、感想を記載しており、何らかの組織を代表してのものではありません。

OCI CLI から Compute Instance を作成する時に使用するコマンド

launch コマンド

以下を設定することで コンピュートを作成できる OCI_DISPLAY_NAME は インスタンスの"名前"

$ oci compute instance launch \
  --display-name ${OCI_DISPLAY_NAME} \
  --availability-domain ${OCI_AD} \
  --image-id ${OCI_IMAGE_ID} \
  --shape ${OCI_SHAPE} \
  --subnet-id ${OCI_SUBNET_ID} \
  --assign-public-ip ${OCI_BOOLEAN_PUBLIC_IP} \  -------- PUBLIC IP を付与する場合はTRUE
  --ssh-authorized-keys-file ${OCI_PUB_KEY}            -------- 公開鍵パスを指定

環境変数を設定するコマンド

$ export OCI_AD=`oci iam availability-domain list | jq -r '.data[0]["name"]'`
$ echo $OCI_AD
aefv:AP-TOKYO-1-AD-1

それぞれを OCIコマンドで確認する方法は以下

AD 確認

$ oci iam availability-domain list
{
  "data": [
    {
      "compartment-id": "ocid1.compartment.oc1..aaaaaaaafjv42qskxf4xmdv7qqcyfnjxnpkoaq33utfbxe6msltviwdyzcea",
      "id": "ocid1.availabilitydomain.oc1..aaaaaaaaaijs56nfsz2usbwsr6k6t5b3do7hns6ib2day6le5scrvvjpeceq",
      "name": "aefv:AP-TOKYO-1-AD-1"
    }
  ]
}

image 確認

# 戻りのjson key 確認
$ oci compute image list | jq -r '.data[0] | keys'
[
  "agent-features",
  "base-image-id",
  "billable-size-in-gbs",
  "compartment-id",
  "create-image-allowed",
  "defined-tags",
  "display-name",
  "freeform-tags",
  "id",
  "launch-mode",
  "launch-options",
  "lifecycle-state",
  "listing-type",
  "operating-system",  -- "Oracle Linux" など
  "operating-system-version",  -- "6.10", "7", "8" など
  "size-in-mbs",
  "time-created"
]

$ oci compute image list --operating-system "Oracle Linux" --operating-system-version "6.10" | jq -r '.data[] | {name:.["display-name"], oci_id:.["id"] }'
{
  "name": "Oracle-Linux-6.10-2021.03.17-0",
  "oci_id": "ocid1.image.oc1.ap-tokyo-1.aaaaaaaazklpkbg2reajttkezdzenx745sfbkps362q4lu7cas3piyynbr5q"
}
{
  "name": "Oracle-Linux-6.10-2021.02.19-0",
  "oci_id": "ocid1.image.oc1.ap-tokyo-1.aaaaaaaaps3c7pb2boenemaac2vsgzmnxi4arjlrantbpq46lhthzvpsuc6a"
}
{
  "name": "Oracle-Linux-6.10-2021.01.12-0",
  "oci_id": "ocid1.image.oc1.ap-tokyo-1.aaaaaaaafaxmn7edxrtd2lw6bfzjfqh4xvzdd4nz6xjyfk3xav4wbi6ukzyq"
}

shape確認

$ oci compute shape list | jq -r '.data[0] | keys '
[
  "baseline-ocpu-utilizations",
  "gpu-description",
  "gpus",
  "is-live-migration-supported",
  "local-disk-description",
  "local-disks",
  "local-disks-total-size-in-gbs",
  "max-vnic-attachment-options",
  "max-vnic-attachments",
  "memory-in-gbs",
  "memory-options",
  "min-total-baseline-ocpus-required",
  "networking-bandwidth-in-gbps",
  "networking-bandwidth-options",
  "ocpu-options",
  "ocpus",
  "platform-config-options",
  "processor-description",
  "shape"
]

$ oci compute shape list --region "ap-tokyo-1" --image-id "ocid1.image.oc1.ap-tokyo-1.aaaaaaaazklpkbg2reajttkezdzenx745sfbkps362q4lu7cas3piyynbr5q" | jq -r '.data[] | { shape : .["shape"], ocpus : .["ocpus"] , memory:.["memory-in-gbs"]}'

subnet id 確認

$ oci network subnet list | jq -r '.data[0] | keys'
[
  "availability-domain",
  "cidr-block",
  "compartment-id",
  "defined-tags",
  "dhcp-options-id",
  "display-name",
  "dns-label",
  "freeform-tags",
  "id",
  "ipv6-cidr-block",
  "ipv6-virtual-router-ip",
  "lifecycle-state",
  "prohibit-internet-ingress",
  "prohibit-public-ip-on-vnic",
  "route-table-id",
  "security-list-ids",
  "subnet-domain-name",
  "time-created",
  "vcn-id",
  "virtual-router-ip",
  "virtual-router-mac"
]

oci network subnet list | jq -r '.data[] | {display_name: .["display-name"], id : .["id"]}'