diff --git a/.tools/validation/validator_config.py b/.tools/validation/validator_config.py index 223abcb2b19..856e058fb08 100644 --- a/.tools/validation/validator_config.py +++ b/.tools/validation/validator_config.py @@ -204,8 +204,6 @@ def skip(path): "chat_sfn_state_machine.json", "market_2.jpg", "movies.json", - "sample_cert.pem", - "sample_private_key.pem", "sample_saml_metadata.xml", "speech_sample.mp3", "spheres_2.jpg", diff --git a/javascriptv3/example_code/cross-services/wkflw-resilient-service/tests/wkflw.integration.test.js b/javascriptv3/example_code/cross-services/wkflw-resilient-service/tests/wkflw.integration.test.js index 22794fe7c67..fe7fe1498f6 100644 --- a/javascriptv3/example_code/cross-services/wkflw-resilient-service/tests/wkflw.integration.test.js +++ b/javascriptv3/example_code/cross-services/wkflw-resilient-service/tests/wkflw.integration.test.js @@ -4,8 +4,13 @@ import { scenarios } from "../index.js"; describe("workflow", () => { it("should run without error", async () => { - await scenarios.deploy.run({ confirmAll: true, verbose: true }); - await scenarios.demo.run({ confirmAll: true, verbose: true }); - await scenarios.destroy.run({ confirmAll: true, verbose: true }); + try { + await scenarios.deploy.run({ confirmAll: true, verbose: true }); + await scenarios.demo.run({ confirmAll: true, verbose: true }); + await scenarios.destroy.run({ confirmAll: true, verbose: true }); + } catch (err) { + await scenarios.destroy.run({ confirmAll: true, verbose: true }); + throw err; + } }); }); diff --git a/javascriptv3/example_code/iam/actions/upload-server-certificate.js b/javascriptv3/example_code/iam/actions/upload-server-certificate.js index 875f09db0e4..ab1ca9b17a2 100644 --- a/javascriptv3/example_code/iam/actions/upload-server-certificate.js +++ b/javascriptv3/example_code/iam/actions/upload-server-certificate.js @@ -13,40 +13,43 @@ 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", - ), -); +const certMessage = `Generate a certificate and key with the following command, or the equivalent for your system. + +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 getCertAndKey = () => { + try { + const cert = readFileSync( + path.join(dirnameFromMetaUrl(import.meta.url), "./example.crt") + ); + const key = readFileSync( + path.join(dirnameFromMetaUrl(import.meta.url), "./example.key") + ); + return { cert, key }; + } catch (err) { + if (err.code === "ENOENT") { + throw new Error( + `Certificate and/or private key not found. ${certMessage}` + ); + } + + throw err; + } +}; /** * * @param {string} certificateName */ export const uploadServerCertificate = (certificateName) => { + const { cert, key } = getCertAndKey(); const command = new UploadServerCertificateCommand({ ServerCertificateName: certificateName, - CertificateBody: certBody.toString(), - PrivateKey: privateKey.toString(), + CertificateBody: cert.toString(), + PrivateKey: key.toString(), }); return client.send(command); diff --git a/javascriptv3/example_code/iam/tests/server-certificate.integration.test.js b/javascriptv3/example_code/iam/tests/server-certificate.integration.test.js deleted file mode 100644 index f24366e37b9..00000000000 --- a/javascriptv3/example_code/iam/tests/server-certificate.integration.test.js +++ /dev/null @@ -1,50 +0,0 @@ -import { describe, it, expect } from "vitest"; - -import { getUniqueName } from "@aws-sdk-examples/libs/utils/util-string.js"; - -import { listServerCertificates } from "../actions/list-server-certificates.js"; -import { uploadServerCertificate } from "../actions/upload-server-certificate.js"; -import { updateServerCertificate } from "../actions/update-server-certificate.js"; -import { deleteServerCertificate } from "../actions/delete-server-certificate.js"; -import { getServerCertificate } from "../actions/get-server-certificate.js"; - -describe("Server certificates", () => { - it("should create, read, update, and delete server certificates", async () => { - // Create a server certificate. - const certName = getUniqueName("test-cert"); - await uploadServerCertificate(certName); - - // List server certificates. - let serverCertificate = await findServerCertificate(certName); - expect(serverCertificate).toBeDefined(); - - const { ServerCertificate } = await getServerCertificate(certName); - expect( - ServerCertificate?.ServerCertificateMetadata?.ServerCertificateName, - ).toEqual(certName); - - // Update the server certificate. - const newCertName = getUniqueName("test-cert"); - await updateServerCertificate(certName, newCertName); - serverCertificate = await findServerCertificate(newCertName); - expect(serverCertificate).toBeDefined(); - - // Delete the server certificate. - await deleteServerCertificate(newCertName); - - serverCertificate = await findServerCertificate(certName); - expect(serverCertificate).toBeUndefined(); - }); -}); - -/** - * - * @param {string} name - */ -const findServerCertificate = async (name) => { - for await (const serverCertificate of listServerCertificates()) { - if (serverCertificate.ServerCertificateName === name) { - return serverCertificate; - } - } -}; diff --git a/resources/sample_files/README.md b/resources/sample_files/README.md index 4ad041fcdc0..24ebeb95aab 100644 --- a/resources/sample_files/README.md +++ b/resources/sample_files/README.md @@ -5,7 +5,5 @@ These files are included as shared sample data files for use in examples in this * [speech_sample.mp3](.sample_media/speech_sample.mp3) `A sample audio file of speech used for Amazon Transcribe examples.` * [spheres_2.jpg](.sample_media/spheres_2.jpg) `A sample image of the Amazon Spheres in Seattle.` * [market_2.jpg](.sample_media/market_2.jpg) `A sample image of the public market in Seattle.` -* [sample_cert.pem](./sample_cert.pem) `A sample certificate PEM file.` -* [sample_private_key.pem](./sample_private_key.pem) `A sample private key PEM file.` * [sample_saml_metadata.xml](./sample_saml_metadata.xml) `A sample SAML metadata file for creating a SAML provider.` diff --git a/resources/sample_files/sample_cert.pem b/resources/sample_files/sample_cert.pem deleted file mode 100644 index 083973eef71..00000000000 --- a/resources/sample_files/sample_cert.pem +++ /dev/null @@ -1,34 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIF6jCCA9ICCQCzB1kmGQZV5zANBgkqhkiG9w0BAQsFADCBtjELMAkGA1UEBhMC -dXMxEDAOBgNVBAgMB0Zsb3JpZGExEDAOBgNVBAcMB0FsYWNodWExHDAaBgNVBAo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Fsl7NtPTXku5ByudaJVaZwYWLlY5bdfGTkP3BXWNj -cUmpYph4MiE4nd3pqU8whI46WkzNJlayrQmsDrTQ6Wkekeya5IGR04hJgLejgCwg -np25C7dpvSQQVNelP5nhYJqaFW89AgMBAAEwDQYJKoZIhvcNAQELBQADggIBAEqW -6KAYuhwF1tyR8U3pkTly3GGK5GfGknaPdLxSZN7z5wlTgoYaTA4x1YxKf4UNTqu0 -9Vz5HiFFW7n1mNjvnTf0Vnyr9P0sBRmb9HgzQ5KWnJ9t4QECjKZeYxby2PGbGdC4 -jF0y6rZBGzMGSSy/oyWRBuUXKjV6X38CpAwFdK/vUMyhZE6mSKDEzxjyUKopLK5C -gXMBz713T6oMGszqIyyxZYriZSsaM8oD4SgevE0Yb4dQCtGOqLub2UQqmRdG3UkD -+7CRwTEX8tk4qSVi8jDWtLEgvDLh32r9f9pRoggEO9ErH+9Ov5qIyzNiRUb7Eb/g -bXGpkn6kLImERpaEqufruvk7Tg1uw7MoRu7Vt1j+xitkx0J1BB8WEXF2REiA5XUv -Gj2O1hVAN9fhKE9hWcigIGEu6UoXfddnxvlkd7LcUHHkKyII/Pq/SIKsiX1sTz8K -z7TvJtq9TuEvnrle52VaOopdwX2wt+OL65axkcK7MY292Cw8tifhikj1997f+QWP -aJ5O9X6LoULNVJqP3qTdg/uEFrDRhPzsjgxHhWRWwOtxF92UwH+IkUvkBDKiOERJ -WqW7yFJksxhPcQ27YTV0K++78ey7m2I9PzGQXTzAJ3wPdzJdhs8q8hrhSqKRoDkp -RbMUywFbXJlB0Jq4Ah3QZk70wPk+hTZB/KCh4tkR ------END CERTIFICATE----- diff --git a/resources/sample_files/sample_private_key.pem b/resources/sample_files/sample_private_key.pem deleted file mode 100644 index e3cb94f8f4a..00000000000 --- a/resources/sample_files/sample_private_key.pem +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQDES4iCN8AY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