AWSDocAWS SDKGitHub サンプルリポジトリには、さらに多くの SDK サンプルがあります
翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
AWS SDK を使用して IAM サーバー証明書をアップロードする
次のコード例は、AWS Identity and Access Management (IAM) サーバー証明書をアップロードする方法を示しています。
- JavaScript
-
- SDK forJavaScript (v3)
-
注記
他にもありますGitHub。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 import { UploadServerCertificateCommand, IAMClient } from "@aws-sdk/client-iam"; import { readFileSync } from "fs"; import { dirnameFromMetaUrl } from "libs/utils/util-fs.js"; import * as path from "path"; const client = new IAMClient({}); /** * The certificate body and private key were generated with the * following command. * * ``` * openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ * -keyout example.key -out example.crt -subj "/CN=example.com" \ * -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1" * ``` */ const certBody = readFileSync( path.join( dirnameFromMetaUrl(import.meta.url), "../../../../resources/sample_files/sample_cert.pem" ) ); const privateKey = readFileSync( path.join( dirnameFromMetaUrl(import.meta.url), "../../../../resources/sample_files/sample_private_key.pem" ) ); /** * * @param {string} certificateName */ export const uploadServerCertificate = (certificateName) => { const command = new UploadServerCertificateCommand({ ServerCertificateName: certificateName, CertificateBody: certBody.toString(), PrivateKey: privateKey.toString(), }); return client.send(command); };
-
API の詳細については、AWS SDK for JavaScriptAPI UploadServerCertificateリファレンスのを参照してください。
-
アクセスキーの更新
シナリオ