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

Represent all GH org secrets in pulumi #6

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Conversation

soapy1
Copy link
Contributor

@soapy1 soapy1 commented Nov 12, 2024

This PR represents all the conda-forge github org secrets in pulumi. Now, to update any github secret the process is:

  • find the secret in the pulumi 1password vault
  • update it to the desired value
  • run the push-secrets workflow

@soapy1 soapy1 force-pushed the push-secrets-pull-gh-secrets branch 14 times, most recently from 886ab8f to 1d1d0c1 Compare November 13, 2024 06:05
@soapy1 soapy1 marked this pull request as ready for review November 13, 2024 06:09
@soapy1 soapy1 requested review from jaimergp and beckermr November 13, 2024 16:09
@soapy1 soapy1 force-pushed the push-secrets-pull-gh-secrets branch from 1d1d0c1 to b97e7a7 Compare November 13, 2024 16:20
@soapy1 soapy1 force-pushed the push-secrets-pull-gh-secrets branch from b97e7a7 to 36414d3 Compare November 13, 2024 16:51
@beckermr
Copy link
Member

Before I double check each entry in detail, is there a way with pulumi to only run commands against one of the entries in the file, or do we have to do the whole thing?

@soapy1
Copy link
Contributor Author

soapy1 commented Nov 13, 2024

It looks like you can use the --target flag to run against a particular resource.

If it's helpful, there are also all ci these runs that apply only 1-3 resources at a time (I batched changes so that I could verify things were not breaking as secrets got swapped out).

@beckermr
Copy link
Member

Awesome. A question for the group, would all of this be clearer if we used separate files per secret?

cc @jaimergp

@soapy1
Copy link
Contributor Author

soapy1 commented Nov 13, 2024

would all of this be clearer if we used separate files per secret?

Ya, I think that's could be nice. Pulumi.yaml can have all the repos and providers defined, and then each secret can have a file like

# azure-token.yaml
variables:
  azure-token:
    fn::invoke:
      function: onepassword:getItem
      arguments:
        title: azure-token
        vault: pulumi
resources:
  gh-org-secret-azure-token:
    type: github:ActionsOrganizationSecret
    options:
      protect: false
      retainOnDelete: true
      deleteBeforeReplace: false
    properties:
      secretName: AZURE_TOKEN
      plaintextValue: ${azure-token.credential}
      visibility: selected
      selectedRepositoryIds:
        - ${repo-admin-requests.repoId}
        - ${repo-admin-migrations.repoId}

@beckermr
Copy link
Member

That looks good to me. Let's go for it and make sure to put instructions for the updated scheme in the readme.

@soapy1
Copy link
Contributor Author

soapy1 commented Nov 14, 2024

Ok so, I was briefly looking into splitting out the pulumi config into different files. But it looks like there is no good, built-in way to do this. Other users have used templating/yaml merging tools to achieve this end.

I think that's ok, but maybe a little clunky. Before spending the time to get that working, re-gauging interest in separating out secrets out into their own files.

ref:
https://archive.pulumi.com/t/13396200/is-there-anyway-to-split-pulumi-lt-stack-gt-yaml-to-multiple

@beckermr
Copy link
Member

That seems clunky. Is there a reason we need one single stack as opposed to separate stacks?

@beckermr
Copy link
Member

Yeah I was thinking about this and let's just use one file for now. We can figure out if something better can be done later.

@soapy1
Copy link
Contributor Author

soapy1 commented Nov 15, 2024

Is there a reason we need one single stack as opposed to separate stacks?

Could do, though I would lean towards not adopting a stack per secret. I think we get a lot of operational overhead as we adopt more stacks. Mostly around ensuring stack configuration stays consistent, and ensuring users access. And, adding secrets becomes more of a process.

Each stack has its own separate configuration and secrets, role-based access controls (RBAC) and policies, and concurrent deployments.
ref: https://www.pulumi.com/docs/iac/packages-and-automation/organizing-projects-stacks/

If we adopt a stack per secret, I think the workflow for adding a new secret would be something like:

  1. Create a new stack in pulumi pulumi stack init conda-forge/sync-secrets/my-new-secret (user must have access to the pulumi org)
  2. Add a new directory for the secret eg sync-secrets/my-new-secret
  3. Add the secret to sync-secrets/my-new-secret/Pulumi.yaml (would be similar to as outlined above)
  4. Add a step to the github workflow push-1password-secrets-to-gha.yaml to run the new new automation against the new stack

Using something like the automation api could automate most of these steps away. But, yaml is not one of it's supported languages.

@soapy1 soapy1 merged commit 1d633dd into main Nov 15, 2024
1 check passed
@beckermr beckermr deleted the push-secrets-pull-gh-secrets branch November 15, 2024 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants