Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:21
    trivikr edited #3914
  • 19:21
    trivikr edited #3914
  • 18:54
    trivikr synchronize #3914
  • 18:47
    trivikr synchronize #3914
  • 18:44

    aws-sdk-js-automation on v2.1009.0

    (compare)

  • 18:44

    aws-sdk-js-automation on master

    Updates SDK to v2.1009.0 (compare)

  • 17:43
    trivikr synchronize #3914
  • 17:40
    trivikr synchronize #3914
  • 17:30
    trivikr synchronize #3914
  • 15:27
    trivikr synchronize #3914
  • 15:08
    trivikr synchronize #3914
  • 00:16
    trivikr synchronize #3914
  • Oct 14 22:31
    trivikr synchronize #3914
  • Oct 14 19:36
    shreddish edited #3918
  • Oct 14 19:34
    shreddish labeled #3918
  • Oct 14 19:34
    shreddish labeled #3918
  • Oct 14 19:34
    shreddish opened #3918
  • Oct 14 18:20

    aws-sdk-js-automation on master

    Updates SDK to v2.1008.0 (compare)

  • Oct 14 18:20

    aws-sdk-js-automation on v2.1008.0

    (compare)

  • Oct 14 04:57
    kcmobile commented #1704
Michał Dymel
@mdymel_gitlab
Hi, I have a browser app built with angular, which is used to manage resources using CloudFront. I want to be able to disable and delete the CF distributions. However when I use getDistribution from the js SDK, I am not getting the ETAG value - probably due to CORS restrictions. How can I work around it?
rajesh
@getmetorajesh_twitter
are there any default retryDelayOptions set for s3 uploads in the sdk
BertrandMarechal
@BertrandMarechal
it seems like you need to set it on the s3 initialization itself
rajesh
@getmetorajesh_twitter
thanks @BertrandMarechal
Jaafar Shhade
@jfrshd
Hello,
const paramsCredentials: CognitoIdentityCredentials.CognitoIdentityOptions = {
IdentityPoolId: this.POOL_DATA.IdentityPoolID,
Logins: {}
};
      paramsCredentials.Logins[this.POOL_DATA.YOUR_USER_POOL_ID_IDP] = session.getIdToken().getJwtToken();

      AWS.config.region = 'eu-east-2';
      AWS.config.credentials = new AWS.CognitoIdentityCredentials(paramsCredentials, {region: 'eu-east-2'});
      console.log(AWS.config.credentials);
      new AWS.CognitoIdentityCredentials(paramsCredentials, {
        region: 'eu-east-2',
      }).get((err) => {
        console.log('err', err);
      });
      // console.log('AWS.config.credentials', AWS.config.credentials);
      // config.credentials.get((err: AWSError) => {
      // if (!err) {
      // const id = config.credentials.identityId;
      // console.log('Cognito Identity ID ' + id);

      const docClient = new AWS.DynamoDB.DocumentClient({region: 'eu-east-2'});

      const params = {
        TableName: this.ddbTable,
        Item: {userid: 'haha', status: 'worked'}
      };

      docClient.put(params, (error, data) => {
        if (error) {
          console.log('error put', error);
        } else {
          console.log(data);
        }
      });

i am facing an error :

error put CredentialsError: Missing credentials in config

