Skip to content

Commit 8c037be

Browse files
authored
Aws cli (#42)
* add aws sso login option * add aws tab completion
1 parent fe5b7c4 commit 8c037be

File tree

7 files changed

+103
-7
lines changed

7 files changed

+103
-7
lines changed

.claude/settings.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
2+
"env": {
3+
"CLAUDE_CODE_USE_BEDROCK": "1",
4+
"AWS_REGION": "us-east-1",
5+
"AWS_PROFILE": "default"
6+
},
27
"permissions": {
38
"additionalDirectories": [
4-
"/mnt/data/crucible"
9+
"/mnt/data/crucible"
510
]
611
}
712
}

.devcontainer/.aws/config.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# AWS SSO Configuration Template
2+
# Copy this file to 'config' and fill in your organization's values
3+
# Run 'scripts/aws-sso-login.sh' to authenticate
4+
5+
[sso-session crucible-sso]
6+
sso_start_url = https://<YOUR-ORG>.awsapps.com/start>
7+
sso_region = <your-region>
8+
sso_registration_scopes = sso:account:access
9+
10+
[profile default]
11+
sso_session = crucible-sso
12+
sso_account_id = <your-account-id>
13+
sso_role_name = <your-role>
14+
region = <your-region>
15+
output = json

.devcontainer/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
.aws/credentials
2+
.aws/config
3+
.aws/sso*
4+
.aws/cli

.devcontainer/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM mcr.microsoft.com/devcontainers/dotnet:2.0.5-10.0-noble
22

33
ARG TARGETARCH
44
ARG DEBIAN_FRONTEND=noninteractive
5+
ARG AWS_CLI_VERSION="2.32.9"
56

67
# Switch to root for configuring image
78
USER root
@@ -48,6 +49,32 @@ RUN set -eux; \
4849
RUN git clone https://github.com/jaggedmountain/k-alias.git /tmp/k-alias && \
4950
cp /tmp/k-alias/[h,k]* /usr/local/bin
5051

52+
# Install AWS CLI with Session Manager Plugin
53+
RUN case "${TARGETARCH}" in \
54+
amd64) AWSCLI_PKG="awscli-exe-linux-x86_64-${AWS_CLI_VERSION}.zip" \
55+
SSM_URL="https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" ;; \
56+
arm64) AWSCLI_PKG="awscli-exe-linux-aarch64-${AWS_CLI_VERSION}.zip" \
57+
SSM_URL="https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_arm64/session-manager-plugin.deb" ;; \
58+
*) echo "Unsupported architecture: ${TARGETARCH}" >&2; exit 1 ;; \
59+
esac && \
60+
curl "https://awscli.amazonaws.com/${AWSCLI_PKG}" -o /tmp/awscliv2.zip && \
61+
unzip -q /tmp/awscliv2.zip -d /tmp && \
62+
/tmp/aws/install --update && \
63+
curl "${SSM_URL}" -o /tmp/session-manager-plugin.deb && \
64+
dpkg -i /tmp/session-manager-plugin.deb
65+
66+
# Configure AWS CLI bash completion
67+
RUN echo '' >> /home/vscode/.bashrc && \
68+
echo '# AWS CLI completion' >> /home/vscode/.bashrc && \
69+
echo 'bind "set show-all-if-ambiguous on"' >> /home/vscode/.bashrc && \
70+
echo 'complete -C /usr/local/bin/aws_completer aws' >> /home/vscode/.bashrc
71+
72+
# Configure AWS CLI zsh completion (using bashcompinit for AWS CLI v2 compatibility)
73+
RUN echo '' >> /home/vscode/.zshrc && \
74+
echo '# AWS CLI completion' >> /home/vscode/.zshrc && \
75+
echo 'autoload -Uz bashcompinit && bashcompinit' >> /home/vscode/.zshrc && \
76+
echo 'complete -C /usr/local/bin/aws_completer aws' >> /home/vscode/.zshrc
77+
5178
# Configure ZSH History
5279
RUN mkdir -p "/home/vscode/.history" && touch "/home/vscode/.history/zsh_history" && \
5380
chown -R vscode:vscode /home/vscode/.history && \

