Skip to content

Automatically download Trusted Advisor Organisational view

0

I would like to setup a process for exporting organisational report of Trusted advisor checks automatically without having to sign in to console. How can I set that up?

asked a year ago1K views
2 Answers
1
Accepted Answer

To set up an automated process for exporting organizational reports of Trusted Advisor checks without having to sign in to the AWS Management Console, you can use AWS CLI and AWS IAM roles. Write a bash script or python code to schedule the automatic execution at your desired frequency

AWS
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
1

Hello,

check out this step will be helpful for you

  1. Create IAM Role
  • Go to IAM Console.
  • Create a Role for Lambda with TrustedAdvisorFullAccess and AmazonS3FullAccess policies.
  • Name it as you like.
  1. Create Lambda Function
  • Go to Lambda Console.
  • Create Function:
  • Runtime: Python.
  • Role: Use the role

3.Add Code:

import boto3
import datetime

def lambda_handler(event, context):
    client = boto3.client('support')
    s3_client = boto3.client('s3')
    bucket_name = 'your-s3-bucket-name'
    date_str = datetime.datetime.now().strftime("%Y-%m-%d")
    file_name = f"trusted_advisor_report_{date_str}.json"
    response = client.describe_trusted_advisor_checks(language='en')
    checks = response['checks']
    s3_client.put_object(
        Bucket=bucket_name,
        Key=file_name,
        Body=str(checks)
    )
    return {'statusCode': 200, 'body': 'Report saved to S3'}

  1. Schedule Lambda
  • Go to CloudWatch Console.
  • Create Rule:
  • Event Source: Schedule rate.
  • Target: Your Lambda function.
  • Name it and create.

This will automatically export the Trusted Advisor report

EXPERT
answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • Hello I have tried this approach and I believe the above solution will not be get the trusted advisor checks for all accounts **client.describe_trusted_advisor_checks(language='en') **this will only export checks for that current account. How we will be able to get all the checked for all account from org view. Is there any other API available to access the org view report and download it using API.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.