diff --git a/.changeset/curvy-things-call.md b/.changeset/curvy-things-call.md index 1f4d8774c7..d64f1a14fa 100644 --- a/.changeset/curvy-things-call.md +++ b/.changeset/curvy-things-call.md @@ -2,9 +2,9 @@ '@backstage/plugin-notifications-backend-module-email': patch --- -SES config for the notification email processor now supports sending an ARN for the SES identity to use when sending an email after the SES SDK V2 update. +SES config for the notification email processor now supports utilizing an ARN for the SES identity when sending an email after the SES SDK V2 update. -The `sesConfig.fromArn` field is marked as deprecated in favor of `sesConfig.fromEmailAddressIdentityArn` to match the option name passed during the send email command. Currently both `sesConfig.fromArn` and `sesConfig.fromEmailAddressIdentityArn` will set the `fromEmailAddressIdentityArn` option. The `sesConfig.sourceArn` field is removed since no equivalent option is available in the send email command options. Example using `sesConfig.fromEmailAddressIdentityArn`: +The `sesConfig.fromArn` will set the `fromEmailAddressIdentityArn` option for the SES `SendEmailCommand`. The `sesConfig.sourceArn` field is removed since no equivalent option is available in the send email command options. Setting `sesConfig.sourceArn` will have no effect and log a warning. Example changes: ```diff notifications: @@ -17,6 +17,5 @@ notifications: replyTo: "no-reply@mycompany.com" sesConfig: - sourceArn: "arn:aws:ses:us-west-2:123456789012:identity/example.com" -- fromArn: "arn:aws:ses:us-west-2:123456789012:identity/example.com" -+ fromEmailAddressIdentityArn: "arn:aws:ses:us-west-2:123456789012:identity/example.com" + fromArn: "arn:aws:ses:us-west-2:123456789012:identity/example.com" ``` diff --git a/plugins/notifications-backend-module-email/README.md b/plugins/notifications-backend-module-email/README.md index d56d277544..248bb2c501 100644 --- a/plugins/notifications-backend-module-email/README.md +++ b/plugins/notifications-backend-module-email/README.md @@ -81,7 +81,7 @@ notifications: receiver: 'users' # Optional SES config # sesConfig: - # fromEmailAddressIdentityArn: 'arn:aws:ses:us-west-2:123456789012:identity/example.com' + # fromArn: 'arn:aws:ses:us-west-2:123456789012:identity/example.com' # configurationSetName: 'custom-config' # How many emails to send concurrently, defaults to 2 concurrencyLimit: 10 diff --git a/plugins/notifications-backend-module-email/config.d.ts b/plugins/notifications-backend-module-email/config.d.ts index 350fb569c5..55a751f8fa 100644 --- a/plugins/notifications-backend-module-email/config.d.ts +++ b/plugins/notifications-backend-module-email/config.d.ts @@ -138,13 +138,8 @@ export interface Config { sesConfig?: { /** * ARN of the identity to use for the "From"/sender address of the email - * @deprecated Use fromEmailAddressIdentityArn instead */ fromArn?: string; - /** - * ARN of the identity to use for the "From"/sender address of the email - */ - fromEmailAddressIdentityArn?: string; /** * Name of the configuration set to use when sending email via ses */ diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts index a52b54401e..ad0817521f 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts @@ -458,64 +458,8 @@ describe('NotificationsEmailProcessor', () => { sender: 'backstage@backstage.io', replyTo: 'no-reply@backstage.io', sesConfig: { - fromEmailAddressIdentityArn: + sourceArn: 'arn:aws:ses:us-west-2:123456789012:identity/example.com', - }, - }, - }, - }, - }; - (createTransport as jest.Mock).mockReturnValue(mockTransport); - const processor = new NotificationsEmailProcessor( - logger, - mockServices.rootConfig({ data: SES_SENDMAIL_CONFIG }), - catalogServiceMock({ entities: [DEFAULT_ENTITIES_RESPONSE.items[0]] }), - auth, - ); - - await processor.postProcess( - { - origin: 'plugin', - id: '1234', - user: 'user:default/mock', - created: new Date(), - payload: { title: 'notification' }, - }, - { - recipients: { type: 'entity', entityRef: 'user:default/mock' }, - payload: { title: 'notification' }, - }, - ); - - expect(sendmailMock).toHaveBeenCalledWith({ - from: 'backstage@backstage.io', - html: '

https://example.org/notifications

', - replyTo: 'no-reply@backstage.io', - subject: 'notification', - text: 'https://example.org/notifications', - to: 'mock@backstage.io', - ses: { - FromEmailAddressIdentityArn: - 'arn:aws:ses:us-west-2:123456789012:identity/example.com', - }, - }); - }); - - it('should send email with deprecated ses config', async () => { - const SES_SENDMAIL_CONFIG = { - app: { - baseUrl: 'https://example.org', - }, - notifications: { - processors: { - email: { - transportConfig: { - transport: 'ses', - region: 'us-west-2', - }, - sender: 'backstage@backstage.io', - replyTo: 'no-reply@backstage.io', - sesConfig: { fromArn: 'arn:aws:ses:us-west-2:123456789012:identity/example.com', }, @@ -557,5 +501,9 @@ describe('NotificationsEmailProcessor', () => { 'arn:aws:ses:us-west-2:123456789012:identity/example.com', }, }); + + expect(logger.warn).toHaveBeenCalledWith( + 'sourceArn is not supported in SESv2 and will be ignored', + ); }); }); diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts index acf1fbdb4c..7eea12bd85 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts @@ -315,19 +315,18 @@ export class NotificationsEmailProcessor implements NotificationProcessor { return undefined; } const ses: Partial = {}; - const fromEmailAddressIdentityArn = this.sesConfig.getOptionalString( - 'fromEmailAddressIdentityArn', - ); const fromArn = this.sesConfig.getOptionalString('fromArn'); + const sourceArn = this.sesConfig.getOptionalString('sourceArn'); const configurationSetName = this.sesConfig.getOptionalString( 'configurationSetName', ); - if (fromEmailAddressIdentityArn) - ses.FromEmailAddressIdentityArn = fromEmailAddressIdentityArn; - else if (fromArn) ses.FromEmailAddressIdentityArn = fromArn; - + if (fromArn) ses.FromEmailAddressIdentityArn = fromArn; if (configurationSetName) ses.ConfigurationSetName = configurationSetName; + if (sourceArn) + this.logger.warn( + 'sourceArn is not supported in SESv2 and will be ignored', + ); return Object.keys(ses).length > 0 ? ses : undefined; }