.devcontainer/devcontainer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"name": "Crucible Development",
3-
"runArgs": ["--name", "crucible-dev"],
3+
"runArgs": [
4+
"--name",
5+
"crucible-dev"
6+
],
47
"build": {
58
"dockerfile": "Dockerfile"
69
},
@@ -15,7 +18,11 @@
1518
"ghcr.io/devcontainers/features/node:1": {
1619
"installYarnUsingApt": false
1720
},
18-
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
21+
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
22+
"version": "latest",
23+
"kubectl": "latest",
24+
"helm": "latest"
25+
},
1926
"ghcr.io/devcontainers-extra/features/markdownlint-cli2:1": {},
2027
"ghcr.io/devcontainers/features/github-cli:1": {},
2128
"ghcr.io/devcontainers/features/php:1": {
@@ -36,7 +43,7 @@
3643
// Shell history
3744
"source=crucible-dev-shell-history,target=/home/vscode/.history,type=volume",
3845
// AWS credentials for Claude Code (optional)
39-
"source=${localWorkspaceFolder}/.devcontainer/.aws,target=/home/vscode/.aws,type=bind,readonly",
46+
"source=${localWorkspaceFolder}/.devcontainer/.aws,target=/home/vscode/.aws,type=bind",
4047
// Claude Code data (sessions, history, todos, etc.)
4148
"source=crucible-dev-claude,target=/home/vscode/.claude,type=volume"
4249
],
@@ -60,7 +67,8 @@
6067
"shardulm94.trailing-spaces",
6168
"shd101wyy.markdown-preview-enhanced",
6269
"pflannery.vscode-versionlens",
63-
"Anthropic.claude-code"
70+
"Anthropic.claude-code",
71+
"AmazonWebServices.aws-toolkit-vscode"
6472
],
6573
"settings": {
6674
"editor.formatOnSave": true,

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ Development certificates, including a CA, are generated at container build time
2929

3030
## Claude Code
3131

32-
The dev container includes [Claude Code](https://docs.anthropic.com/en/docs/claude-code), Anthropic's CLI for Claude, configured to use AWS Bedrock via the official [Claude Code devcontainer feature](https://github.com/anthropics/devcontainer-features).
32+
The dev container includes [Claude Code](https://docs.anthropic.com/en/docs/claude-code), Anthropic's CLI for Claude, configured to use AWS Bedrock via the official [Claude Code devcontainer feature](https://github.com/anthropics/devcontainer-features). There are two setup methods that can be used to authenticate to AWS. Select the one that fits your use case.
3333

34-
### Setup
34+
### Setup option 1 - credential authentication
3535

3636
1. Copy the example credentials file:
3737
```bash
@@ -49,6 +49,36 @@ The dev container includes [Claude Code](https://docs.anthropic.com/en/docs/clau
4949

5050
The credentials file is mounted to `/home/vscode/.aws/credentials` inside the container and is excluded from git via `.devcontainer/.gitignore`.
5151

52+
### Setup option 2 - sso login authentication
53+
54+
1. Copy the example config file:
55+
```bash
56+
cp .devcontainer/.aws/config.example .devcontainer/.aws/config
57+
```
58+
59+
2. Edit `.devcontainer/.aws/config` and add your AWS account information:
60+
```ini
61+
[sso-session crucible-sso]
62+
sso_start_url = https://<YOUR-ORG>.awsapps.com/start
63+
sso_region = <your-region>
64+
sso_registration_scopes = sso:account:access
65+
66+
[profile default]
67+
sso_session = crucible-sso
68+
sso_account_id = <your-account-id>
69+
sso_role_name = <your-role>
70+
region = <your-region>
71+
output = json
72+
```
73+
74+
3. Build or rebuild the dev container
75+
4. Run the aws-sso-login.sh script
76+
```ini
77+
scripts/aws-sso-login.sh
78+
```
79+
80+
The config file is mounted to `/home/vscode/.aws/config` inside the container and is excluded from git via `.devcontainer/.gitignore`.
81+
5282
### Usage
5383

5484
Once the container is running with valid credentials, run `claude` in the terminal to start Claude Code.

scripts/aws-sso-login.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# start clean
4+
rm -f /home/vscode/.aws/cli/cache/*
5+
# login
6+
aws sso login --sso-session crucible-sso
7+
# create a file with the aws credentials needed for moodle or other docker-in-docker containers
8+
aws configure export-credentials --profile default > /home/vscode/.aws/sso-credentials

0 commit comments

Comments
 (0)