-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Unable Connect do SQS if using a VPC #1900
Comments
I'm having the same problem. I can access KMS and SSM properly, just not SQS |
I finally figured this out. In order for the routes to work properly, you need to use a specific URL for the api calls as noted in the docs. The SQS metadata hasn't been updated in a long time and so it does not have this updated URL scheme. The solution was not clear to me originally since the argument for the So the fix is to override the session = boto3.Session()
sqs_client = session.client(
service_name='sqs',
endpoint_url='https://sqs.us-east-1.amazonaws.com',
)
sqs_client.send_message(
QueueUrl='https://sqs.us-east-1.amazonaws.com/...',
MessageBody=json.dumps('my payload'),
) |
So the reason we use the alternate endpoint style is to support Python 2.6 as it does not support SNI, which is required for the new endpoints. We would need to drop support for python 2.6-2.7.8. Even then it would still be a breaking change because people have whitelists for particular urls, so changing what we use would break them. One possibility in the short term is to add a configuration setting to switch over to the new endpoints. |
That makes sense. I don't necessarily think configuration would be better since the user would still need to know about the configuration options. A warning in the docs would be a good start, perhaps at the top of the page and each relevant section. I looked at the docs several times for a clue when I was working through this - that would have likely resolved it quickly. Another idea would be to log warnings if the user is on py2.7.8+, is using a new-style URL for the queue_url, and has not set the endpoint_url. Thanks for following up! |
Any updates or plans for tackling this issue? We're stuck on older versions of boto3 so we can work with SQS inside our VPCs. |
@SteveByerly thanks much for #1900 (comment) And I think a warning in the docs/logs would be good. |
@SteveByerly, you're my hero. Second that. The docs absolutely do not cover this (seems to apply to sqs only) and I burned 8 hours trying to figure it out. |
I want to add to the observation, it seems like it's not even consistent across regions. I had same code with same setup working in one region, but failing in another, sending me to investigate networking problems. Overriding endpoint URL works in both regions, but default |
The proposed solution with the additional |
To avoid confusion a quick follow-up: our problem was related to the lambda not having access rights to the public SQS endpoint. After fixing that, simply using |
Any updates on this one? |
@dt-kylecrayne I'm having the same issue, which boto3 version is working for you with SQS inside your VPCs? |
I found the following workaround overriding boto settings in endpoints.json:
I hope this helps someone else until this gets fixed |
This would be quite simple to fix within botocore. The offending line is 467 in Until this gets fixed (as I said, should be simple), I've created a microlibrary that implements a variation of the solution that @marianobrc indicated directly above. You can find this here - https://pypi.org/project/awsserviceendpoints/ |
Any updates on a fix for this? |
this also results in mismatch data between the cli and boto api usage, as the cli for some reason knows how to use the correct endpoint (sqs.region) but the boto api usage doesn't and has the legacy region. when querying queue url the service returns it based on the accessed host, so now we have data inconsistencies as well because of this.
it feels like madness to me that the sdk is forcing all its users to work around it. is there a default sane configuration without having to manually pass in endpoint, ie. how is the awscli doing the right thing? can we get a environment flag similiar to sts regional endpoints? |
Resolved the issue by putting lambda function in private subnet and allowing internet access using NAT gateway. VPC -> create private subnets -> create NAT Gateway in public subnet -> attach private subnets to NAT Gateway -> lambda configuration update VPC setting. session = boto3.Session(region_name="ca-central-1") |
I have had a lambda function sending messages to a sqs queue configured with a vpc, it has been working normally for several months, but now out of nowhere no messages are sent and the function times out. The Lambda function is in a private subnet. |
Change the security group ingress rules to allow all traffic, that works. |
Same thing happened to me. Lambda running with the VPC set up, there is a endpoint created so the resources within the VPN can access SQS endpoints. All working fine for years. Suddenly lambdas started to timeout and couldn't resolve SQS endoints. Opened the doors as @sejr1996 mentioned as a last resort and it worked for now. |
This issue has been addressed — you can test by running: import boto3
session = boto3.Session()
boto3.set_stream_logger('')
sqs_client = session.client(
service_name='sqs',
region_name='us-east-1'
)
response = sqs_client.list_queues()
print(response) And see in the logs that it resolves to the correct:
Please update to a newer version of Boto3 for access to the latest functionality. The most recent version is 1.34.125 per the CHANGELOG. And note that Python 3.8+ is required. SQS endpoints for reference: https://docs.aws.amazon.com/general/latest/gr/sqs-service.html. If you want to use a custom or legacy endpoint you could set the service-specific endpoint |
This issue is now closed. Comments on closed issues are hard for our team to see. |
when i try send sqs message from lambda in a VPC, i get timeout. I tryed use the VPC Link, but dont work.
{
"errorMessage": "2019-03-07T13:45:11.739Z 7cb1fd0f-7b84-4fcd-8775-01f0f374a0a9 Task timed out after 15.01 seconds"
}
SG Outbound ALL Open and NACL too.
I already create the VPC Link.
Function Logs
[INFO] 2019-03-07T13:44:56.744Z 7cb1fd0f-7b84-4fcd-8775-01f0f374a0a9 Start with Hash: 1111114502ff8532d063b9d988e2406a
[INFO] 2019-03-07T13:44:56.744Z 7cb1fd0f-7b84-4fcd-8775-01f0f374a0a9 msgData: {'msgBody': 'Howdy @ 2019-03-07 13:44:56', 'msgAttributes': {'hash': {'StringValue': '1111114502ff8532d063b9d988e2406a', 'DataType': 'String'}}}
2019-03-07 13:45:11.739 7cb1fd0f-7b84-4fcd-8775-01f0f374a0a9 ask timed out after 15.01 secondsundefined
If i remove the VPC all work fine...
But i need this fuction working inside a VPC
anyone help me please T_T
The text was updated successfully, but these errors were encountered: