This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -14,10 +14,15 @@ Templates that utilize Github External Auth can automatically ensure that the Co
14
14
# Example
15
15
16
16
``` tf
17
+ data "coder_external_auth" "github" {
18
+ id = "myauthid"
19
+ }
20
+
17
21
module "github-upload-public-key" {
18
22
source = "registry.coder.com/modules/github-upload-public-key/coder"
19
23
version = "1.0.13"
20
24
agent_id = coder_agent.example.id
25
+ external_auth_id = data.coder_external_auth.github.id
21
26
}
22
27
```
23
28
Original file line number Diff line number Diff line change @@ -14,11 +14,18 @@ variable "agent_id" {
14
14
description = " The ID of a Coder agent."
15
15
}
16
16
17
+ variable "external_auth_id" {
18
+ type = string
19
+ description = " The ID of the GitHub external auth."
20
+ default = " github"
21
+ }
22
+
17
23
resource "coder_script" "github_upload_public_key" {
18
24
agent_id = var. agent_id
19
25
script = templatefile (" ${ path . module } /run.sh" , {
20
26
CODER_OWNER_SESSION_TOKEN : data.coder_workspace.me.owner_session_token,
21
27
CODER_ACCESS_URL : data.coder_workspace.me.access_url,
28
+ GITHUB_EXTERNAL_AUTH_ID : var.external_auth_id,
22
29
})
23
30
display_name = " Github Upload Public Key"
24
31
icon = " /icon/github.svg"
Original file line number Diff line number Diff line change 4
4
5
5
CODER_ACCESS_URL=" ${CODER_ACCESS_URL} "
6
6
CODER_OWNER_SESSION_TOKEN=" ${CODER_OWNER_SESSION_TOKEN} "
7
+ GITHUB_EXTERNAL_AUTH_ID=" ${GITHUB_EXTERNAL_AUTH_ID} "
7
8
8
9
if [ -z " $CODER_ACCESS_URL " ]; then
9
10
echo " No coder access url specified!"
@@ -15,8 +16,13 @@ if [ -z "$CODER_OWNER_SESSION_TOKEN" ]; then
15
16
exit 1
16
17
fi
17
18
19
+ if [ -z " $GITHUB_EXTERNAL_AUTH_ID " ]; then
20
+ echo " No GitHub external auth id specified!"
21
+ exit 1
22
+ fi
23
+
18
24
echo " Fetching GitHub token..."
19
- GITHUB_TOKEN=$( coder external-auth access-token github )
25
+ GITHUB_TOKEN=$( coder external-auth access-token $GITHUB_EXTERNAL_AUTH_ID )
20
26
if [ $? -ne 0 ]; then
21
27
echo " Failed to fetch GitHub token!"
22
28
exit 1
You can’t perform that action at this time.
0 commit comments