Varolan bir role aws tarafından yönetilen bir ilke eklemek istiyorum. Bunu şablon kullanarak başarıyorum:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation template to modify Role",
"Parameters": {
"MyRole": {
"Type": "String",
"Default": "MyRole",
"Description": "Role to be modified"
}
},
"Resources": {
"S3FullAccess": {
"Type": "AWS::IAM::ManagedPolicy",
"Properties": {
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"s3:*",
"s3-object-lambda:*"
],
"Resource": "*"
}]
},
"Roles": [
"MyRole"
]
}
}
}
}
Bu şablon s3FullAccess ile bir ilke oluşturacak ve bunu Myrole'a ekleyecektir. Ancak yeni bir politika oluşturmak istemiyorum, s3 tam erişim için aws ile zaten mevcut olan politikayı kullanmak istersem, bunu nasıl yapabilirim.
Ve eğer bu şablonu kullanırsam:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "AWS CloudFormation template to modify Role",
"Resources": {
"IAMRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"Path": "/",
"ManagedPolicyArns": [
"arn:aws:iam::aws:policy/ReadOnlyAccess"
],
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"AWS": "*"
}
}]
},
"RoleName": "RoleName"
}
}
}
}
Bu, yeni bir rol oluşturmaya ve readonlypolicy'yi ona eklemeye çalışacaktır. Ancak, varolan role bir ilke eklemek istersem, bu role şablonda nasıl başvurulur.