Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the github token in the stack config doesn't have any effect #203

Open
pierskarsenbarg opened this issue Mar 31, 2022 · 4 comments
Labels
area/core awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features

Comments

@pierskarsenbarg
Copy link
Member

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

It looks like we store the (encrypted) GitHub token in the stack as part of the provider and if the token is changed in the stack config we don't update the value. This means that if the original token no longer exists (if it expires or is deleted) then you can't perform any more updates.

Steps to reproduce

  1. Create an access token (https://github.com/settings/tokens)
  2. Create a new Pulumi project (I used Typescript here) and install the GitHub provider
  3. Add the token to the stack config (pulumi config set github:token <token> --secret)
  4. Add the following to your index.ts:
import * as github from "@pulumi/github";

const repo = new github.Repository("my-test-repo", {
    name: "my-test-repo"
})
  1. Run pulumi up
  2. Create a new access token (https://github.com/settings/tokens) and set that to be the token in the stack
  3. Delete the origin token
  4. Run pulumi refresh

(You can also run pulumi stack export after step 5 and then see that it doesn't update in the stack json)

Expected: Pulumi would use the new access token
Actual: Pulumi continues to use the old (deleted) access token as part of the provider.

@pierskarsenbarg pierskarsenbarg added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Mar 31, 2022
@guineveresaenger
Copy link
Contributor

Hi @pierskarsenbarg -

I attempted to repro this and it turns out it is only pulumi refresh that is showing this behavior. pulumi up works just fine, and moreover, after a successful pulumi up with the new token (and old ones deleted), pulumi refresh is working just fine.

Console output after setting the secret:

@guin:github-203🦉 pulumi refresh
Previewing refresh (dev)

View Live: https://app.pulumi.com/guinevere/github-203/dev/previews/834bf9b3-e503-4305-8b33-5ffffa5fcfbc

     Type                        Name            Plan        Info
     pulumi:pulumi:Stack         github-203-dev              1 error
 ~   └─ github:index:Repository  my-test-repo    refresh     1 error
 
Diagnostics:
  pulumi:pulumi:Stack (github-203-dev):
    error: preview failed
 
  github:index:Repository (my-test-repo):
    error: Preview failed: refreshing urn:pulumi:dev::github-203::github:index/repository:Repository::my-test-repo: GET https://api.github.com/repos/guinandjamiesawesomeorg/my-test-repo: 401 Bad credentials []

@guin:github-203🦉 pulumi up
Previewing update (dev)

View Live: https://app.pulumi.com/guinevere/github-203/dev/previews/dffe7f7a-ca96-46fc-a1ae-afa484f2dcde

     Type                 Name            Plan     
     pulumi:pulumi:Stack  github-203-dev           
 
Resources:
    2 unchanged

Do you want to perform this update? yes
Updating (dev)

View Live: https://app.pulumi.com/guinevere/github-203/dev/updates/6

     Type                 Name            Status     
     pulumi:pulumi:Stack  github-203-dev             
 
Resources:
    2 unchanged

Duration: 2s

@guin:github-203🦉 pulumi refresh
Previewing refresh (dev)

View Live: https://app.pulumi.com/guinevere/github-203/dev/previews/777703d8-7d34-472f-95f8-fc8eb99dccdc

     Type                        Name            Plan     
     pulumi:pulumi:Stack         github-203-dev           
     └─ github:index:Repository  my-test-repo             
 
Resources:
    2 unchanged

Do you want to perform this refresh?
Do you want to perform this refresh?
Do you want to perform this refresh?
No resources will be modified as part of this refresh; just your stack's state will be. yes
Refreshing (dev)

View Live: https://app.pulumi.com/guinevere/github-203/dev/updates/7

     Type                        Name            Status     
     pulumi:pulumi:Stack         github-203-dev             
     └─ github:index:Repository  my-test-repo               
 
Resources:
    2 unchanged

Duration: 1s

I did not see any differnece between setting the token as an env var or via pulumi config set but my guess is that this is something to do with pulumi refresh not this particular provider.

@iwahbe
Copy link
Member

iwahbe commented Feb 27, 2024

This is an instance of pulumi/pulumi#4981.

iwahbe added a commit that referenced this issue Feb 28, 2024
Allow `token` to be set via the `GITHUB_TOKEN` env var.

This provides a partial workaround for
#203.
@iwahbe
Copy link
Member

iwahbe commented Feb 29, 2024

By setting the token via an env var: GITHUB_TOKEN instead of with pulumi config, you can work around this issue. That is current best practice until pulumi/pulumi#4981 is closed.

@VenelinMartinov
Copy link
Contributor

VenelinMartinov commented Mar 26, 2024

I suspect #578 was actually a regression here: #613

We had a similar issue in GCP

EDIT: Maybe not, could not repro an issue with expired credentials.

@mikhailshilkov mikhailshilkov added the awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). label Apr 2, 2024
@mjeffryes mjeffryes modified the milestone: 0.107 Jul 24, 2024
@mjeffryes mjeffryes added awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core awaiting/core Blocked on a missing bug or feature in pulumi/pulumi (except codegen) awaiting-upstream The issue cannot be resolved without action in another repository (may be owned by Pulumi). kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

6 participants