tensult / aws-automation Goto Github PK
View Code? Open in Web Editor NEWAWS automation scripts and lambda functions
Home Page: https://www.tensult.com
License: MIT License
AWS automation scripts and lambda functions
Home Page: https://www.tensult.com
License: MIT License
Hi,
The lambda below is setting retention for all newly created log groups to 14 whether its set to Never expire or any other value. How can you set this to only trigger when new log group has retention set to Never Expire, if it is a different value say 30 then don't do anything.
const AWS = require('aws-sdk');
const cloudwatchLogs = new AWS.CloudWatchLogs();
function setRetentionOfCloudwatchLogGroup(logGroupName, duration) {
let params = {
logGroupName : logGroupName,
retentionInDays: duration
};
return cloudwatchLogs.putRetentionPolicy(params).promise();
}
exports.handler = async (event) => {
const logGroupName = event.logGroupName ? event.logGroupName : event.detail.requestParameters.logGroupName;
try {
await setRetentionOfCloudwatchLogGroup(logGroupName, 14);
console.log('Retention has been set to ' + logGroupName + 'for 2 weeks');
return;
} catch(error) {
console.error(error);
throw error;
}
};
When running the lambda:
const AWS = require('aws-sdk');
const cloudwatchLogs = new AWS.CloudWatchLogs();
//const requestParameters = false;
function setRetentionOfCloudwatchLogGroup(logGroupName, duration) {
let params = {
logGroupName : logGroupName,
retentionInDays: duration
};
return cloudwatchLogs.putRetentionPolicy(params).promise();
}
exports.handler = async (event) => {
const logGroupName = event.logGroupName ? event.logGroupName : event.detail.requestParameters.logGroupName;
try {
await setRetentionOfCloudwatchLogGroup(logGroupName, 14);
console.log('Retention has been set to ' + logGroupName + 'for 2 weeks');
return;
} catch(error) {
console.error(error);
throw error;
}
};
Getting following error:
Response:
{
"errorType": "TypeError",
"errorMessage": "Cannot read property 'requestParameters' of undefined",
"trace": [
"TypeError: Cannot read property 'requestParameters' of undefined",
" at Runtime.exports.handler (/var/task/index.js:14:81)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:63:25)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
Request ID:
"aab21312-d1f8-4940-a9ac-2dab49dd858e"
Function Logs:
START RequestId: aab21312-d1f8-4940-a9ac-2dab49dd858e Version: $LATEST
2019-07-17T14:28:30.805Z aab21312-d1f8-4940-a9ac-2dab49dd858e ERROR Invoke Error {"errorType":"TypeError","errorMessage":"Cannot read property 'requestParameters' of undefined","stack":["TypeError: Cannot read property 'requestParameters' of undefined"," at Runtime.exports.handler (/var/task/index.js:14:81)"," at Runtime.handleOnce (/var/runtime/Runtime.js:63:25)"," at process._tickCallback (internal/process/next_tick.js:68:7)"]}
END RequestId: aab21312-d1f8-4940-a9ac-2dab49dd858e
REPORT RequestId: aab21312-d1f8-4940-a9ac-2dab49dd858e Duration: 21.63 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 78 MB
Now: AWS automation scripts and lambda functions https://ww.tensult.com
Expected: AWS automation scripts and lambda functions https://www.tensult.com
One w
missed in URL =)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.