{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example.com/*"
}
]
}
S3 Standard Storage | |
First 50 TB / Month | $0.023 per GB |
Next 450 TB / Month | $0.022 per GB |
Over 500 TB / Month | $0.021 per GB |
Data Transfer IN/OUT S3-Internet | |
All data transfer in | $0 per GB |
Out up to 1 GB / Month | $0 per GB |
Out, next 9.999 TB / Month | $0.09 per GB |
Request pricing | |
Data Returned by S3 Select | $0.0007 per GB |
Data Scanned by S3 Select | $0.002 per GB |
PUT, COPY, POST, or LIST Requests | $0.005 per 1,000 requests |
GET, SELECT and all other Requests | $0.0004 per 1,000 requests |
const AWS = require('aws-sdk');
const doc = require('dynamodb-doc');
AWS.config.update({ region: 'eu-west-1' });
const dynamo = new doc.DynamoDB();
const TableName = 'table';
const Key = { id: 1 };
exports.bumpCounter = async(event, context) => {
const result = await dynamo.getItem({ TableName, Key }).promise();
return {
statusCode: 200,
body: JSON.stringify(result) // { Item: { /* keys and values */ } }
};
};
const { counter } = await dynamo.getItem({ TableName, Key }).promise();
return {
statusCode: 200,
body: JSON.stringify(
(await dynamo.updateItem({
TableName,
Key,
UpdateExpression: `set counter = ${counter + 1}`,
ReturnValues: 'UPDATED_NEW'
}).promise()).Attributes
)
};
console.log
:)
const { counter } = await dynamo.getItem({ TableName, Key }).promise();
const { Item: { counter } } = await dynamo.getItem({ TableName, Key }).promise();
return { statusCode: 200, body: JSON.stringify( (await dynamo.updateItem({ TableName, Key,
UpdateExpression: `set counter = ${counter + 1}`,
UpdateExpression: 'set #C = :counter', ExpressionAttributeNames: { '#C': 'counter' }, ExpressionAttributeValues: { ':counter': (counter + 1) },
ReturnValues: 'UPDATED_NEW' }).promise()).Attributes ) };