I'm try to create a service role for AWS CodeBuild.
I can create a role like this:
from aws_cdk import aws_iam as iam
role = iam.Role(
self, 'CodebuildServiceRole',
assumed_by=iam.ServicePrincipal('codebuild.amazonaws.com'),
max_session_duration=cdk.Duration.hours(1),
)
Now I need to attach the Amazon-provided AWSCodeBuildAdminAccess
policy to the role. How can I do this using the CDK?
You can get access to the policy like this:
AWSCodeBuildAdminAccess = iam.ManagedPolicy.from_aws_managed_policy_name('AWSCodeBuildAdminAccess')
And attach it to your role like this:
role.add_managed_policy(AWSCodeBuildAdminAccess)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.