please help i found nothing
BertrandMarechal
@BertrandMarechal
Hey
where do you run this code ? locally ?
Jaafar Shhade
@jfrshd
yes
i am using angular
BertrandMarechal
@BertrandMarechal
so this is part of an angular service ?
Jaafar Shhade
@jfrshd
yes
BertrandMarechal
@BertrandMarechal
ok
so this error is usually linked to the fact that AWS cannot find the aws credentials (as api keys) from your environment variables
Jaafar Shhade
@jfrshd
should i be using secret and access keys?
BertrandMarechal
@BertrandMarechal
yes and no : Yes, that's what AWS SDK is expecting, no in an angular service if you are about to deploy it somewhere
it it is just a local app you are not gonna share, then you should be fine if you are careful (and do not share the credentials on a public github repo for instance)
Jaafar Shhade
@jfrshd
i mean i am trying to access the dynamo db using cognito user pool with identity pool
why should i need accesskey
they didn't mention that in the tutorial
BertrandMarechal
@BertrandMarechal
because they might be expecting you to run this code in Lambda or somewhere else where your credentials are set up
Jaafar Shhade
@jfrshd
Owwwwwwww
are you sure?
BertrandMarechal
@BertrandMarechal
not entirely, that's why I said might
Jaafar Shhade
@jfrshd
mmmmmmm
BertrandMarechal
@BertrandMarechal
but this error message is usually when it's missing the API keys :)
so which tutorial are you following ?
Jaafar Shhade
@jfrshd
i am following the link above
BertrandMarechal
@BertrandMarechal
so try with the following just after you define the region : AWS.config.credentials = new AWS.Credentials('<API KEY ID>', '<API SECRET>');
Jaafar Shhade
@jfrshd
it worked without access keys, there was a problem in matching keys
this took me 4 hours
thank you for your help
Jaafar Shhade
@jfrshd
hello
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:ListBucket"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::com.mybucket.123.mybucket"
],
"Condition": {
"StringLike": {
"s3:prefix": [
"${cognito-identity.amazonaws.com:sub}"
]
}
}
},
{
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::com.mybucket.123.mybucket/${cognito-identity.amazonaws.com:sub}/*"
]
}
]
}
this is my policy code

i am creating a folder in s3 like this

region + ":" + session.getIdToken().payload.sub

i think i am facing a problem where "sub" of js isn't matching the one of the policy so it keeps getting denied
i tried putting in statically in the policy and it worked
region + ":" + session.getIdToken().payload.sub isn't the same as cognito-identity.amazonaws.com:sub
am i right?
Ronique Ricketts
@RoniqueRicketts
Is it normal to get calls from +206 922 0130 stating that it's amazon service requesting a pin? I never initiate a pin.
Randy H
@randy-halim
most likely a scammer who is trying to get into your account-even if not, i would avoid giving the pin unless you are in a support session (as in you initiate it)
Ronique Ricketts
@RoniqueRicketts
I didn’t send the pin
kes333
@kes333
Hi, I am trying to access a PNG file from S3 using a presigned URL but I am consistently getting access denied. PDF files work as expected. Anybody has faced this issue? I am generating the pre-signed URL via AWS lambda for an S3 event. Thee are other issues also like when the pdf file is downloaded, it is downloading as response.pdf rather than the actual name which is in the URL. I cannot also download PDF files with multiple white spaces although I am able to do so with single space by replacing the filename with .repalce("+", " "). I am sure this will not work with other file types or special characters as well in the file name. First priority is to make the other file types like PNG work. Then work with multiple spaces in filename . Function to generate the presigned URL is as below ( Removed the API URL)

const AWS = require('aws-sdk');
var querystring = require('querystring');
var https = require('https');

//var fs = require('fs');

// if you are using an eu region, you will have to set the signature
// version to v4 by passing this into the S3 constructor -
// {signatureVersion: 'v4' }
var s3 = new AWS.S3({signatureVersion: 'v4'});

exports.handler = function (event, context,callback) {

const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key. replace("+", " ");
console.log( "File Name" + key. replace("+", " "));

if (!bucket) {
console.log('bucket not set:');
context.done(new Error(S3 bucket not set));
}

if (!key) {
console.log('key missing:');
context.done(new Error('S3 object key missing'));
return;
}

const params = {
'Bucket': bucket,
'Key': key,
Expires: 60 * 5

//ACL: 'public-read'

};

var url = s3.getSignedUrl('getObject', params);
url.replace(/+/g, '%2B');
console.log('The URL is', url);
ResponseContentDisposition: "attachment;filename=key";

//POST to external URL

var post_data = querystring.stringify(
url //TODO here we can get data fro cognito and then instead of obj need to set post_data into call
);

   console.log('post_data='+post_data);

       //TODO need to get data fom cognito
      var obj = {
        "url":url

   };

  console.log(JSON.stringify(obj));

var post_options = {
host:
//host: 'dummy.restapiexample.com',
path:'/v1/documenturl',
//path: '/api/v1/create',
method: 'POST',

};

// Set up the request
var post_req = https.request(post_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ' + chunk);
context.succeed();
});
res.on('error', function (e) {
console.log("Got error: " + e.message);
context.done(null, 'FAILURE');
});

});
console.log('post_req'+post_req);

// post the data
post_req.write(JSON.stringify(obj));//TODO post_data
post_req.end();

};

BertrandMarechal
@BertrandMarechal
can you please reformat your code ?