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 Tags update #222

Merged
merged 24 commits into from
Oct 28, 2024
Merged

SNS Tags update #222

merged 24 commits into from
Oct 28, 2024

Conversation

CarlosGamero
Copy link
Collaborator

@CarlosGamero CarlosGamero commented Oct 18, 2024

No description provided.

@CarlosGamero CarlosGamero self-assigned this Oct 18, 2024
@CarlosGamero CarlosGamero mentioned this pull request Oct 18, 2024
Comment on lines 13 to +14
snsClient: SNSClient
stsClient: STSClient
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

new dependency as discussed

@CarlosGamero CarlosGamero marked this pull request as ready for review October 23, 2024 16:43
describe('buildTopicArn', () => {
it('build ARN for topic', async () => {
const topicName = 'my-test-topic'
await expect(buildTopicArn(stsClient, topicName)).resolves.toMatchInlineSnapshot(
Copy link
Owner

Choose a reason for hiding this comment

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

might be good to also create a topic with the same name within the test, and compare actual arn to manually built one. then we will break if AWS will change the structure at some point

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea! will add it 🙌 thanks igor 🙇

* Doc -> https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html
*/
export const buildTopicArn = async (client: STSClient, topicName: string) => {
const identityResponse = await client.send(new GetCallerIdentityCommand({}))
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 move this call outside of the function and make building itself synchronous, but also expose an asynchronous method on top of it that does resolution for you.

from performance perspective it would be ideal to only resolve the identity once per app startup and not once per every queue. for now we can rely on async one, but having sync one exposed as well would allow to optimize in the future by moving identity resolution to app itself

Copy link
Collaborator Author

@CarlosGamero CarlosGamero Oct 28, 2024

Choose a reason for hiding this comment

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

I am not sure if moving identity resolution to the app is a good idea 🤔, maybe we can do it once and cache the result so the next calls won't need it, we can even do it within this file, what do you think?

Copy link
Owner

@kibertoad kibertoad Oct 28, 2024

Choose a reason for hiding this comment

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

sounds good! but let's expose a method to reset it as well, for tests e. g.

return `arn:aws:sns:${region}:${identityResponse.Account}:${topicName}`
}

export const clearCachedCallerIdentity = () => {
Copy link
Owner

Choose a reason for hiding this comment

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

let's expose it from package exports as well, because users may need it too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! I forgot to expose it on index 😓

@CarlosGamero CarlosGamero merged commit d5ecdf3 into main Oct 28, 2024
5 checks passed
@CarlosGamero CarlosGamero deleted the feat/SNS_tags_update branch October 28, 2024 16:32
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