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(sns): support multiple tokens as url and email subscriptions #6357

Merged
merged 11 commits into from
Feb 24, 2020

Conversation

strazeadin
Copy link
Contributor

@strazeadin strazeadin commented Feb 19, 2020

Commit Message

feat(sns): support multiple tokens as url and email subscriptions (#6357)

fixes #3996 to allow using tokens in email subscriptions, additionally
fixes a bug with URL subscriptions when using more than one token
subscription.

The Issue
Email Subscriptions currently use the value passed in as the construct
ID, when the value passed in is a token (For example a parameter) it
causes an error as tokens aren't supported as construct IDs. A previous
fix was done for URL Subscriptions but it also errors when more than
one URL subscription with a token is used.

The fix
In the topic base, identify if the subscription ID is a token and
override it to a valid construct ID. The method of ensuring a valid ID
is to convert it to a special prefix suffixed by a number and doing an
increment of the number for each new topic created with a token.
Subscriptions not utilizing a token are not effected.


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

fixes aws#3996 to allow using tokens in email subscriptions, additionally
fixes a bug with URL subscriptions when using more then one token
subscription.
@mergify
Copy link
Contributor

mergify bot commented Feb 19, 2020

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@strazeadin strazeadin changed the title fix(aws-sns-subscriptions) - support for tokens in EmailSubscription fix(aws-sns-subscriptions) - support for tokens in emailsubscription Feb 19, 2020
@strazeadin strazeadin changed the title fix(aws-sns-subscriptions) - support for tokens in emailsubscription fix: support for tokens in emailsubscription Feb 19, 2020
@strazeadin strazeadin changed the title fix: support for tokens in emailsubscription fix(aws-sns-subscriptions): support for tokens in emailsubscription Feb 19, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 2c3eb69
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: d4f7004
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@nija-at nija-at self-assigned this Feb 20, 2020
@nija-at nija-at changed the title fix(aws-sns-subscriptions): support for tokens in emailsubscription feat(sns): support multiple tokens as url and email subscriptions Feb 20, 2020
Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Thanks for getting this through. Looks mostly ok to me; a few things below.

Given the non-trivial nature of this change, I would expect the commit message to be more detailed. Start with a short paragraph on what the problem that this change is fixing followed by what the change is doing, i.e., storing tokens as construct nodes with a special prefix and counting them.

packages/@aws-cdk/aws-sns/lib/topic-base.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-sns-subscriptions/test/subs.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-sns/lib/topic-base.ts Outdated Show resolved Hide resolved
@mergify mergify bot dismissed nija-at’s stale review February 20, 2020 23:26

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0b84b64
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3c0f8a5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 491bd4d
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: b90399a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

@nija-at nija-at left a comment

Choose a reason for hiding this comment

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

Code looks good to me.

As claimed by the failing PR check, this change needs an update to the package's README. Can you add this information to the appropriate sections?

A URL section is missing, let's add that. As well as, state in both the email and url sections that they support tokens with a code example. A good example would be to show the use of CfnParameter (which is powered by tokens),

const emailAddress = new CfnParameter(this, 'email-param');
myTopic.addSubscription(new subscriptions.EmailSubscription(emailAddress.valueAsString());

@mergify mergify bot dismissed nija-at’s stale review February 24, 2020 02:42

Pull request has been modified.

@strazeadin
Copy link
Contributor Author

Pushed an update to the readme file (Although I believe this is a bug fix and not a new feat).

The URL section already existed (under HTTPS) so I added a note regarding support for parameters as I haven't found many README files directly calling out support for tokens so wasn't sure what terminology to use.

Happy to make it more generic based on existing examples if you have any.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c4de34b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@nija-at
Copy link
Contributor

nija-at commented Feb 24, 2020

I've pushed a slightly modified README into this PR. Hope it looks ok to you.

Thanks for submitting this change 😊

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 711bea4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Feb 24, 2020

Thank you for contributing! Your pull request is now being automatically merged.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 8a4c734
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 0d03f01
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Feb 24, 2020

Thank you for contributing! Your pull request is now being automatically merged.

@mergify mergify bot merged commit e5493bd into aws:master Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[sns] support for tokens in EmailSubscription
4 participants