Seeking guidance on querying CloudWatch logs across accounts using lambda and AWS SDK
Developing a lambda function in typescript
Deploying lambda with CloudFormation, granting necessary roles for reading from two different AWS accounts
Initial execution involves:
cloudWatchLogs.startQuery(startQueryParams).promise()
to obtain queryId
- Subsequently, executing the following with the queryId:
cloudWatchLogs.getQueryResults(getQueryResultsParams).promise()
to retrieve required log events
Utilizing specific parameters to access log events locally:
<{
const startQueryParams = {
logGroupName: this.logGroupName,
queryString: this.queryString,`your text`
startTime: this.startTime,
endTime: this.endTime
};>
If my lambda has the necessary security roles to query between accounts, how can I execute code (Lambda) from account_A to fetch log events from account_B? Obtaining account_B token and utilizing it.