27 lines
864 B
Python
27 lines
864 B
Python
|
import boto3
|
||
|
import os
|
||
|
import json
|
||
|
|
||
|
client = boto3.client('sts')
|
||
|
response = client.assume_role(
|
||
|
DurationSeconds=900,
|
||
|
RoleArn='arn:aws:iam::794747783570:role/HKEX_INFRA_ROLE',
|
||
|
RoleSessionName='python',
|
||
|
)
|
||
|
|
||
|
os.environ['AWS_ACCESS_KEY_ID'] = response['Credentials']['AccessKeyId']
|
||
|
os.environ['AWS_SECRET_ACCESS_KEY'] = response['Credentials']['SecretAccessKey']
|
||
|
os.environ['AWS_SESSION_TOKEN'] = response['Credentials']['SessionToken']
|
||
|
|
||
|
session = boto3.Session(aws_access_key_id=response['Credentials']['AccessKeyId'],
|
||
|
aws_secret_access_key=response['Credentials']['SecretAccessKey'], aws_session_token=response['Credentials']['SessionToken'])
|
||
|
newclient = session.client(service_name="backup")
|
||
|
jobs = newclient.list_backup_jobs()['BackupJobs']
|
||
|
|
||
|
print(jobs)
|
||
|
# print(json.dumps(jobs))
|
||
|
|
||
|
# for key in jobs:
|
||
|
# print(key, ' : ', jobs[key])
|
||
|
|