LoginSignup
0
0

More than 1 year has passed since last update.

[忘備録] AWS CloudFormationでLightsailでインスタンスを作るときに必要な「BlueprintId」「bundleId」を調べる

Last updated at Posted at 2023-02-08

はじめに

AWS CloudFormationでLightsailのインスタンスを作る時に必要なインスタンスイメージ「blueprint_id」「bundleId」を調べる

参考

公式のドキュメント

以下、参考にさせていただいたサイト

結論、LightsailのAPIから「blueprint_id」「bundleId」を取得する

【blueprint_idを取得】使用するAPI:「get-blueprints」

Lightsailで使用可能なインスタンス イメージまたはブループリントのリストを取得する

【bundleIdを取得】使用するAPI:「get-bundles」

Lightsailインスタンスに適用できるバンドルを取得する

バンドルは、インスタンスの仕様 (毎月のコスト、メモリ量、vCPU の数、ストレージ スペースの量、毎月のネットワーク データ転送クォータなど) のこと


実践

「get-blueprints」APIを実行してインスタンスイメージリストを取得する

AWS CLIでLightsailの「get-blueprints」APIを実行する

aws lightsail get-blueprints 
API実行結果
$ aws lightsail get-blueprints
{
    "blueprints": [
        {
            "blueprintId": "windows_server_2019",
            "name": "Windows Server 2019",
            "group": "windows_2019",
            "type": "os",
            "description": "Amazon Lightsail helps you build, deploy, scale, and manage Microsoft applications quickly, easily, and cost effectively with Windows Server 2019. For business IT applications, Lightsail runs Windows-based solutions in a secure, easily managed, and performant cloud environment. Common Windows use cases include Enterprise Windows-based application hosting, website and web-service hosting, data processing, distributed testing, ASP.NET application hosting, and running any other application requiring Windows software.",
            "isActive": true,
            "minPower": 0,
            "version": "2023.01.19",
            "versionCode": "1",
            "productUrl": "https://aws.amazon.com/marketplace/pp/B07QZ4XZ8F",
            "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/ef297a90-3ad0-4674-83b4-7f0ec07c39bb/8dcaef51-8e20-41b3-a622-57864d247f86.txt",
            "platform": "WINDOWS"
        },
~~~~~略~~~~~

全てのインスタンスイメージのリストが返ってきてめっちゃ多くて探しにくかった・・

「get-blueprints」APIの結果から必要なインスタンスイメージのみ取得する(jqコマンドで絞り込み)

jqコマンドは入力を受け取り、出力を生成するプログラム
オブジェクトの特定のフィールドを抽出、数値を文字列に変換、フィルターなどできる。

準備:jqコマンドインストール(Homebrew)

$ brew install jq

実行:Linux/Unixのインスタンスイメージのみ取得する

"blueprints": [{"platform": "LINUX_UNIX",...}]となっているオブジェクトで絞り込む

aws lightsail get-blueprints | jq '.blueprints[] | select(.platform == "LINUX_UNIX")'
API実行&絞り込み結果
$ aws lightsail get-blueprints | jq '.blueprints[] | select(.platform == "LINUX_UNIX")'
{
  "blueprintId": "amazon_linux_2",
  "name": "Amazon Linux 2",
  "group": "amazon_linux_2",
  "type": "os",
  "description": "Amazon Linux 2 image (HVM / 64-bit). The Amazon Linux 2 image is a supported and maintained Linux image provided by Amazon Web Services (AWS) for use on Amazon Lightsail. It is designed to provide a stable, secure, and high performance execution environment for applications running on Lightsail. It also includes packages that enable easy integration with AWS, including launch configuration tools and many popular AWS libraries and tools. AWS provides ongoing security and maintenance updates to all instances running the Amazon Linux 2 image. The Amazon Linux 2 image is provided at no additional charge to Lightsail users.",
  "isActive": true,
  "minPower": 0,
  "version": "2.0.20230119.1",
  "versionCode": "1",
  "productUrl": "https://aws.amazon.com/amazon-linux-2/",
  "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/f37c8255-1ff9-48bd-b5da-b5046f4fee68/17864b80-f5b6-4f0a-aa26-7346ef135ebc.txt",
  "platform": "LINUX_UNIX"
}
{
  "blueprintId": "ubuntu_20_04",
  "name": "Ubuntu",
  "group": "ubuntu_20",
  "type": "os",
  "description": "Ubuntu 20.04 LTS - Focal. Lean, fast and powerful, Ubuntu Server delivers services reliably, predictably and economically. It is the perfect base on which to build your instances. Ubuntu is free and will always be, and you have the option to get support and Landscape from Canonical.",
  "isActive": true,
  "minPower": 0,
  "version": "20.04 LTS",
  "versionCode": "1",
  "productUrl": "https://aws.amazon.com/marketplace/pp/B087QQNGF1",
  "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/aced0818-eef1-427a-9e04-8ba38bada306/0f54e60e-b0e5-43dc-9e02-c7a340498b1b.txt",
  "platform": "LINUX_UNIX"
}
~~略~~

「get-bundles」APIを実行してバンドルリストを取得する

AWS CLIでLightsailの「get-bundles」APIを実行する

aws lightsail get-bundles
API実行結果
$ aws lightsail get-bundles
{
    "bundles": [
        {
            "price": 3.5,
            "cpuCount": 1,
            "diskSizeInGb": 20,
            "bundleId": "nano_2_0",
            "instanceType": "nano",
            "isActive": true,
            "name": "Nano",
            "power": 300,
            "ramSizeInGb": 0.5,
            "transferPerMonthInGb": 1024,
            "supportedPlatforms": [
                "LINUX_UNIX"
            ]
        },
~~略~~

以上

0
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
0
0