had some trouble creating a service account and assigning roles to it. Initially I based my code on this example however I couldn't get it to work because while it does create the service account it does not assign roles to it. So I looked around on stackoverflow and found this answer which does work.
Pasted below is the content of Jinja file responsible for creating the service-account that doesn't work. What I expect it do is is create a service account and then assign pubsub.editor and dataflow.developer roles to it.
I don't understand why the code below doesn't work so I'm hoping someone can explain what is wrong with it.
{# Service account creation #}
resources:
- type: gcp-types/iam-v1:projects.serviceAccounts
name: {{ env['name'] }}
properties:
accountId: {{ env['name'] }}
displayName: serviceAccount-{{ env['name'] }}
accessControl:
gcpIamPolicy:
bindings:
- role: roles/dataflow.developer
members:
- "serviceAccount:myaccount-sa@myproject.iam.gserviceaccount.com"
- role: roles/pubsub.editor
members:
- "serviceAccount:myaccount-sa@myproject.iam.gserviceaccount.com"