AWS ses: Update Lambda example to AWS SDK for JavaScript v3
Summary
Migrated the sample Lambda function from aws-sdk v2 to @aws-sdk/client-ses v3, updated runtime guidance, parameter naming, and error handling to rethrow errors.
Security assessment
The change modernizes the example code (SDK v3, error rethrow) for pausing sending on a configuration set. It is a code-quality/maintenance update with no vulnerability or security control being addressed.
Evidence
+ throw err;
Diff
diff --git a/ses/latest/dg/monitoring-sender-reputation-pausing-configuration-set.md b/ses/latest/dg/monitoring-sender-reputation-pausing-configuration-set.md index 7d377cd..e879a0a 100644 --- a//ses/latest/dg/monitoring-sender-reputation-pausing-configuration-set.md +++ b//ses/latest/dg/monitoring-sender-reputation-pausing-configuration-set.md @@ -97 +97 @@ This function only pauses email sending for configuration sets in the AWS Region - * For **Runtime** , choose **Node.js 14x** (or the version currently offered in the select list). + * For **Runtime** , select the latest **Node.js** version offered in the select list. The code uses the AWS SDK for JavaScript v3, which all supported Node.js runtimes include. @@ -105 +105 @@ Choose **Create function**. - 6. Under **Function code** , in the code editor, paste the following code: + 6. Under **Function code** , in the code editor, paste the following code, and replace ``my-configuration-set`` with the name of the configuration set: @@ -110 +110,2 @@ Choose **Create function**. - SES + SESClient, + UpdateConfigurationSetSendingEnabledCommand @@ -112 +113 @@ Choose **Create function**. - from 'aws-sdk'; + from '@aws-sdk/client-ses'; @@ -114,2 +115,2 @@ Choose **Create function**. - const ses = new SES(); - const configSet = 'CONFIG_SET_NAME_HERE'; + const ses = new SESClient(); + const configSet = 'my-configuration-set'; @@ -124 +125 @@ Choose **Create function**. - const data = await ses.updateConfigurationSetSendingEnabled(params).promise(); + const data = await ses.send(new UpdateConfigurationSetSendingEnabledCommand(params)); @@ -137,8 +138,3 @@ Choose **Create function**. - console.error('Error:', err.message); - return { - statusCode: 500, - body: JSON.stringify({ - message: 'Failed to pause email sending for configuration set.', - error: err.message - }), - }; + // Rethrow so that the invocation fails and the error is visible. + console.error('Failed to pause email sending for configuration set:', err.message); + throw err; @@ -148 +144 @@ Choose **Create function**. -Replace `ConfigSet` in the preceding code with the name of the configuration set. Choose **Save**. +Choose **Deploy**.