-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Put SQS Message from Lambda inside a VPC (config endpoint) #3203
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
Comments
I can't just make it work. I remember that it worked some time ago using only the I verified that:
The lambda always timeout trying to send the message to the queue. |
@baumblatt The above code will make a call to the
Marking this as a feature request and let the team work on it. |
I have a different problem that I think might be happening because of this issue. That some of the requests are going through the VPC while rest are going through public endpoint (goes through a NAT): ^ I have filtered these graphs with only the queue and VPC endpoint by tags. Have also verified the subnet for all the instances and for the VPC endpoint. Could it be possible that this issue would only impact one of the SQS request methods? We have tried using the VPC endpoint url in the queue url (Sep 08-09 days) |
@ajredniwja @luismramirezr
which can be found in DNS names in "Details" |
I'm having a similar issue. I'm running my lambda within localstack, so as described at this issue, I created my SQS object with no endpoint:
And I call
When I log the content of the sqs object, this is empty, and further I'm facing the following error when I call the When I run the lambda outside the localstack docker, with LOCALSTACK_HOSTNAME=localhost, I'm not facing this error. Also, I'm using aws-sdk-js to access DocumentClient in the same way and at the same lambda and this is working fine, I'm having this problem only with the SQS class. Can anyone help me? |
Any updates on this issue? I am running into the same issue, trying to use the SQS SDK in an EC2 instance via ECS. I am trying to use a VPC enpoint by doing
where Any calls to the SQS SDK functions would eventually timeout. |
As @pktippa mentioned, it works. thanks. 👍 |
This worked, but I am not sure if it is appropriate. ( var AWS = require('aws-sdk');
AWS.config.update({region: 'ap-northeast-1'});
var sqs = new AWS.SQS({apiVersion: '2012-11-05', endpoint : 'https://ap-northeast-1.queue.amazonaws.com'});
var queueURL = "https://sqs.ap-northeast-1.amazonaws.com/{id}/my-queue";
exports.handler = (event) => {
sqs.receiveMessage({ QueueUrl: queueURL }, function(err, data) {
// something
});
}; |
Is there anyone able to get it working? I am trying to send message to SQS from ECS Fargate, following are what I've tried:
All of above options end up timeout with the same error: "Error UnknownEndpoint: Inaccessible host: P/s: value of |
Finally! We were able to make it work. The answer that put us on track can be found here, so I think it could help someone out there struggling with this as we were.
Inbound: HTTPS(TCP)/443 <-- 0.0.0.0/0 Be aware that we are not security experts, so this configuration probably violates several security rules for a production environment, but for the moment we are in dev/prototype mode, so it didn't matter. We'll harden the configuration once we move to production environment (if funds are approved :) ) |
it was my inbound network configuration, I am not sure why it needs inbound traffic but thank danielcardenas75 for pointing it out 🙇 |
@danielcardenas75 Thanks for your detail answer, I just have one query, what Endpoint you are using exactly with queue url? DNS name given by VPC endpoint i.e "vpce-{{id}}-{{additional_text}}.sqs.us-east-1.vpce.amazonaws.com"? |
Hi @waleedasad, I think you are asking about this value: |
One note we observed when Lambda is a Python function using
To see which URL was created for the Boto resource object, you can inspect the When connecting to SQS with the default URL from a VPC, the lambda call would just time out. You can override this with the sqs = boto3.resource('sqs', endpoint_url='https://sqs.eu-west-1.amazonaws.com', region_name='eu-west-1') HTH. |
this is worked for me. Crucial step was setting Inbound rules, default one was http. thanks a lot |
this worked for me, thanks 🙏 |
My solution I created a VPCEndpoint or CloudFormation SQSVPCEndpoint:
Type: AWS::EC2::VPCEndpoint
Properties:
VpcId: !Ref VPC
ServiceName: !Sub com.amazonaws.${AWS::Region}.sqs
SecurityGroupIds:
- !Ref LambdaSecurityGroup
SubnetIds:
- !Ref SubnetAPrivate
- !Ref SubnetBPrivate
VpcEndpointType: Interface
Outputs:
.......
SQSVPCEndpointDNS:
Description: Endpoint de SQS
Value:
!Select [
'1',
!Split [':', !Select ['0', !GetAtt SQSVPCEndpoint.DnsEntries]],
]
I have 3 DNS names I use any DNS, example: vpce-04ab98b90de87d58e-xxxxxxxx.sqs.us-east-1.vpce.amazonaws.com In this case I work with Node.js import { SQS } from 'aws-sdk';
const sqs = new SQS();
sqs
.sendMessage({
QueueUrl:
'https://vpce-04ab98b90de87d58e-xxxxxx.sqs.us-east-1.vpce.amazonaws.com/<account-id>/<queue>',
MessageBody: JSON.stringify({ message: 'Hola' }),
})
.promise()
.then(result => {
console.log(result);
}); |
Hello! Please also see https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html for more detailed configuration. You will need to migrate to v3 of the SDK to use this. |
Confirm by changing [ ] to [x] below:
Describe the question
I want to put a message on a SQS queue from a Lambda function published on a private subnet of my VPC.
In accordant of documentations, this should work if the
endpoint
is configured to the VPC Endpoint for the SQS service.This issue is related with the Ruby and Java equivalents where the point is
QueueUrl
is overriding theendpoint
configurartion.Typescript Sample code:
Best regards,
Bernardo Baumblatt
The text was updated successfully, but these errors were encountered: