svnshikhil
4/20/2018 - 12:52 PM

AWS

var AWS = require('aws-sdk')
var docClient = new AWS.DynamoDB.DocumentClient();
exports.handler = (event, context, callback) => {
    // TODO implement
    var params = {
		TableName: "",
		KeyConditionExpression: "#gameid = :gameId",
		ExpressionAttributeNames: {
			"#gameid": "gameID"
		},
		ExpressionAttributeValues: {
			":gameId":event.queryStringParameters.gameID
		}

	}
    docClient.query(params, function (err, data) {
        if (err) {
            console.log(err)
            callback(null, {
                headers: {
                    "Access-Control-Allow-Credentials": true,
                    "Access-Control-Allow-Origin": "*",
                    "Content-Type": "application/json",
                    "Access-Control-Allow-Methods": "POST",
                    "Access-Control-Request-Headers": "X-Custom-Header",
                    'Access-Control-Allow-Headers': 'tenant_id'
                },
                statusCode: 400,
                body: JSON.stringify(err),
            });
        } else {
            console.log(data)
            callback(null, {
                headers: {
                    "Access-Control-Allow-Credentials": true,
                    "Access-Control-Allow-Origin": "*",
                    "Content-Type": "application/json",
                    "Access-Control-Allow-Methods": "POST",
                    "Access-Control-Request-Headers": "X-Custom-Header",
                    'Access-Control-Allow-Headers': 'tenant_id'
                },
                statusCode: 200,
                body: JSON.stringify(data),
            });
        }
    })
};

#copy my-file.txt to the to the "data" directory located in my-s3-bucket 
aws s3 cp my-file.txt s3://my-s3-bucket/data/
 
#copy all files in my-data-dir into the "data" directory located in my-s3-bucket 
aws s3 cp my-data-dir/ s3://my-s3-bucket/data/ --recursive