Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    waleedshkt
    @waleedshkt
    Hey guyz, I'm trying to create S3 instance from S3 class in aws-sdk js v3. I add region, accessKeyId, secretAccessKey and sessionToken as constructor config parameters. But I am getting an error saying 'Credential is missing'. Please someone help me out. The issue is opened on stackoverflow at this link https://stackoverflow.com/questions/62612082/credential-is-missing-error-on-instantiating-s3-class-using-aws-sdk-js-v3
    Keren Cohen
    @kerendot
    I am using @aws-sdk/client-ec2 and @aws-sdk/client-cloudformation (is there a specific version for the browser?). Can anyone help me understand the format of exceptions that are being "catched"? I can console.log the error but I don't know how to extract a specific property that holds the content of the error. Any documentation exists?
    Keren Cohen
    @kerendot
    answering myself - was able to get it with e.toString()
    Traycho Ivanov
    @traycho_twitter

    Het, I am just trying v3.

    const data = await s3.getObject({
            Bucket: bucket,
            Key: key
        });

    And this results into {"errorType":"SyntaxError","errorMessage":"Unexpected token o in JSON at position 1","stack":["SyntaxError: Unexpected token o in JSON at position 1"," at JSON.parse (<anonymous>)"," at Runtime.exports.handler (/var/task/src/index.js:45:27)"," at processTicksAndRejections (internal/process/task_queues.js:97:5)"]}

    What is the best way to use getObject with new v3 ?

    2 replies
    Traycho Ivanov
    @traycho_twitter
    The issue is data.Body.toString("utf-8") is not working anymore
    Ronique Ricketts
    @RoniqueRicketts
    Hello all
    I am new to AWS and I am here going through the documentation for the Dynamodb client. If I do a ´´´put’´´ it only returns a blank object. Is there a way to get the created item results after creating it?
    Ricardo Montoya
    @mogarick
    Hello. I opened an aws/aws-sdk-js#3443 yesterday night (Mexico CDT) and I can now see in my github activity that "@trivikr transferred this issue from aws/aws-sdk-js-v3 24 minutes ago”. The issue cannot be found anymore (404), only through my github issues created activity.
    Can anybody please tell me what that means? Was the issue discarded, moved to internal review, etc? I’m new on this so I just want to know if I did something wrong or what to expect. Thank you in advance.
    Trivikram Kamat
    @trivikr
    @mogarick the issue was moved to v2 repo aws/aws-sdk-js#3443
    Ricardo Montoya
    @mogarick
    Thank you I’ve noticed a few minutes ago. It looks the redirect from the transfer was not being updated or something like that.
    Ricardo Montoya
    @mogarick
    @trivikr is the package @aws-sdk part of version 2? I stated "aws-sdk": "^2.747.0” but it was because I had that version installed in addition to aws-amplify that installs @aws-sdk in node modules. In such directory I don’t see a clear way to know the package version but only the individual directories ´package.json´ files. Most of them are in 1.0.0-gamma.3. I unisntalled the aws-sdk package to make sure it was not the one being used. The problems describen in the issue still persisted. So that’s why I’m asking if it is correct to leave the isse in version 2. thank you for your attention
    Zakir
    @sozakir
    hi, I want to use aws-sdk-v3 for s3, how can I install it from npm?
    Ricardo Montoya
    @mogarick

    Hi @sozakir. According to the v3 repo example for dynamoDB, this could be the way for S3:

    yarn add @aws-sdk/client-s3@gamma

    or for node

    npm i @aws-sdk/client-s3@gamma
    I don’t know if other v3 libs need to be installed alongside or the s3 client package handles that by itself.
    Zakir
    @sozakir
    Thanks @mogarick I had installed this yesterday. But some of the API are changed as compared to earlier aws-sdk. My earlier code written using aws-sdk was not working. could anyone shared the docs for aws-sdk-js-v3 usage? I am currently using s3 only in my code base.
    Daniel
    @Neuroforge
    Hello. I hope that you are all well. I'm working with the old SDK and have been struggling with credential issues. Is the V3 sdk compatible with amazon-cognito-identity-js and if so, how are credentials created using the v3 sdk?
    David Pfeffer
    @bytenik
    Hello all, hopefully this is something stupidly simple that I'm just not understanding. I am using a pretty vanilla instantiation of the SNS client, but when I tell it to publish a message, it tries to connect to localhost:443. It does this regardless of whether or not I specify an endpoint at construction.
    David Pfeffer
    @bytenik
    Solved it, I was using a much older release of the library (alpha.x, not gamma.x) and there was a bug. Its now been fixed.
    Oliver Salzburg
    @oliversalzburg
    Where is the documentation for the v3 SDK?
    Sebastien
    @sebastien6
    Hi, I was trying the new gamma-10 release, and was trying to use the function ec2.modifyTransitGateway(params, function(err, data) mentioned in the SDK documentation. However, seems that function do not exist in the V3 SDK. Does anyone know if it was replaced by something else?
    Robert Wawrzyniak
    @thuringia

    Hi everyone,
    I was thinking it might be better to ask this question here first, before opening an issue. Checking out the current gamma release there is a lot to like in the v3 SDK, however when trying it out I was left a bit disappointed by the proposed new API. It doesn't feel like an API designed for node... yet there is no description in the README or the issues giving insight into the design.
    I'm not sure if this is just my personal biases regarding API design talking though. Hence this long question here:
    Why is the "modular" API designed as a pattern of const c = new Client() and c.send(new Command())? I would have anticipated an API more in line with patterns in other libraries like const result = await command(options, client()), that way we could easily curry SDK-functions with project-specific configuration etc.
    Please ignore my non-usage of new this question is really not about "why classes".
    The current API feels very much like it is wrapping a set of RPC endpoints... which is absolutely fine, but wouldn't it be preferable to more closely align with other projects in this space.

    On a related note:
    Maybe the SDK could ship with a babel plugin or macro to rewrite the "enhanced v2" syntax to the "modular" one? The v2 syntax in many ways feels like a rather cohesive OOP-API, making it much easier to teach to juniors or team members who are not as familiar with AWS. The v3 API already raised questions like "what's a command" when we presented the v3 SDK as something new in a knowledge session.

    Robert Wawrzyniak
    @thuringia
    I cross-posted my question above to Github: aws/aws-sdk-js-v3#1557
    Martin Juhasz
    @martinjuhasz
    Hey, is the v3 api reference already online somewhere?
    Oliver Salzburg
    @oliversalzburg
    @martinjuhasz The last time I looked, it wasn't and nobody here answered me regarding where to find it
    Lauri Svan
    @laurisvan

    Hi, also awaiting for the v3 api. Meanwhile - how does the "assume role" functionality work in V3 API? Our current setup requires assuming a role from another account, and somehow v2 API was able to do it under the hood. When calling commands with the v3 API, I get "Profile <profile> requires a role to be assumed, but no role assumption callback was provided.".

    How to define such a callback?

    Jason
    @jstrese
    Would anyone happen to know why when using the S3Client with v3 it seems to be asking for credentials when being ran on an ec2? Usually the AWS SDK doesn't need to be provided credentials as long as the IAM profile has sufficient access (which it does)
    Chris Kalafarski
    @farski
    Do v3 DynamodbClient commands work like the v2 DocumentClient? I.e., do they work with standard JSON data, or does it need to be typed S: foo, etc
    Steven Aerts
    @steven-aerts
    @laurisvan this is how I got it working:
    {credentials: fromIni({
            roleAssumer: async (credentials, params) => {
                // no idea why we have to implement this ourselves.
                const sts = new STSClient({credentials});
                const response = await sts.send(new AssumeRoleCommand(params));
                return {
                    accessKeyId: response.Credentials.AccessKeyId,
                    secretAccessKey: response.Credentials.SecretAccessKey,
                    sessionToken: response.Credentials.SessionToken,
                    expiration: response.Credentials.Expiration,
                };
            }
        }
    Boris V.Kuznetsov
    @tampler
    Hello! I'm new to aws-sdk-v3 Javascript. Evaluating this new lib for our new project. Currently, I'm trying to getObject with the following:
    downloadFile = async (src: String, dst: String) => {
        this.params.Key = path.basename(src);
        var outFile = fs.createWriteStream(dst);
        try {
          const data = await this.s3
            .send(new GetObjectCommand(this.params))
            .Contents.array.forEach((element) => {
              outFile.write(element);
            });
          console.log("Success", data);
        } catch (err) {
          console.log("Error", err);
        }
      };
    I was able to reuse v2 js uploadFile, which works fine. However, this my impl creates a dstfile, but its empty (zero size). Could anybody point to my mistake? Thanks in advance !
    Boris V.Kuznetsov
    @tampler

    Alright... After looking at solution of @Mousaka, I came up with the working solution:

    const data = await this.s3.send(new GetObjectCommand(this.params)).then((response) => {
            const receiveObject = new Promise<Buffer>((resolve) => {
              const forBuffer = new PassThrough();
              response.Body?.pipe(forBuffer);
              forBuffer.on("data", (chunk) => {
                outFile.write(chunk);
              });
              forBuffer.on("finish", () => {
                outFile.end();
              });
            });
          });
          console.log("Success", data);
        } catch (err) {
          console.log("Error", err);
        }
      };

    Thanks for building and supporting the v3 API !

    Boris V.Kuznetsov
    @tampler

    Hello! How to instantiate S3Client in a browser with custom credentials? I'd like to use .env to pass creds to my JS code. Here's what I'm doing now:

    const cfg = {
      accessKeyId: process.env.KEY,
      secretAccessKey: process.env.SECRET,
      endpoint: process.env.HOST,
      s3ForcePathStyle: true,
      signatureVersion: "v4",
    };
    
    const s3 = new S3Client(cfg);

    This works in Node, but fails in the browser with the following error: "vue.runtime.esm.js?5593:619 [Vue warn]: Error in created hook: "Error: Credential is missing"
    How do I work around this? Thank you!

    Cristian Barrientos Montoya
    @ColadaFF
    Hi there, has anyone sign request to ElasticSearch using the sdk v3 ?
    2 replies
    Benjamin Tamasi
    @half2me
    Is there an example of how I can use the sdk-js-v3 to do a GraphQL query on my AppSync api?
    @aws-sdk/client-appsync seems to be for manipulating AppSync itself, I just want to query the GraphQL API
    Isaac Levy
    @isaacl
    Is the v3 included in the node lambda enviroment -- i.e. should I mark all @aws-sdk packages as external in my webpack build?
    2 replies
    Imaduddin Haetami
    @artidata
    On dealing with dynamodb ProvisionedThroughputExceededException error, I am using the same approach as this second answer of the given stackoverflow question. However, it seems that v3 doesn't support it as even though I have changed maxRetries to 5 the most number of attempts logged stuck at 3 and the error still occurred. Is there any suggestion to handle this issue?
    Imaduddin Haetami
    @artidata
    Well, I solve the issue by provisioning higher write capacity of the dynamodb table
    Dean Shelton
    @deanshelton913
    For anyone wondering how to use the new S3 getObject with Readable streams: This worked for me:
    (it's in Typescript but should work with raw JS aswell)
    import { Readable } from 'stream';
    
    const readStream = (stream: Readable): Promise<string> => {
      return new Promise((res, rej) => {
        let data = '';
        stream.on('data', function (chunk) { data += chunk; });
        stream.on('end', function () { res(data); });
        stream.on('error', rej);
      });
    }
    const params = { Bucket, Key };
    logger.debug('S3 getObject >', params);
    const result = (await s3.getObject(params)).Body as any;
    const stream = Readable.from(result);
    return readStream(stream);
    Ognjen Palija
    @misk0
    I've done in this way (NodeJS)
        const response = await s3.getObject({ Bucket: BUCKET, Key: imageName } );
    
        let file_stream = response.Body;
        let content_buffer = Buffer.from([]);
        if (file_stream instanceof Readable) {
            for await (const chunk of file_stream) {
                content_buffer = Buffer.concat([content_buffer,chunk]);
            }
        } else {
            throw new Error('Unknown object stream type.');
        }
    HOK
    @HOKcomics_twitter
    Hi guy
    Hi gals and guys, I'm getting my head arround the new Cognito interface
    I've managed login and some requests, but I'm struggling with security. Any best practices how to preserve a session in a static web application (Java Script using V3 via Webpack) so that my user doesn't have to log in every time he jumps between my various HTML files?
    Cognito side "session" function seems to be gone
    Saving Tokens in browser session seems to break OWASP best practices. Any hint appreciated.
    Eli B. Duhon
    @ebduhon
    I keep getting typescript compilation errors when attempting to use @aws-sdk/client-s3 any suggestions as to which version works?
    to be clear im trying to use it via nodejs
    Eli B. Duhon
    @ebduhon

    I keep getting typescript compilation errors when attempting to use @aws-sdk/client-s3 any suggestions as to which version works?

    After uninstalling all the @aws-sdk packages and reinstalling @aws-sdk/client-s3-node works but @aws-sdk/client-sqs no longer works and I am getting Typescript errors when attempting to use the ListQueuesCommand. ListQueuesCommand incorrectly implements interface 'Command...

    to be clear i am attempting to now use the @aws-sdk/client-sqs-node package