-
Notifications
You must be signed in to change notification settings - Fork 80
Add AWS CLI module for installing AWS CLI v2 in workspaces #543
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
base: main
Are you sure you want to change the base?
Changes from all commits
fdaaba7
c22fb8b
fca4fdf
5564a55
75fd523
3393a04
eef8697
2039c39
7a70127
be4dc93
a7a4ae4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "lockfileVersion": 1, | ||
| "configVersion": 0, | ||
| "workspaces": { | ||
| "": { | ||
| "name": "registry", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| display_name: Austen Bruhn | ||
| bio: Solution Engineer at Coder, OSS enthusiast | ||
| github: ausbru87 | ||
| avatar: ./.images/avatar.png | ||
| linkedin: https://www.linkedin.com/in/austen-bruhn-b0a646a1/ | ||
| status: community | ||
| --- | ||
|
|
||
| # ausbru87 | ||
|
|
||
| Brief description of what this namespace provides. Include information about: | ||
|
|
||
| - What types of templates/modules you offer | ||
| - Your focus areas (e.g., specific cloud providers, technologies) | ||
| - Any special features or configurations | ||
|
|
||
| ## Templates | ||
|
|
||
| List your available templates here: | ||
|
|
||
| - **template-name**: Brief description | ||
|
|
||
| ## Modules | ||
|
|
||
| List your available modules here: | ||
|
|
||
| - **module-name**: Brief description | ||
|
|
||
| ## Contributing | ||
|
|
||
| If you'd like to contribute to this namespace, please [open an issue](https://github.com/coder/registry/issues) or submit a pull request. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| --- | ||
| display_name: AWS CLI | ||
| description: Install AWS CLI v2 in your workspace | ||
| icon: ../../../../.icons/aws.svg | ||
| verified: false | ||
| tags: [helper, aws, cli] | ||
| --- | ||
|
|
||
| # AWS CLI | ||
|
|
||
| Automatically install the [AWS CLI v2](https://aws.amazon.com/cli/) in your Coder workspace with command autocomplete support for bash, zsh, and fish shells. | ||
|
|
||
| ```tf | ||
| module "aws-cli" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/ausbru87/aws-cli/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| } | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - Installs AWS CLI v2 for Linux and macOS | ||
| - Supports x86_64 and ARM64 architectures | ||
| - Optional version pinning | ||
| - **Auto-configures command autocomplete** for bash, zsh, and fish shells | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Basic Installation | ||
|
|
||
| ```tf | ||
| module "aws-cli" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/ausbru87/aws-cli/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| } | ||
| ``` | ||
|
|
||
| ### Pin to Specific Version | ||
|
|
||
| ```tf | ||
| module "aws-cli" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/ausbru87/aws-cli/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| install_version = "2.15.0" | ||
| } | ||
| ``` | ||
|
|
||
| ### Custom Log Path | ||
|
|
||
| ```tf | ||
| module "aws-cli" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/ausbru87/aws-cli/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| log_path = "/var/log/aws-cli.log" | ||
| } | ||
| ``` | ||
|
|
||
| ### Airgapped Environment | ||
|
|
||
| Use a custom download URL for environments without internet access to AWS: | ||
|
|
||
| ```tf | ||
| module "aws-cli" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/ausbru87/aws-cli/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.example.id | ||
| download_url = "https://internal-mirror.company.com/awscli-exe-linux-x86_64.zip" | ||
| } | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| run "required_vars" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-id" | ||
| } | ||
| } | ||
|
|
||
| run "with_custom_version" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-id" | ||
| install_version = "2.15.0" | ||
| } | ||
| } | ||
|
|
||
| run "with_custom_log_path" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-id" | ||
| log_path = "/var/log/aws-cli.log" | ||
| } | ||
| } | ||
|
|
||
| run "with_custom_download_url" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-id" | ||
| download_url = "https://internal-mirror.company.com/awscli-exe-linux-x86_64.zip" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| terraform { | ||
| required_version = ">= 1.0" | ||
|
|
||
| required_providers { | ||
| coder = { | ||
| source = "coder/coder" | ||
| version = ">= 2.5" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| variable "agent_id" { | ||
| type = string | ||
| description = "The ID of a Coder agent." | ||
| } | ||
|
|
||
| variable "install_version" { | ||
| type = string | ||
| description = "The version of AWS CLI to install." | ||
| default = "" | ||
| } | ||
|
|
||
| variable "download_url" { | ||
| type = string | ||
| description = "Custom download URL for AWS CLI. Useful for airgapped environments. If not set, uses the official AWS download URL." | ||
| default = "" | ||
| } | ||
|
|
||
| variable "log_path" { | ||
| type = string | ||
| description = "The path to the AWS CLI installation log file." | ||
| default = "/tmp/aws-cli-install.log" | ||
| } | ||
|
|
||
| resource "coder_script" "aws-cli" { | ||
| agent_id = var.agent_id | ||
| display_name = "AWS CLI" | ||
| icon = "/icon/aws.svg" | ||
| script = templatefile("${path.module}/run.sh", { | ||
| LOG_PATH : var.log_path, | ||
| VERSION : var.install_version, | ||
| DOWNLOAD_URL : var.download_url, | ||
| }) | ||
| run_on_start = true | ||
| run_on_stop = false | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,129 @@ | ||||
| #!/usr/bin/env sh | ||||
|
|
||||
| set -e | ||||
|
|
||||
| LOG_PATH=${LOG_PATH} | ||||
| VERSION=${VERSION} | ||||
| DOWNLOAD_URL=${DOWNLOAD_URL} | ||||
|
Comment on lines
+5
to
+7
|
||||
|
|
||||
| BOLD='\\033[0;1m' | ||||
| RESET='\\033[0m' | ||||
|
|
||||
| printf "${BOLD}Installing AWS CLI...\\n${RESET}" | ||||
|
|
||||
| # Check if AWS CLI is already installed | ||||
| if command -v aws > /dev/null 2>&1; then | ||||
| INSTALLED_VERSION=$(aws --version 2>&1 | cut -d' ' -f1 | cut -d'/' -f2) | ||||
| if [ -n "$VERSION" ] && [ "$INSTALLED_VERSION" != "$VERSION" ]; then | ||||
| printf "❌ AWS CLI $INSTALLED_VERSION is installed, but version $VERSION was requested.\\n" | ||||
| printf "Note: AWS CLI installer does not support version-specific installation.\\n" | ||||
| exit 1 | ||||
| else | ||||
| printf "AWS CLI is already installed ($INSTALLED_VERSION). Skipping installation.\\n" | ||||
| exit 0 | ||||
| fi | ||||
| fi | ||||
|
|
||||
| # Determine OS and architecture | ||||
| OS=$(uname -s | tr '[:upper:]' '[:lower:]') | ||||
| ARCH=$(uname -m) | ||||
|
|
||||
| case "$ARCH" in | ||||
| x86_64) ARCH="x86_64" ;; | ||||
|
||||
| x86_64) ARCH="x86_64" ;; |
Copilot
AI
Nov 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the zsh autocomplete heredoc, the variable $AWS_COMPLETER_PATH is not properly escaped. Since this is inside a heredoc with the delimiter ZSHEOF (not quoted), the variable will be expanded by the shell when writing to .zshrc. Use double backslash or a different heredoc approach to ensure the literal variable reference is written to the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The namespace README contains placeholder text that should be replaced with actual content describing the contributor's modules and focus areas. Update the description and module list to reflect the AWS CLI module being added.