fix: use fromArn config, log warning for sourceArn
Signed-off-by: Colt McKissick <colt.mckissick.ycbp@statefarm.com>
This commit is contained in:
@@ -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"
|
||||
```
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
+5
-57
@@ -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: '<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',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
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',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+6
-7
@@ -315,19 +315,18 @@ export class NotificationsEmailProcessor implements NotificationProcessor {
|
||||
return undefined;
|
||||
}
|
||||
const ses: Partial<SendEmailCommandInput> = {};
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user