Skip to content
Advertisement

How to attach a managed policy to a an IAM role using the CDK

I’m try to create a service role for AWS CodeBuild.

I can create a role like this:

JavaScript

Now I need to attach the Amazon-provided AWSCodeBuildAdminAccess policy to the role. How can I do this using the CDK?

Advertisement

Answer

You can get access to the policy like this:

JavaScript

And attach it to your role like this:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement