Skip to content

Commit f34013b

Browse files
committed
feat: add Pulumi PAT to nomad-server
1 parent d9f51e0 commit f34013b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

Pulumi.github.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
config:
22
holochain:automationUserToken:
33
secure: AAABAMlBFfkdQybCGmTBT99+prfFkJ/NBtu6+S2gpnH/6XkYEAPrVM6B8/9aVLsgwqP7tLUCvEaLvHs84Nky2iPOYRS4XEaI
4+
holochain:hra2PulumiAccessToken:
5+
secure: AAABAESpY2fKLjLgiRFaQqZ1pE+H+SFfYbkKo2jKidYtZQT5KK26u3VKW/jmlG6JQTHebMt+M1OSgYk/Bt8r8UDjKbma6gbcwr/K6w==

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,24 @@ configured to use it. You can do this by running:
3434
```bash
3535
pulumi up
3636
```
37+
38+
### Rotating the Pulumi access token
39+
40+
The secret `hra2PulumiAccessToken` can be used to give repositories access to
41+
Pulumi itself so that changes can be deployed in the CI.
42+
43+
To rotate the token, you can run the following command:
44+
45+
```bash
46+
pulumi config set --secret hra2PulumiAccessToken <new-token>
47+
```
48+
49+
This value is encrypted by Pulumi and stored in `Pulumi.github.yaml`.
50+
51+
Then you will need to ask Pulumi to deploy the token to projects that are
52+
configured to use it. You can do this by getting a PR merged into `main` and
53+
allowing the CI to deploy it or by manually running:
54+
55+
```bash
56+
pulumi up
57+
```

main.go

+17
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ func main() {
513513
if err = AddAutomationUserSecret(ctx, conf, "nomad-server"); err != nil {
514514
return err
515515
}
516+
if err = AddPulumiAccessTokenSecret(ctx, conf, "nomad-server"); err != nil {
517+
return err
518+
}
516519

517520
return nil
518521
})
@@ -702,3 +705,17 @@ func AddAutomationUserSecret(ctx *pulumi.Context, cfg *config.Config, repository
702705

703706
return nil
704707
}
708+
709+
func AddPulumiAccessTokenSecret(ctx *pulumi.Context, cfg *config.Config, repository string) error {
710+
_, err := github.NewActionsSecret(ctx, fmt.Sprintf("%s-pulumi-access-token", repository), &github.ActionsSecretArgs{
711+
Repository: pulumi.String(repository),
712+
SecretName: pulumi.String("HRA2_PULUMI_ACCESS_TOKEN"),
713+
// The GitHub API only accepts encrypted values. This will be encrypted by the provider before being sent.
714+
PlaintextValue: cfg.RequireSecret("hra2PulumiAccessToken"),
715+
}, pulumi.DeleteBeforeReplace(true), pulumi.IgnoreChanges([]string{"encryptedValue"}))
716+
if err != nil {
717+
return err
718+
}
719+
720+
return nil
721+
}

0 commit comments

Comments
 (0)