diff --git a/.changeset/curvy-things-call.md b/.changeset/curvy-things-call.md new file mode 100644 index 0000000000..1f4d8774c7 --- /dev/null +++ b/.changeset/curvy-things-call.md @@ -0,0 +1,22 @@ +--- +'@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. + +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`: + +```diff +notifications: + processors: + email: + transportConfig: + transport: "ses" + region: "us-west-2" + sender: "sender@mycompany.com" + 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" +``` diff --git a/plugins/notifications-backend-module-email/config.d.ts b/plugins/notifications-backend-module-email/config.d.ts index f73ef1074b..350fb569c5 100644 --- a/plugins/notifications-backend-module-email/config.d.ts +++ b/plugins/notifications-backend-module-email/config.d.ts @@ -136,6 +136,11 @@ export interface Config { * Optional SES config for mail options. Allows for delegated sender */ 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 */ 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 4ebc5d40a8..a52b54401e 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.test.ts @@ -500,4 +500,62 @@ describe('NotificationsEmailProcessor', () => { }, }); }); + + 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', + }, + }, + }, + }, + }; + (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', + }, + }); + }); }); diff --git a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts index bec19e77e8..acf1fbdb4c 100644 --- a/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts +++ b/plugins/notifications-backend-module-email/src/processor/NotificationsEmailProcessor.ts @@ -318,12 +318,15 @@ export class NotificationsEmailProcessor implements NotificationProcessor { const fromEmailAddressIdentityArn = this.sesConfig.getOptionalString( 'fromEmailAddressIdentityArn', ); + const fromArn = this.sesConfig.getOptionalString('fromArn'); const configurationSetName = this.sesConfig.getOptionalString( 'configurationSetName', ); if (fromEmailAddressIdentityArn) ses.FromEmailAddressIdentityArn = fromEmailAddressIdentityArn; + else if (fromArn) ses.FromEmailAddressIdentityArn = fromArn; + if (configurationSetName) ses.ConfigurationSetName = configurationSetName; return Object.keys(ses).length > 0 ? ses : undefined;