Description
SUMMARY
Right now it's not possible to bind an IAM role with a user in an ansible-friendly way. This use case should be supported since roles are only created to be assigned to users. A role without users is useless
ISSUE TYPE
- Feature Idea
COMPONENT NAME
Either add the functionality to the gcp_iam_role
module to be able to create and bind roles in one task or create a new module to exclusively bind roles to users
ADDITIONAL INFORMATION
There's no use on creating roles if they can't be added to a user. Right now my workaround is to use the command
module to add the role using gcloud
name: assign role to user
command: gcloud projects add-iam-policy-binding {{gcp_project}} --member "serviceAccount:myAccount@{{gcp_project}}.iam.gserviceaccount.com" --role "projects/{{gcp_project}}/roles/myRole"
But that has a lot of requirements. You need to have gcloud
locally, you need to be authenticated, it is not idempotent, etc etc
The simplest way that I can think for this new feature would be to add a parameter bindings
to the gcp_iam_role module to be able to bind the role to a list of users
e.g.
- name: Create and bind my role
gcp_iam_role:
name: "myRole"
title: Dummy role
project: "{{gcp_project}}"
included_permissions:
- compute.addresses.create
- compute.addresses.get
bindings: # new parameter
- serviceAccount:myAccount@{{gcp_project}}.iam.gserviceaccount.com