Note while I work with AWS
Cross-regions working: This is an interesting topic that I should write a separated one on this. However some brief information including:
SQS (queue-owner) subscribes to SNS (topic-owner) in another account: When it is within one account it sounds more simple, but when cross-accounts things get more complicated. And it boils down to SQS and SNS policies. It can be done in two ways: from SQS and from SNS. I experience the later case:
- Imagine you have an existing SQS queue in one account and want to send information from different services (SNS, lambda...) to that queue. In this case you want to add a subscription from services to SQS. SQS must confirms the subscriptions before SNS can send the message.
- SQS policy always should allow sqs:SendMessage from the subscription account.
- In case of lambda service, lambda role needs to allow ...
- In case of SNS service, SNS needs to create subscription. This subscription message will be sent to SQS queue for confirmation. Until SQS confirms the subscription, SNS can't send the message to the queue. This document from AWS explains it https://docs.aws.amazon.com/sns/latest/dg/sns-send-message-to-sqs-cross-account.html. The confirmation is more like click on the link in SubscribeURL of the sent message. One can do it automatically in code by getting SubscribeURL and do requests.get(SubscribeURL) --python.
- For SNS to send msg to SQS queue (even subscription or other message), SQS queue must have permission for SNS. To do so, SQS policy needs to update with allowing principal " Service:SNS", resource SNS topic, action sns:sendmessage
- SNS also needs to allow SQS to subscribe to it
- The second way is in case you are the owner of SQS and want to subscribe it to SNS in another account. In this case, the initiation is from SQS queue-owner, and no-one needs to confirm subscription
- Before SQS can subscribe, SNS topic must allow SQS subscription. SNS policy must add a statement to allow Principal SQS owner to SNS:Subscribe to SNS topic.
- After this, SQS can add subscribe to the topic
I found this link which can also explain better the second way of doing: https://aws.amazon.com/blogs/compute/cross-account-integration-with-amazon-sns/
Network Load Balancer (NLB)
1 NLB can forward traffic to " Target Groups" - which are instances. A NLB doesn't have a security group, therefore the security to which traffic is allowed must be done on the security group (sg) of instances and Access Control Policy (ACL).
- To allow traffic from NLB to an instance, the sg of an instance should allow NLB EIP (check Network Interfaces - search for NLB name to get its IP)
- NLB forwards traffic from the source -> target instance, sg of the target must allow source IP as well
Comments
Post a Comment