Synthetics のランタイムバージョン - Amazon CloudWatch

Synthetics のランタイムバージョン

Canary を作成または更新する際に、Canary の Synthetics ランタイムバージョンを選択します。Synthetics ランタイムは、スクリプトハンドラーを呼び出す Synthetics コードと、バンドルされた依存関係の Lambda レイヤーを組み合わせたものです。

CloudWatch Synthetics は現在、スクリプトと Puppeteer フレームワークに Node.js を使用するランタイムと、スクリプトに Python を使用し、フレームワークには Selenium Webdriver を使用するランタイムをサポートしています。

Synthetics ライブラリの最新の機能や更新プログラムを使用できるように、Canary の最新のランタイムバージョンを常に使用することをお勧めします。

Canary を作成すると、作成されるレイヤーの 1 つは、先頭に Synthetics の追加された Synthetics レイヤーになります。このレイヤーは Synthetics サービスアカウントが所有し、ランタイムコードを含みます。

注記

Canary をアップグレードして新しいバージョンの Synthetics ランタイムを使用するたびに、Canary が使用するすべての Synthetics ライブラリ関数も Synthetics ランタイムがサポートするのと同じバージョンの NodeJS に自動的にアップグレードされます。

CloudWatch Synthetics ランタイムサポートポリシー

Synthetics ランタイムバージョンは、メンテナンスおよびセキュリティ更新プログラムに依存します。ランタイムバージョンのいずれかのコンポーネントがサポートされなくなると、その Synthetics ランタイムバージョンは非推奨となります。

非推奨のランタイムバージョンを使用して Canary を作成することはできません。非推奨のランタイムを使用する Canary が引き続き実行されます。これらの Canary は、停止、開始、削除することができます。サポートされているランタイムバージョンを使用するように Canary を更新することで、非推奨のランタイムバージョンを使用する既存の Canary を更新できます。

60 日以内に非推奨となる予定のランタイムを使用している Canary がある場合、CloudWatch Synthetics は通知メールをユーザーに送信します。最新のリリースに含まれる新しい機能、セキュリティ、および強化されたパフォーマンスを活用するために、Canary のランタイムは、サポートされているバージョンに更新することをお勧めします。

Canary を新しいランタイムバージョンに更新するにはどうすればよいですか?

CloudWatch コンソールから、AWS CloudFormation、AWS CLI、または AWS SDK を使用して、Canary のランタイムバージョンを更新できます。CloudWatch コンソールを使用する場合であれば、一度に最大 5 つの Canary を更新できます。これには、一覧ページから対象の Canary を選択した上で、[アクション]、[ランタイムの更新] の順にクリックします。

アップグレードを確認するためには、CloudWatch コンソールを使用して Canary をクローンし、そのランタイムバージョンを更新します。これにより、元の Canary のクローンである別の Canary が作成されます。新しいランタイムバージョンの Canary を検証し終えたら、元の Canary のランタイムバージョンを更新した後で、クローンの Canary を削除します。

アップグレード用のスクリプトを使用すると、複数の Canary を更新することもできます。詳細については、「Canary ランタイムアップグレード用スクリプト」を参照してください。

Canary のアップグレードに失敗した場合は、「失敗した Canary のトラブルシューティング」を参照してください。

ランタイムが非推奨となる日付

ランタイムバージョン 廃止日

syn-nodejs-puppeteer-6.1

2024 年 3 月 8 日

syn-nodejs-puppeteer-6.0

2024 年 3 月 8 日

syn-nodejs-puppeteer-5.1

2024 年 3 月 8 日

syn-nodejs-puppeteer-5.0

2024 年 3 月 8 日

syn-nodejs-puppeteer-4.0

2024 年 3 月 8 日

syn-nodejs-puppeteer-3.9

2024 年 1 月 8 日

syn-nodejs-puppeteer-3.8

2024 年 1 月 8 日

syn-python-selenium-2.0

2024 年 3 月 8 日

syn-python-selenium-1.3

2024 年 3 月 8 日

syn-python-selenium-1.2

2024 年 3 月 8 日

syn-python-selenium-1.1

2024 年 3 月 8 日

syn-python-selenium-1.0

2024 年 3 月 8 日

syn-nodejs-puppeteer-3.7

2024 年 1 月 8 日

syn-nodejs-puppeteer-3.6

2024 年 1 月 8 日

syn-nodejs-puppeteer-3.5

2024 年 1 月 8 日

syn-nodejs-puppeteer-3.4

2022 年 11 月 13 日

syn-nodejs-puppeteer-3.3

2022 年 11 月 13 日

syn-nodejs-puppeteer-3.2

2022 年 11 月 13 日

syn-nodejs-puppeteer-3.1

2022 年 11 月 13 日

syn-nodejs-puppeteer-3.0

2022 年 11 月 13 日

syn-nodejs-2.2

2021 年 5 月 28 日

syn-nodejs-2.1

2021 年 5 月 28 日

syn-nodejs-2.0

2021 年 5 月 28 日

syn-nodejs-2.0-beta

2021 年 2 月 8 日

syn-1.0

2021 年 5 月 28 日

Canary ランタイムアップグレード用スクリプト

