-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Issue Closes #29083 ### Reason for this change When granting send email access to a lambda the grant needs to be constructed manually, including constructing the ARN for the identity. e.g. ``` Grant.addToPrincipal({ grantee, actions: ["ses:SendEmail"], resourceArns: [ this.stack.formatArn({ service: 'ses', resource: 'identity', resourceName: 'test@example.com', }), ], scope: this }) ``` This is dissimilar to other constructs, which generally expose a grant method and one or more convenience methods for particularly relevant groups of actions. ### Description of changes Added `grant` and `grantSendEmail` to `IEmailIdentity`, and added a common abstract class, `BaseEmailIdentity` with the relevant grant code. This is to avoid code duplication between the full `EmailIdentity` and the `Import` class. ### Description of how you validated changes Tests added for grants on both new and imported email identities, and a test to validate the `grantSendEmail` method. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
13 changed files
with
749 additions
and
88 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/@aws-cdk-testing/framework-integ/test/aws-ses/test/fixtures/send-email/index.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import json | ||
import boto3 | ||
|
||
client = boto3.client('ses', region_name='us-west-2') | ||
|
||
def lambda_handler(event, context): | ||
response = client.send_email( | ||
Destination={ | ||
'ToAddresses': ['test@example.com'] | ||
}, | ||
Message={ | ||
'Body': { | ||
'Text': { | ||
'Charset': 'UTF-8', | ||
'Data': 'This is the message body in text format.', | ||
} | ||
}, | ||
'Subject': { | ||
'Charset': 'UTF-8', | ||
'Data': 'Test email', | ||
}, | ||
}, | ||
Source='sender@cdk.dev' | ||
) | ||
|
||
print(response) | ||
|
||
return { | ||
'statusCode': 200, | ||
'body': json.dumps("Email Sent Successfully. MessageId is: " + response['MessageId']) | ||
} |
2 changes: 1 addition & 1 deletion
2
....email-identity.js.snapshot/EmailIdentityIntegDefaultTestDeployAssert3F909307.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
....snapshot/asset.ab3156800c2f322f16da8bff913172139189a387dd64a4e622f82a790561fd4d/index.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 16 additions & 3 deletions
19
...st/aws-ses/test/integ.email-identity.js.snapshot/cdk-ses-email-identity-integ.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ws-cdk-testing/framework-integ/test/aws-ses/test/integ.email-identity.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
...cdk-testing/framework-integ/test/aws-ses/test/integ.email-identity.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.