You can attach a policy to an IAM Role using the AWS Management Console, AWS CLI, or AWS SDKs. Here’s an example using the AWS CLI:
Example Code:
aws iam attach-role-policy --role-name ExampleRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess