Skip to content

Instantly share code, notes, and snippets.

@bpmct

bpmct/main.tf Secret

Last active May 13, 2022 15:39
Show Gist options
  • Save bpmct/89cd29a356f8613778f6276df8dac753 to your computer and use it in GitHub Desktop.
Save bpmct/89cd29a356f8613778f6276df8dac753 to your computer and use it in GitHub Desktop.
Example of Coder template with Dotfiles
variable "dotfiles_uri" {
description = <<EOT
Optional: specify a URL for your dotfiles repo
- see: https://dotfiles.github.io
EOT
sensitive = false # user-level variable
}
resource "coder_agent" "dev" {
arch = "amd64"
auth = "aws-instance-identity"
os = "linux"
init_script<<EOT
# add dotfiles
if [ -n "${var.dotfiles_uri}" ]; then
git clone ${var.dotfiles_uri} dotfiles/
cd dotfiles/
if [[ -x "install.sh" ]]; then
# run install script
install.sh
else
shopt -s nullglob
for dotfile in "$DOTFILES_CLONE_PATH/".*; do
# Skip `..` and '.'
[[ $dotfile =~ \.{1,2}$ ]] && continue
ln -sf "$dotfile" "$HOME"
done
dotfiles/install.sh
fi
fi
EOT
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment