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

SNS Tag update #221

Closed
wants to merge 17 commits into from
Closed

SNS Tag update #221

wants to merge 17 commits into from

Conversation

CarlosGamero
Copy link
Collaborator

No description provided.

@CarlosGamero CarlosGamero changed the title SNS Tag update on SNS SNS Tag update Oct 18, 2024
* It follows the following pattern: arn:aws:sns:<region>:<account-id>:<topic-name>
* Doc -> https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html
*/
const buildTopicArn = async (client: SNSClient, topicName: string) => {
Copy link
Owner

Choose a reason for hiding this comment

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

I would expose this from utils, this can be useful in a variety of different use-cases.

Would be nice to also write some tests for it, to ensure that the built arn matches the real arn created by SNS based on same parameters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mmm, Okay! will expose it 🙏

const region =
typeof client.config.region === 'string' ? client.config.region : await client.config.region()

const stsClient = new STSClient({
Copy link
Owner

@kibertoad kibertoad Oct 18, 2024

Choose a reason for hiding this comment

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

recreating client on every request sounds like a lot of overhead, I'd suggest to pass it as a dependency instead

Copy link
Collaborator Author

@CarlosGamero CarlosGamero Oct 18, 2024

Choose a reason for hiding this comment

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

Do you mean as a dependency for users? the idea was to hide its usage by using SNS config parameters, although I am not really sure if it is a good idea 🤔.

What do you mean by recreating it in every request? I think it is done just once on init right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh I got it, you mean to the method, would be fine to create it on publisher/consumer creation and pass it as parameter?

Copy link
Owner

Choose a reason for hiding this comment

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

wouldn't it be done once per buildTopicArn, which realistically means once for every topic?

Copy link
Owner

Choose a reason for hiding this comment

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

yeah, same as we pass sqsClient and snsClient

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But as a dependency passed by the user, or do you think it is a good idea to build it internally base on SNS config? Advantage of not requesting it is that the API won’t change

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(Btw sorry, I am already a bit slow 😓)

Copy link
Owner

Choose a reason for hiding this comment

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

I would pass by user, would be less surprising than globally cached dependency. but we can also make an optional parameter and build automatically if not passed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense to me! Will think about it and address the change in the new PR
Thanks Igor 🙌🏽

@CarlosGamero
Copy link
Collaborator Author

Will close this in favour of #222 to have clean PR, this is a bit dirty with all tests

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.

2 participants