xxxxxxxxxx
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
const bucketName = 's3-bucket-name';
const fileName = 'index.html';
exports.handler = (event, context, callback) => {
// Get the content of the index.html file from the S3 bucket
s3.getObject({ Bucket: bucketName, Key: fileName }, (err, data) => {
const content = data.Body.toString('utf-8');
// Invoke the callback with a successful response
callback(null, {
statusCode: 200,
body: content.replace(/OLDTEXT/g, 'NEWTEXT'),
headers: {
'Content-Type': 'text/html',
},
});
});
};