-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(messaging): use SES tenants #39129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+57
−2
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9e26d75
tweak
havenbarnes cfa4607
tweak
havenbarnes 316609d
Merge branch 'master' into feat/messaging-ses-multi-tenant
havenbarnes 79807c6
Merge branch 'master' of https://github.com/PostHog/posthog into feat…
havenbarnes 5a6a621
tweak
havenbarnes e7c3d07
Merge branch 'feat/messaging-ses-multi-tenant' of https://github.com/…
havenbarnes ac7b1be
Merge branch 'master' into feat/messaging-ses-multi-tenant
havenbarnes c968eac
fix test
havenbarnes c3b38b4
Merge branch 'feat/messaging-ses-multi-tenant' of https://github.com/…
havenbarnes f54482f
Merge branch 'master' into feat/messaging-ses-multi-tenant
havenbarnes 853c191
Merge branch 'master' of https://github.com/PostHog/posthog into feat…
havenbarnes c4014fe
tweak
havenbarnes 28bf9ef
Merge branch 'feat/messaging-ses-multi-tenant' of https://github.com/…
havenbarnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -22,9 +22,23 @@ | |
| ) | ||
|
|
||
| def create_email_domain(self, domain: str, team_id: int): | ||
| # NOTE: For sesv1 creation is done through verification | ||
| # NOTE: For sesv1, domain Identity creation is done through verification | ||
| self.verify_email_domain(domain, team_id) | ||
|
|
||
| # Create a tenant for the domain if not exists | ||
| try: | ||
| tenant_name = f"team-{team_id}" | ||
| self.client.create_tenant(TenantName=tenant_name, Tags=[{"Key": "team_id", "Value": str(team_id)}]) | ||
| except ClientError as e: | ||
| if e.response["Error"]["Code"] != "AlreadyExistsException": | ||
| raise | ||
|
|
||
| # Associate the new domain identity with the tenant | ||
| self.client.create_tenant_resource_association( | ||
| TenantName=tenant_name, | ||
| ResourceArn=f"arn:aws:ses:{settings.SES_REGION}:{settings.SES_ACCOUNT_ID}:identity/{domain}", | ||
| ) | ||
|
||
|
|
||
| def verify_email_domain(self, domain: str, team_id: int): | ||
| # Validate the domain contains valid characters for a domain name | ||
| DOMAIN_REGEX = r"(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$" | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: AWS tenant names have specific constraints (3-64 characters, alphanumeric and hyphens). Consider validating the generated tenant name meets these requirements
Prompt To Fix With AI