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

Error when making AWS API calls on windows #40

Closed
GJZwiers opened this issue Nov 6, 2022 · 4 comments · Fixed by #41
Closed

Error when making AWS API calls on windows #40

GJZwiers opened this issue Nov 6, 2022 · 4 comments · Fixed by #41

Comments

@GJZwiers
Copy link

GJZwiers commented Nov 6, 2022

First of all thank you for making this module, it is very nice! I noticed that on windows there is an error when trying to load the AWS credentials. My credentials are located in the default location for the file on windows C:\Users\<MyUser>\.aws\credentials and this is an example of code that errors:

import { ApiFactory } from 'https://deno.land/x/aws_api@v0.7.0/client/mod.ts';
import { CloudFormation } from "https://aws-api.deno.dev/v0.3/services/cloudformation.ts";

const cfn = new ApiFactory({
    region: 'eu-west-3'
}).makeNew(CloudFormation);

const result = await cfn.describeStacks();

console.log(result);

Error:

deno run -A  .\life.ts
error: Uncaught (in promise) Error: Failed to load any possible AWS credentials:
    - ()=>new EnvironmentCredentials('AWS') Error: AWS environment variables not set
    - ()=>new EnvironmentCredentials('AMAZON') Error: AMAZON environment variables not set
    - ()=>new SharedIniFileCredentials() NotFound: The system cannot find the path specified. (os error 3)    
    - ()=>new EcsTaskCredentials() Error: AWS_CONTAINER_CREDENTIALS_RELATIVE_URI not set
    - ()=>new TokenFileWebIdentityCredentials() Error: No WebIdentityToken file path is set
    - ()=>new EC2MetadataCredentials() TypeError: error sending request for url (http://169.254.169.254/latest/api/token): error trying to connect: tcp connect error: A socket operation was attempted to an unreachable network. (os error 10051)
    return Promise.reject(new Error([
                          ^
    at CredentialsProviderChain.getCredentials (https://deno.land/x/aws_api@v0.7.0/client/credentials.ts:44:27)
    at async QueryServiceClient.signingFetcher [as signedFetcher] (https://deno.land/x/aws_api@v0.7.0/client/client.ts:89:29)
    at async QueryServiceClient.performRequest (https://deno.land/x/aws_api@v0.7.0/client/client.ts:179:22)   
    at async CloudFormation.describeStacks (https://aws-api.deno.dev/v0.3/services/cloudformation.ts:606:18)  
    at async file:///C:/Users/GJZwiers/repos/deno_deno/life.ts:8:16

I also use WSL (Ubuntu) with credentials at ~/.aws/credentials and on there it works as normal.

@danopia
Copy link
Member

danopia commented Nov 6, 2022

Hi, thanks for the report!
This is likely the same exact issue that my /x/kubernetes_client library had on Windows.
I can't say I'm surprised, I included a TODO comment:

// TODO: this will probably go wrong on windows
const HOME = Deno.env.get('HOME');
filename = HOME+'/.aws/credentials';

Anyway, I've started a fix:

To test the fix, please use this import:

import { ApiFactory } from 'https://raw.githubusercontent.com/cloudydeno/deno-aws_api/4a9d5be8044abdc7d2d50186e9e9c0775d09d9a2/lib/client/mod.ts';

@GJZwiers
Copy link
Author

GJZwiers commented Nov 6, 2022

I've just tried it out, it looks like it fixed the issue. Working on both windows and WSL now

@danopia
Copy link
Member

danopia commented Nov 6, 2022

Great, thanks for reporting back! :)

I should be able to get a release out sometime this week, depends on what else needs work while I'm in the area

danopia added a commit that referenced this issue Feb 8, 2023
@danopia
Copy link
Member

danopia commented Feb 26, 2023

🚀 This fix finally shipped in a tag today: v0.8.0

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 a pull request may close this issue.

2 participants