question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't grant permissions on secrets

See original GitHub issue

In our new deployments, I’ve been trying to assign secretmanager.secretAccessor on a specific secret to a given service account.

Is this an impossible feat? I’ve managed to create a type provider for the secret manager API, but cannot assign the required permissions.

This is a minimal deployment of the secret:

resources:
  # Service account needing secretAccessor
  - name: account-user123
    type: iam.v1.serviceAccount
    properties:
      accountId: user123
      displayName: user123

  # Create secret
  - name: secret-parent-up-auth_secret
    action: [PROJECT_ID]/secret-manager:secretmanager.projects.secrets.create
    properties:
      replication:
        automatic: {}
      parent: projects/[PROJECT_ID]
      secretId: auth_secret
    metadata:
      runtimePolicy:
        - CREATE
      dependsOn:
        - api-secretmanager
        - type-provider-secret-manager

  # Delete secret
  - name: secret-parent-down-auth_secret
    action: [PROJECT_ID]/secret-manager:secretmanager.projects.secrets.delete
    properties:
      name: projects/155387989549/secrets/auth_secret
    metadata:
      runtimePolicy:
        - DELETE
      dependsOn:
        - type-provider-secret-manager

  # Deploy secret version
  - name: secret-version-auth_secret_payload
    action: [PROJECT_ID]/secret-manager:secretmanager.projects.secrets.addVersion
    properties:
      parent: projects/[PROJECT_ID]/secrets/auth_secret
      payload:
        data: c3RhcmZpc2g=
    metadata:
      dependsOn:
        - secret-parent-up-auth_secret

  # Deploy secret manager type provider
  - name: type-provider-secret-manager
    type: gcp-types/deploymentmanager-v2beta:typeProviders
    properties:
      name: secret-manager
      descriptorUrl: https://secretmanager.googleapis.com/$discovery/rest?version=v1beta1
      options:
        inputMappings:
          - fieldName: Authorization
            location: HEADER
            value: $.concat("Bearer ", $.googleOauth2AccessToken())

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
m0arcommented, Sep 3, 2020

What does work, but gives access to all project secrets (which is obviously too generous):

  - name: iam-projectRole-user123-secretAccessor
    type: gcp-types/cloudresourcemanager-v1:virtual.projects.iamMemberBinding
    properties:
      resource: [PROJECT_ID]
      role: roles/secretmanager.secretAccessor
      member: serviceAccount:user123@[PROJECT_ID].iam.gserviceaccount.com
    metadata:
      dependsOn:
        - account-user123
        - secret-version-auth_secret_payload
0reactions
m0arcommented, Sep 15, 2020

@ocsig Got it, thanks for the insights ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolve Secrets Manager secret access errors after ... - AWS
I attempted to retrieve or access an AWS Secrets Manager secret, and received an error similar to one of the following: "You can't...
Read more >
Grant permission to applications to access an Azure key vault ...
Go to key vault Access control (IAM) tab and remove "Key Vault Secrets Officer" role assignment for this resource. Remove assignment - key...
Read more >
Access control with IAM - Secret Manager - Google Cloud
To create, manage, list, or access a secret, the appropriate IAM permissions must be granted at the project level and at the individual...
Read more >
Can't access secret stored in Secrets Manager from Google ...
Can you share the full error message? · And did you grant the Cloud Function's service account permissions to access the secret? ·...
Read more >
Grant AWS Lambda Access to Secrets Manager | bobbyhadz
In order to grant a Lambda function access to Secrets Manager, we have to ... If your function is still unable to access...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found