title: AWS Access Keys Work Local Host but Not Depoloyment
body: <p>I am pretty lost here... I can use my AWS S3 Bucket on my localhost/ local server but not deployment on Heroku. I have tried a ton of searches and different approaches - Can anyone help?</p>
  <p>Basically... I have configured the Access Key ID through the IAM User. I also tried the Global Access Key ID and Secret Key Id.</p>
  <p>I am getting the error:</p>
  <pre><code>error InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records.
  </code></pre>
  <p>Thanks!</p>
  <p>Here is my config in the server file -</p>
  <pre><code>    // config for AWS bucket and rekognition services
  const AWS = require('aws-sdk')
  AWS.config.update({
    accessKeyId: process.env.KEY,
    secretAccessKey: process.env.SECRET,
    region: &quot;us-east-2&quot;,
  });
  
  const s3 = new AWS.S3({apiVersion: '2006-03-01'})
  const AWSParameters = {
      &quot;accessKeyId&quot;: process.env.KEY,
      &quot;secretAccessKey&quot;: process.env.SECRET,
      &quot;region&quot;: &quot;us-east-2&quot;,
      &quot;bucket&quot;: &quot;dk-prototype&quot;,
      &quot;ACL&quot;: &quot;public-read&quot;
  }
  
  const rekognition = new AWS.Rekognition(AWSParameters);
  const ses = new AWS.SES(AWSParameters);
  </code></pre>
  <p>Here is the POST request --</p>
  <pre><code>    app.post ('/upload-card-front/:game/:owner', isLoggedIn, function (req, res) {
    let ts = Date.now();
    let current_userID = res.locals.user.id;
    let current_user_screen_name = req.params.owner;
    let current_user_profile_pic = res.locals.user.picture;
    let key = current_userID + ts;
    var game = req.params.game
    s3.upload({
        Bucket: 'dk-prototype',
        Key:  `${key}.png`,
        Body: req.files.card_front.data,
        ACL: 'public-read',
      }, function(err, data) {
        if (err) {
          console.log('error', err)
        }
          var params = {
            Image: {
              S3Object: {
                Bucket: 'dk-prototype',
                Name: `${key}.png`,
              }
            }
          };
          rekognition.detectText(params, function(err, data) {
          if (err) {
            console.log(err, err.stack);
          } else {
            var name = ''
            if(game == 'Magic the Gathering'){
              name = data['TextDetections'][0]['DetectedText'];
            } else if(game == 'Pokemon'){
              name = data['TextDetections'][1]['DetectedText'].split(' ')[0];
            } else if(game == 'yugioh'){
              let name_length = data['TextDetections'][0]['DetectedText'].length;
              let raw_name = data['TextDetections'][0]['DetectedText'];
              let to_parse = raw_name.toUpperCase().split(' ', 3);
              to_parse.forEach(function(val, i){
                if(i !== to_parse.length -1){
                  name +=  val + ' '
                }
              })
            } else if(game == 'warcraft'){
              name = data['TextDetections'][0]['DetectedText'];
            } else {
              let vanguard_card = data['TextDetections']
              vanguard_card.forEach(function(c, i){
                if(i == vanguard_card.length - 4){
                  name = c['DetectedText'];
                }
              });
            }
            var card = {
              game: game,
              name: name,
              front: `https://s3.us-east-2.amazonaws.com/dk-prototype/${key}.png`,
              user_id: current_userID,
              user_screen_name: current_user_screen_name,
              profile_pic: current_user_profile_pic
            }
            var q = &quot;INSERT INTO user_cards VALUES (default, ${game}, ${name}, ${front}, ${user_id}, ${user_screen_name}, ${profile_pic}, default, default)&quot;;
            db.result(q, card)
              .then(function (result) {
              })
              .catch(function (e){
                console.log('error', e);
              });
            if(game == 'Magic the Gathering'){
              mtg_card = data['TextDetections'][0]['DetectedText'];
              var valid_card = false;
              mtg.card.all({ name: mtg_card })
                .on('data', card =&gt; {
                  // mtg_card_data = card
                  valid_card = true;
                });
            } else if(game == 'Pokemon') {
              console.log('let\'s hunt us one of them pokeman')
              pokemon_card = data['TextDetections'][1]['DetectedText'].split(' ')[0];
              console.log('here is your pokemon', pokemon_card)
              var valid_card = false;
              pokemon.card.all({ name: pokemon_card})
                .on('data', card =&gt; {
                    valid_card = true;
                  });
            } else if(game == 'yugioh'){
              let api_url = `http://yugiohprices.com/api/card_data/${name}`;
              axios.get(api_url)
                .then(function(r){
                  if(r.data.status == 'success'){
                  valid_card = true;
                  }
                })
                .catch(function(e){
                  console.log(e);
                });
            } else if(game == 'warcraft'){
            // so far no working api for warcraft
            valid_card = true;
            } else {
            //so far no working api for vanguard
              valid_card = true;
            }
            setTimeout(function(){
              if (valid_card == true) {
                var q = `SELECT * FROM user_cards WHERE game = \'${game}\' and user_id = '${current_userID}' ORDER BY id DESC LIMIT 1`;
                db.result(q)
                  .then(function(r) {
                      let front = r.rows[0].front
                      let validity = 'TRUE';
                      var q = `UPDATE user_cards SET valid = \'${validity}\' WHERE front = \'${front}\'`;
                      db.result(q)
                        .then(function (result) {
                        })
                    })
                    .catch(function(e){
                      console.log('error', e);
                    });
              }
            }, 2000);
          };
        });
      });
    res.redirect(`/games/card-back?name=back&amp;game=${game}&amp;owner=${current_user_screen_name}`);
  });
  </code></pre>