File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,8 @@ resource "coder_agent" "dev" {
90
90
env = {
91
91
GITHUB_TOKEN : data.coder_git_auth.github.access_token,
92
92
OIDC_TOKEN : data.coder_workspace.me.owner_oidc_access_token,
93
+ CODER_USER_TOKEN : data.coder_workspace.me.owner_session_token,
94
+ CODER_DEPLOYMENT_URL : data.coder_workspace.me.access_url
93
95
}
94
96
startup_script_behavior = " blocking"
95
97
@@ -202,6 +204,15 @@ resource "coder_agent" "dev" {
202
204
elif [ -f ~/personalize ]; then
203
205
echo "~/personalize is not executable, skipping..." | tee -a ~/.personalize.log
204
206
fi
207
+
208
+ # Automatically authenticate the user if they are not
209
+ # logged in to another deployment
210
+ if ! coder list >/dev/null 2>&1; then
211
+ set +x; coder login --token=$CODER_USER_TOKEN --url=$CODER_DEPLOYMENT_URL
212
+ else
213
+ echo "You are already authenticated with coder"
214
+ fi
215
+
205
216
EOT
206
217
}
207
218
You can’t perform that action at this time.
0 commit comments