amplify-education / serverless-vpc-discovery

Serverless plugin for discovering VPC / Subnet / Security Group configuration by name.
MIT License
38 stars 15 forks source link

connection issue behind corporate proxy to ec2 service #11

Closed robizz closed 3 years ago

robizz commented 6 years ago

Hi, thanks for this plugin, a lifesaver :)

i have a problem to query the ec2 service for vpc discovery, it seem to be a proxy issue:

Error -------------------------------------------------- Could not set vpc config. Message: UnknownEndpoint: Inaccessible host:ec2.eu-west-1.amazonaws.com'. This service may not be available in the eu-west-1' region. For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable. Stack Trace -------------------------------------------- Error: Could not set vpc config. Message: UnknownEndpoint: Inaccessible host:ec2.eu-west-1.amazonaws.com'. This service may not be available in the eu-west-1' region. at getVpcId.then.catch (c:\Development\aws\DAY3\sls_samples\sls_samples\stawa-service\sls-services\node_modules\serverless-vpc-discovery\index.js:59:13) at process._tickDomainCallback (internal/process/next_tick.js:135:7) From previous event: at PluginManager.invoke (C:\Users\scapelg\AppData\Roaming\npm\node_modules\serverless\lib\classes\PluginManager.js:366:22) at PluginManager.spawn (C:\Users\scapelg\AppData\Roaming\np

but on the same machine, aws cli and python boto3 can query the ec2 service successfully.

maybe the node aws sdk has issue in creating the ec2 client using system proxy configuration (in this case on a windows machine), do you have a workaround?

I ask this because unfortunately i am not a node expert :)

Thanks!

Roberto

robizz commented 6 years ago

Hi,

done some experiment comparing with other plugins and sls 1.24.1

if I replace your plugin generated ec2 client with the one that (i suppose) is passed from serverless, I obtain a successfull deploy:

-    AWS.config.update(awsCreds);
-    this.ec2 = new AWS.EC2();
+    this.aws = this.serverless.getProvider(this.provider);

and

-    return this.ec2.describeVpcs(vpcParams).promise().then((data) => {
+    return this.aws.request('EC2','describeVpcs', vpcParams,     this.stage ,    this.region ).then((data) => {

I have seen this stile in other plugins

does that make sense to you? do you want me to submit a PR?

rddimon commented 3 years ago

It has been fixed in version 2.0.0