fix: mark fromArn as deprecated, update getSesOptions to read fromArn if set
Signed-off-by: Colt McKissick <colt.mckissick.ycbp@statefarm.com>
This commit is contained in:
@@ -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"
|
||||
```
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+58
@@ -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: '<p><a href="https://example.org/notifications">https://example.org/notifications</a></p>',
|
||||
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',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user