Skip to content

Commit 9826679

Browse files
authored
Update aws.md
1 parent 6fb21a4 commit 9826679

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

ai/aws.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,124 @@
1515
- This leads to a [page describing what must be installed](https://catalog.workshops.aws/building-agentic-workflows/en-US/on_your_own)
1616
- The IDE in particular will be VS Code Code-Server
1717

18+
19+
## Build a working environment on EC2 including Q Developer access
20+
21+
22+
- EC2: Ubuntu Server latest; say c5.xlarge; keypair; new security group
23+
- SG: SSH(22) - 0.0.0.0/0 or be more specific
24+
- HTTP (80) - 0 etc
25+
- HTTPS (443) - 0 etc
26+
- Custom TCP (8501) 0 etc for Streamlit, a Web App Builder application
27+
- Custom TCP (8080) 0 etc for VS Code Server
28+
- 32GB gp3 root drive
29+
- Advanced Details > IAM Instance Profile: Create a role with Bedrock permissions
30+
- Create IAM Role for Bedrock Access
31+
- IAM > Roles > Create Role
32+
- Trusted Entity: EC2
33+
- Permissions: AmazonBedrockFullAccess
34+
- EC2InstanceConnect (optional?)
35+
- Name: EC2-Bedrock-Role
36+
- Attach this to the above EC2 instance
37+
- Connect, set up environment
38+
- `ssh -i keypair.pem ubuntu@ect-public-ip`
39+
- Install VS Code Server
40+
- Not tested yet; here is the command sequence:
41+
42+
43+
```
44+
curl -fsSL https://code-server.dev/install.sh | sh
45+
46+
mkdir -p ~/.config/code-server
47+
cat > ~/.config/code-server/config.yaml << EOF
48+
bind-addr: 0.0.0.0:8080
49+
auth: password
50+
password: your-secure-password
51+
cert: false
52+
EOF
53+
54+
# Start VS Code Server
55+
sudo systemctl enable --now code-server@ubuntu
56+
```
57+
58+
Here the 'your-secure-password' is an arbitrary password I select. I use it in
59+
authenticating in to the VS Code Server instance: Prompted when navigating to
60+
`http://ec2-ip-address:8080`.
61+
62+
63+
- Install Python3
64+
65+
66+
Notice this relies on `pip`.
67+
68+
69+
```
70+
# Update system
71+
sudo apt update && sudo apt upgrade -y
72+
73+
# Install Python 3 and pip
74+
sudo apt install -y python3 python3-pip python3-venv git
75+
76+
# Install development tools
77+
sudo apt install -y build-essential curl wget
78+
79+
# Upgrade pip and install common packages
80+
# `networkx` is just an example non-standard library (graph theory)
81+
# `boto3` is the AWS API Python library
82+
# `streamlit` is a library for building web apps
83+
# `transformers` and `torch` are used to implement HF models
84+
# `pillow` is the standard Python image processing library (evolved from PIL)
85+
pip3 install --upgrade pip
86+
pip3 install networkx boto3 streamlit transformers torch pillow
87+
```
88+
89+
90+
- Enable Amazon Q Developer
91+
- In VS Code Server aka browser address `http://the-ec2-ip:8080`
92+
- Open Extensions (Ctrl + Shift + X)
93+
- Search `Amazon Q`
94+
- Install `Amazon Q Developer` extension
95+
- Sign in with AWS Builder ID or "AWS Credentials"
96+
- Credentials by means of Access Key via the CLI: Next section
97+
98+
99+
- Configure AWS Credentials if needed
100+
101+
102+
```
103+
# Install AWS CLI
104+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
105+
unzip awscliv2.zip
106+
sudo ./aws/install
107+
108+
# Configure (if not using IAM role)
109+
# This prompts for four parameters: Region, Format (JSON), two keys from an access key file
110+
aws configure
111+
```
112+
113+
114+
- Enable Bedrock Models
115+
- AWS Console for this account > Bedrock > Enable Access >
116+
- Select desired models, request access "Next > Submit" > Verify (couple minutes)
117+
118+
- Test setup
119+
- Create this test file in VS Code Server:
120+
121+
```
122+
import boto3
123+
import networkx as nx
124+
125+
# Test Bedrock connection
126+
bedrock = boto3.client('bedrock-runtime', region_name='us-west-2')
127+
print("Bedrock client created successfully")
128+
129+
# Test NetworkX
130+
G = nx.Graph()
131+
G.add_edge('A', 'B')
132+
print(f"NetworkX working: {list(G.edges())}")
133+
```
134+
135+
136+
137+
138+

0 commit comments

Comments
 (0)