[英]Adding the custom policy to the Role (taskRole)
I am trying to add policystatement to task.我正在尝试将政策声明添加到任务中。
What I made now is like this below.我现在做的是下面这样的。
const myBucketPolicy = new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
"s3:PutObject*"
],
resources: [
up_bk.bucketArn,
up_bk.bucketArn + "/*"
],
});
try to add this to the fargate taskrole.尝试将其添加到 Fargate 任务角色。
props!.taskDefinitionAdmin.taskRole.addToResourcePolicy(myBucketPolicy);
However, this error comes.但是,这个错误来了。
Property 'addToResourcePolicy' does not exist on type 'IRole'.
So basically, my idea is wrong.所以基本上,我的想法是错误的。
How can I add the custom policy to the role?如何将自定义策略添加到角色?
Solution using attachInlinePolicy使用 attachInlinePolicy 的解决方案
const pushacl = new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
"s3:PutObject*"
],
resources: [
"*"
],
});
const pushaclpolicy = new iam.Policy(this, 'pushs3acl-policy', {
statements: [pushacl]
});
taskDefinitionAdmin.taskRole.attachInlinePolicy(pushaclpolicy);
I think you should be using attachInlinePolicy , instead of addToResourcePolicy
.我认为您应该使用attachInlinePolicy ,而不是
addToResourcePolicy
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.