AWS에서 페더레이션 된 액세스를 위해 IAM 역할을 만들고 cloto를 사용하여 boto 또는 powershell을 사용하여 python에서 동일한 문제를 계속 실행하려고합니다.aws에서 iam 역할을 만들고 assumeRolePolicyDocument에서 오류가 발생했습니다.
여기 파이썬으로 무엇을하려고합니다. 나는 내가 통해 JSON을 실행 한
ClientError: An error occurred (ValidationError) when calling the CreateRole operation: The specified value for assumeRolePolicyDocument is invalid. It must contain only printable ASCII characters.
다음과 같은 오류를 얻을 해당 파일이 코드를 실행하면
import boto3
tpdoc = r'c:\folders\trustPolicy.json'
with open(tpdoc, 'r') as tpfile:
data = tpfile.read()
client = boto3.client('iam')
response = client.create_role(
RoleName="testrole",
AssumeRolePolicyDocument=data
)
이 참조 trustPolicy.json이
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRoleWithSAML",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"SAML:aud": "https://signin.aws.amazon.com/saml"
}
},
"Principal": {
"Federated": "arn:aws:iam::1234567890:saml-provider/myidp"
}
}
]
}
과 같이 구성되어 aws json 유효성 검사기 및 유효성을 검사하고 또한 허용되는 문자에 대한 정규식을 실행하고 그것을 전달합니다. 또한 수동으로 만든 역할에서 기존 트러스트 정책을 복사하고 내 json 파일에 해당 내용을 사용했지만 동일한 오류가 발생합니다.