import boto3
client = boto3.client('ec2')
response = client.describe_instances()
instances = []
for reservation in response["Reservations"]:
for instance in reservation["Instances"]:
instances.append(instance["InstanceId"])
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sagemaker:InvokeEndpoint"
],
"Effect": "Allow",
"Resource": [
"arn:aws:sagemaker:us-east-1:my-account-id:endpoint/my-endpoint"
]
}
]
}
具体来说,这个策略允许该角色调用名为“my-endpoint”的Sagemaker端点。其中,“my-account-id”应该被替换为AWS账户ID。