This repository was archived by the owner on May 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
feat: add amazon-q module #465
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dcc2572
feat(amazon-q): add initial module implementation with tests and README
DevelopmentCats a3bb1b1
refactor(amazon-q): remove validation for experiment_auth_tarball var…
DevelopmentCats ca20a12
fix(README): update Amazon Q installation link to the correct develop…
DevelopmentCats bbc1aa1
chore(README): fix typo in TODO
DevelopmentCats 9df68ce
fix(amazon-q): remove unused experiment_auth_tarball variable from tests
DevelopmentCats fb90707
fix(amazon-q): update default value for experiment_auth_tarball variable
DevelopmentCats 525a845
chore(amazon-q): add AmazonQ In Action Example Image
DevelopmentCats 87c34b7
feat(amazon-q): enhance prompts and architecture detection
DevelopmentCats f47c160
docs(amazon-q): update README with image and variable formatting
DevelopmentCats d9bee76
fix(amazon-q): rename task_prompt variable to ai_prompt
DevelopmentCats 9ec8726
fix(amazon-q): update README to rename task_prompt to ai_prompt
DevelopmentCats baca01d
fix(amazon-q): complete rename task_prompt to ai_prompt in main.tf
DevelopmentCats 26d58a2
fix(amazon-q): update system_prompt to enhance task reporting guideli…
DevelopmentCats 8f5737f
chore(amazon-q): clean up script by removing commented sections
DevelopmentCats File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
--- | ||
display_name: Amazon Q | ||
description: Run Amazon Q in your workspace to access Amazon's AI coding assistant. | ||
icon: ../.icons/aws.svg | ||
maintainer_github: coder | ||
verified: true | ||
tags: [ai, helper, amazon-q] | ||
--- | ||
|
||
# Amazon Q | ||
|
||
Run [Amazon Q](https://aws.amazon.com/q/) in your workspace to access Amazon's AI coding assistant. This module installs and launches Amazon Q, with support for background operation, task reporting, and custom pre/post install scripts. | ||
|
||
```tf | ||
module "amazon-q" { | ||
source = "registry.coder.com/modules/amazon-q/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
# Required: see below for how to generate | ||
experiment_auth_tarball = var.amazon_q_auth_tarball | ||
} | ||
``` | ||
|
||
 | ||
|
||
## Prerequisites | ||
|
||
- You must generate an authenticated Amazon Q tarball on another machine: | ||
```sh | ||
cd ~/.local/share/amazon-q && tar -c . | zstd | base64 -w 0 | ||
``` | ||
Paste the result into the `experiment_auth_tarball` variable. | ||
- To run in the background, your workspace must have `screen` or `tmux` installed. | ||
|
||
<details> | ||
<summary><strong>How to generate the Amazon Q auth tarball (step-by-step)</strong></summary> | ||
|
||
**1. Install and authenticate Amazon Q on your local machine:** | ||
|
||
- Download and install Amazon Q from the [official site](https://aws.amazon.com/q/developer/). | ||
- Run `q login` and complete the authentication process in your terminal. | ||
|
||
**2. Locate your Amazon Q config directory:** | ||
|
||
- The config is typically stored at `~/.local/share/amazon-q`. | ||
|
||
**3. Generate the tarball:** | ||
|
||
- Run the following command in your terminal: | ||
```sh | ||
cd ~/.local/share/amazon-q | ||
DevelopmentCats marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tar -c . | zstd | base64 -w 0 | ||
``` | ||
|
||
**4. Copy the output:** | ||
|
||
- The command will output a long string. Copy this entire string. | ||
|
||
**5. Paste into your Terraform variable:** | ||
|
||
- Assign the string to the `experiment_auth_tarball` variable in your Terraform configuration, for example: | ||
```tf | ||
variable "amazon_q_auth_tarball" { | ||
type = string | ||
default = "PASTE_LONG_STRING_HERE" | ||
} | ||
``` | ||
|
||
**Note:** | ||
|
||
- You must re-generate the tarball if you log out or re-authenticate Amazon Q on your local machine. | ||
- This process is required for each user who wants to use Amazon Q in their workspace. | ||
|
||
[Reference: Amazon Q documentation](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/generate-docs.html) | ||
|
||
</details> | ||
|
||
## Examples | ||
|
||
### Run Amazon Q in the background with tmux | ||
|
||
```tf | ||
module "amazon-q" { | ||
source = "registry.coder.com/modules/amazon-q/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
experiment_auth_tarball = var.amazon_q_auth_tarball | ||
experiment_use_tmux = true | ||
} | ||
``` | ||
|
||
### Enable task reporting (experimental) | ||
|
||
```tf | ||
module "amazon-q" { | ||
source = "registry.coder.com/modules/amazon-q/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
experiment_auth_tarball = var.amazon_q_auth_tarball | ||
experiment_report_tasks = true | ||
} | ||
``` | ||
|
||
### Run custom scripts before/after install | ||
|
||
```tf | ||
module "amazon-q" { | ||
source = "registry.coder.com/modules/amazon-q/coder" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
experiment_auth_tarball = var.amazon_q_auth_tarball | ||
experiment_pre_install_script = "echo Pre-install!" | ||
experiment_post_install_script = "echo Post-install!" | ||
} | ||
``` | ||
|
||
## Variables | ||
|
||
| Name | Required | Default | Description | | ||
| -------------------------------- | -------- | ------------------------ | ----------------------------------------------------------------------------------------------- | | ||
| `agent_id` | Yes | — | The ID of a Coder agent. | | ||
| `experiment_auth_tarball` | Yes | — | Base64-encoded, zstd-compressed tarball of a pre-authenticated Amazon Q config directory. | | ||
| `install_amazon_q` | No | `true` | Whether to install Amazon Q. | | ||
| `amazon_q_version` | No | `latest` | Version to install. | | ||
| `experiment_use_screen` | No | `false` | Use GNU screen for background operation. | | ||
| `experiment_use_tmux` | No | `false` | Use tmux for background operation. | | ||
| `experiment_report_tasks` | No | `false` | Enable task reporting to Coder. | | ||
| `experiment_pre_install_script` | No | `null` | Custom script to run before install. | | ||
| `experiment_post_install_script` | No | `null` | Custom script to run after install. | | ||
| `icon` | No | `/icon/amazon-q.svg` | The icon to use for the app. | | ||
| `folder` | No | `/home/coder` | The folder to run Amazon Q in. | | ||
| `order` | No | `null` | The order determines the position of app in the UI presentation. | | ||
| `system_prompt` | No | See [main.tf](./main.tf) | The system prompt to use for Amazon Q. This should instruct the agent how to do task reporting. | | ||
| `ai_prompt` | No | See [main.tf](./main.tf) | The initial task prompt to send to Amazon Q. | | ||
|
||
## Notes | ||
|
||
- Only one of `experiment_use_screen` or `experiment_use_tmux` can be true at a time. | ||
- If neither is set, Amazon Q runs in the foreground. | ||
- For more details, see the [main.tf](./main.tf) source. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { describe, it, expect } from "bun:test"; | ||
import { | ||
runTerraformApply, | ||
runTerraformInit, | ||
testRequiredVariables, | ||
findResourceInstance, | ||
} from "../test"; | ||
import path from "path"; | ||
|
||
const moduleDir = path.resolve(__dirname); | ||
|
||
const requiredVars = { | ||
agent_id: "dummy-agent-id", | ||
}; | ||
|
||
describe("amazon-q module", async () => { | ||
await runTerraformInit(moduleDir); | ||
|
||
// 1. Required variables | ||
testRequiredVariables(moduleDir, requiredVars); | ||
|
||
// 2. coder_script resource is created | ||
it("creates coder_script resource", async () => { | ||
const state = await runTerraformApply(moduleDir, requiredVars); | ||
const scriptResource = findResourceInstance(state, "coder_script"); | ||
expect(scriptResource).toBeDefined(); | ||
expect(scriptResource.agent_id).toBe(requiredVars.agent_id); | ||
// Optionally, check that the script contains expected lines | ||
expect(scriptResource.script).toContain("Installing Amazon Q"); | ||
}); | ||
|
||
// 3. coder_app resource is created | ||
it("creates coder_app resource", async () => { | ||
const state = await runTerraformApply(moduleDir, requiredVars); | ||
const appResource = findResourceInstance(state, "coder_app", "amazon_q"); | ||
expect(appResource).toBeDefined(); | ||
expect(appResource.agent_id).toBe(requiredVars.agent_id); | ||
}); | ||
|
||
// Add more state-based tests as needed | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Don't they support an easier more user friendly auth method?
Uh oh!
There was an error while loading. Please reload this page.
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.
I wish - that’s what’s recommended in the community forums. https://community.aws/content/2uZYCp6BNJJgBaRnw3Nie6i8r0l/putting-amazon-q-developer-in-a-docker-container