Canary スクリプトを、サポートされているランタイムバージョンにアップグレードするには、次のスクリプトを使用します。

const AWS = require('aws-sdk'); // You need to configure your AWS credentials and Region. // https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html // https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-region.html const synthetics = new AWS.Synthetics(); const DEFAULT_OPTIONS = { /** * The number of canaries to upgrade during a single run of this script. */ count: 10, /** * No canaries are upgraded unless force is specified. */ force: false }; /** * The number of milliseconds to sleep between GetCanary calls when * verifying that an update succeeded. */ const SLEEP_TIME = 5000; (async () => { try { const options = getOptions(); const versions = await getRuntimeVersions(); const canaries = await getAllCanaries(); const upgrades = canaries .filter(canary => !versions.isLatestVersion(canary.RuntimeVersion)) .map(canary => { return { Name: canary.Name, FromVersion: canary.RuntimeVersion, ToVersion: versions.getLatestVersion(canary.RuntimeVersion) }; }); if (options.force) { const promises = []; for (const upgrade of upgrades.slice(0, options.count)) { const promise = upgradeCanary(upgrade); promises.push(promise); // Sleep for 100 milliseconds to avoid throttling. await usleep(100); } const succeeded = []; const failed = []; for (let i = 0; i < upgrades.slice(0, options.count).length; i++) { const upgrade = upgrades[i]; const promise = promises[i]; try { await promise; console.log(`The update of ${upgrade.Name} succeeded.`); succeeded.push(upgrade.Name); } catch (e) { console.log(`The update of ${upgrade.Name} failed with error: ${e}`); failed.push({ Name: upgrade.Name, Reason: e }); } } if (succeeded.length) { console.group('The following canaries were upgraded successfully.'); for (const name of succeeded) { console.log(name); } console.groupEnd() } else { console.log('No canaries were upgraded successfully.'); } if (failed.length) { console.group('The following canaries were not upgraded successfully.'); for (const failure of failed) { console.log('\x1b[31m', `${failure.Name}: ${failure.Reason}`, '\x1b[0m'); } console.groupEnd(); } } else { console.log('Run with --force [--count <count>] to perform the first <count> upgrades shown. The default value of <count> is 10.') console.table(upgrades); } } catch (e) { console.error(e); } })(); function getOptions() { const force = getFlag('--force', DEFAULT_OPTIONS.force); const count = getOption('--count', DEFAULT_OPTIONS.count); return { force, count }; function getFlag(key, defaultValue) { return process.argv.includes(key) || defaultValue; } function getOption(key, defaultValue) { const index = process.argv.indexOf(key); if (index < 0) { return defaultValue; } const value = process.argv[index + 1]; if (typeof value === 'undefined' || value.startsWith('-')) { throw `The ${key} option requires a value.`; } return value; } } function getAllCanaries() { return new Promise((resolve, reject) => { const canaries = []; synthetics.describeCanaries().eachPage((err, data) => { if (err) { reject(err); } else { if (data === null) { resolve(canaries); } else { canaries.push(...data.Canaries); } } }); }); } function getRuntimeVersions() { return new Promise((resolve, reject) => { const jsVersions = []; const pythonVersions = []; synthetics.describeRuntimeVersions().eachPage((err, data) => { if (err) { reject(err); } else { if (data === null) { jsVersions.sort((a, b) => a.ReleaseDate - b.ReleaseDate); pythonVersions.sort((a, b) => a.ReleaseDate - b.ReleaseDate); resolve({ isLatestVersion(version) { const latest = this.getLatestVersion(version); return latest === version; }, getLatestVersion(version) { if (jsVersions.some(v => v.VersionName === version)) { return jsVersions[jsVersions.length - 1].VersionName; } else if (pythonVersions.some(v => v.VersionName === version)) { return pythonVersions[pythonVersions.length - 1].VersionName; } else { throw Error(`Unknown version ${version}`); } } }); } else { for (const version of data.RuntimeVersions) { if (version.VersionName === 'syn-1.0') { jsVersions.push(version); } else if (version.VersionName.startsWith('syn-nodejs-2.')) { jsVersions.push(version); } else if (version.VersionName.startsWith('syn-nodejs-puppeteer-')) { jsVersions.push(version); } else if (version.VersionName.startsWith('syn-python-selenium-')) { pythonVersions.push(version); } else { throw Error(`Unknown version ${version.VersionName}`); } } } } }); }); } async function upgradeCanary(upgrade) { console.log(`Upgrading canary ${upgrade.Name} from ${upgrade.FromVersion} to ${upgrade.ToVersion}`); await synthetics.updateCanary({ Name: upgrade.Name, RuntimeVersion: upgrade.ToVersion }).promise(); while (true) { await usleep(SLEEP_TIME); console.log(`Getting the state of canary ${upgrade.Name}`); const response = await synthetics.getCanary({ Name: upgrade.Name }).promise(); const state = response.Canary.Status.State; console.log(`The state of canary ${upgrade.Name} is ${state}`); if (state === 'ERROR' || response.Canary.Status.StateReason) { throw response.Canary.Status.StateReason; } if (state !== 'UPDATING') { return; } } } function usleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }