Skip to content
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

feat(ses): add fromEmailIdentityArn #33984

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

hassaku63
Copy link
Contributor

Issue # (if applicable)

Closes #33981

Reason for this change

The SES module currently lacks a method to import an EmailIdentity by its ARN, which is inconsistent with many other CDK resource libraries. Supporting this would allow users to follow a consistent pattern when managing resources across CDK stacks.

Description of changes

  • Added a new static method EmailIdentity.fromEmailIdentityArn(scope, id, emailIdentityArn) to enable importing an EmailIdentity by ARN.

Describe any new or updated permissions being added

No new IAM permissions are required, as this change does not perform any operations requiring permissions. It only allows referencing an existing SES Email Identity by ARN.

Description of how you validated changes

  • Added unit tests in email-identity.test.ts to verify that the ARN is correctly parsed and the resulting IEmailIdentity behaves as expected.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2 labels Mar 31, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 31, 2025 17:49
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

Copy link

codecov bot commented Mar 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (74cbe27) to head (e2d4d64).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33984   +/-   ##
=======================================
  Coverage   83.98%   83.98%           
=======================================
  Files         120      120           
  Lines        6976     6976           
  Branches     1178     1178           
=======================================
  Hits         5859     5859           
  Misses       1005     1005           
  Partials      112      112           
Flag Coverage Δ
suite.unit 83.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 83.98% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hassaku63
Copy link
Contributor Author

Exemption Request

I would like to request an exemption from the requirements to update the README and integration test files, based on the following reasons:

  • The existing method fromEmailIdentityName, which provides similar functionality (i.e., importing an identity by name), does not have a corresponding section in the README.
  • There is also no integration test or snapshot that covers fromEmailIdentityName.

Since this feature follows the same usage pattern and abstraction level as fromEmailIdentityName, I believe it's reasonable to apply the same documentation and testing scope.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Mar 31, 2025
Copy link
Contributor

@QuantumNeuralCoder QuantumNeuralCoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add an integ test and a readme please?

@QuantumNeuralCoder
Copy link
Contributor

Please let me know if you need help with writing the test. There are few samples that can be referred from within the repo.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Apr 1, 2025
@hassaku63
Copy link
Contributor Author

@QuantumNeuralCoder Thanks for the feedback.

Regarding the integration test, I will work on adding one. Since the newly added method does not create or modify any actual AWS resources—it's a static method for importing an existing resource by ARN—I initially considered its behavior sufficiently covered by unit tests. However, I understand the value of having integ test coverage for completeness and consistency, and I’ll follow up with an appropriate test case.

As for the README, I’d appreciate a bit more detail on what kind of addition you’d like to see. The fromEmailIdentityArn method follows a common static import pattern used across many L2 constructs, and based on a quick review of similar modules, this type of method is often not explicitly documented unless it’s part of a usage example. Would it make sense to update an existing example in the README to use fromEmailIdentityArn instead of constructing a new resource? I’d be happy to revise the documentation accordingly once I better understand the intended scope.

@hassaku63 hassaku63 force-pushed the feat/from-arn-support-for-ses-email-identity branch from ba1ccb6 to 39fce40 Compare April 3, 2025 16:06
});

test('import email identity by ARN fails with invalid ARN', () => {
expect(() => EmailIdentity.fromEmailIdentityArn(stack, 'Identity', 'arn:aws:s3:us-west-2:123456789012:bucket/cdk.dev')).toThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the expected error message here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review, yes I have added explicitly assert thrown error.

shikha372
shikha372 previously approved these changes Apr 8, 2025
Copy link
Contributor

@shikha372 shikha372 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hassaku63 for submitting the change, can we add a section to Readme for this, would be helpful for the users.

@shikha372 shikha372 added the pr/do-not-merge This PR should not be merged at this time. label Apr 8, 2025
@shikha372 shikha372 dismissed their stale review April 8, 2025 23:32

clicked by mistake

@shikha372 shikha372 self-assigned this Apr 9, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b34af8c
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation dismissed their stale review April 12, 2025 13:28

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK feature-request A feature should be added or improved. p2 pr/do-not-merge This PR should not be merged at this time. pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-ses): Allow importing EmailIdentity by arn
4 participants