Skip to content

Commit 898db14

Browse files
committed
Merge branch 'feature/add-linux-dev-environment-guide' into 'develop'
Add Linux development environment setup guide See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!247
2 parents 82a5c1e + 1a04ec9 commit 898db14

File tree

2 files changed

+248
-0
lines changed

2 files changed

+248
-0
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Development Environment Setup Guide on Linux
2+
# Introduction
3+
This guide establishes a cloud-based development environment using Amazon Linux 2023 on AWS EC2, specifically designed for the GenAI IDP accelerator.
4+
5+
Purpose: Provides a standardized, scalable development infrastructure that combines the familiar VSCode interface on your local machine with powerful cloud compute resources. This approach eliminates local environment configuration issues while ensuring consistent development experiences across team members.
6+
7+
When to use this guide:
8+
- You need a new development environment
9+
- Your current setup has configuration issues
10+
- You prefer cloud-based development with scalable resources
11+
- You want a clean, isolated environment for this project
12+
13+
What you'll achieve:
14+
A hybrid development setup where your code runs on a pre-configured Amazon Linux EC2 instance while you work through VS Code on your local machine, providing both performance and consistency.
15+
16+
# Step 1: Launch EC2 Instance
17+
18+
## 1.1 Navigate to EC2 Console
19+
1. Log into [AWS Management Console](https://console.aws.amazon.com/)
20+
2. Navigate to EC2 service
21+
3. Click Launch Instance
22+
23+
## 1.2 Configure Instance Settings
24+
Name: genai-idp-dev-environment(example)
25+
AMI Selection:
26+
Amazon Linux 2023
27+
- Architecture: 64-bit (x86)
28+
29+
Instance Type:
30+
- Heavy development: t3.2xlarge (8 vCPU, 32 GB RAM)(recommended)
31+
(Other instance types will also work, but this is one we tested)
32+
33+
## 1.3 Key Pair Setup
34+
1. Click Create new key pair (or select existing)
35+
2. Name: genai-idp-dev-key (example)
36+
3. Type: RSA
37+
4. Format: .pem
38+
5. Download and save the .pem file securely
39+
40+
## 1.4 Network Settings
41+
Security Group Configuration:
42+
1. Create new security group
43+
2. Add these inbound rules:
44+
- **SSH**: Port 22, Source: My IP
45+
46+
## 1.5 Storage Configuration
47+
- Size: 720 GiB
48+
- Type: gp3
49+
- Delete on termination: Yes
50+
51+
## 1.6 Launch
52+
Click Launch instance and wait for it to reach "Running" state.
53+
54+
# Step 2: Connect to Your Instance
55+
56+
## Get Connection Info
57+
1. Select your instance in EC2 console
58+
2. Note the Public IPv4 address
59+
60+
## SSH Connection Command
61+
On local machine:
62+
### CMD Terminal
63+
ssh -i /path/to/genai-idp-dev-key.pem ec2-user@YOUR_INSTANCE_IP
64+
### To install git run this command on EC2 Instance
65+
sudo dnf install git -y
66+
67+
### Clone Repository
68+
git clone https://github.com/aws-solutions-library-samples/accelerated-intelligent-document-processing-on-aws
69+
70+
### Go to directory
71+
cd accelerated-intelligent-document-processing-on-aws/
72+
73+
### Run the setup script for development tools which is scripts directory
74+
cd scripts
75+
sh ./dev_setup.sh
76+
77+
### To upgrade the python version run this command on EC2 instance
78+
source /home/ec2-user/miniconda/bin/activate base
79+
80+
# Step 4: Install Visual Studio Code on Local Machine
81+
## 4.1 Visit the official website: Go to [https://code.visualstudio.com/](https://code.visualstudio.com/)
82+
Download: Click the "Download for Windows" button
83+
- This will download the User Installer (recommended for most users)
84+
- File name will be something like VSCodeUserSetup-x64-1.x.x.exe
85+
86+
Install:
87+
- Run the downloaded installer
88+
- Choose installation location (default is recommended)
89+
90+
Launch: Click "Launch Visual Studio Code" when installation completes
91+
Install Remote - SSH extension (by Microsoft)
92+
93+
## 4.2 Connect via VSCode: Update your SSH config
94+
To open "SSH Config" go to "Remote Explorer" option on left bar
95+
You can open and edit "SSH config" file by settings option on "SSH" Tab
96+
97+
```
98+
Host genai-idp-dev
99+
HostName YOUR_INSTANCE_PUBLIC_IP
100+
User ec2-user
101+
IdentityFile /path/to/genai-idp-dev-key.pem
102+
Port 22
103+
```
104+
105+
# 4.3 Connect via VSCode
106+
1. Press Ctrl+Shift+P
107+
2. Type "Remote-SSH: Connect to Host"
108+
3. Select "genai-idp-dev"
109+
4. Open folder: /home/ec2-user/accelerated-intelligent-document-processing-on-aws
110+
111+
# Step 5: AWS Configure
112+
### Refer this link for AWS configure
113+
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html
114+
115+
# Step 6: Run Publish Script
116+
## Test Build Process
117+
### Test publish script help
118+
./publish.sh --help
119+
120+
### Test build (this will take 10-15 minutes)
121+
./publish.sh bucket_name build-test us-east-1
122+
123+
# Step 7: Cline & Q Developer installation
124+
### Cline
125+
What it is: An AI coding assistant that runs as a VS Code extension, powered by various LLMs (Claude, GPT, etc.)
126+
127+
Key capabilities:
128+
- Autonomous code editing across multiple files
129+
- Executes terminal commands and reads file outputs
130+
- Can browse the web for documentation/research
131+
- Maintains context across entire codebases
132+
- Handles complex, multi-step development tasks
133+
134+
Why it's helpful: Acts like an AI pair programmer that can actually write, test, and debug code independently while you supervise.
135+
- You can install it from "Extensions" tab on VSCode.
136+
137+
### Amazon Q Developer
138+
What it is: AWS's AI coding assistant integrated into IDEs, specifically designed for AWS development
139+
140+
Key capabilities:
141+
- Code suggestions and completions optimized for AWS services
142+
- Security vulnerability scanning and fixes
143+
- AWS best practices recommendations
144+
- Infrastructure as Code (CloudFormation, CDK) assistance
145+
- Direct integration with AWS documentation and services
146+
147+
Why it's helpful: Specialized for AWS development with deep knowledge of AWS services, perfect for this GenAI-IDP project since it's
148+
built entirely on AWS.
149+
- You can install it from https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html

scripts/dev_setup.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
# SPDX-License-Identifier: MIT-0
5+
6+
##############################################################################################
7+
# Linux Development Environment Setup Script
8+
#
9+
# This script automates the installation of development tools for the GenAI IDP accelerator
10+
# on Amazon Linux 2023 systems. It installs Python 3.13, AWS CLI, SAM CLI, Node.js, Docker,
11+
# and other essential development tools.
12+
#
13+
# Usage: ./dev_setup.sh
14+
# Note: Reboot required after completion
15+
##############################################################################################
16+
17+
# exit on failure
18+
set -ex
19+
20+
pushd /tmp
21+
22+
# force python 3.9 (yum/dnf don;t seem to work well with 3.12)
23+
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
24+
sudo alternatives --set python3 /usr/bin/python3.9
25+
26+
# developer tools
27+
sudo yum groupinstall "Development Tools" -y
28+
29+
# python/pip/conda
30+
sudo dnf update -y
31+
sudo dnf install python3.12 -y
32+
sudo alternatives --install /usr/bin/python3 python3 /usr/bin/python3.13 1
33+
sudo alternatives --install /usr/bin/python python /usr/bin/python3.13 1
34+
python3.12 -m ensurepip --upgrade
35+
pip3 install --upgrade pip
36+
pip3 install virtualenv
37+
curl -LO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
38+
bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda || bash Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda -u
39+
40+
# aws cli
41+
sudo yum remove awscli -y
42+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
43+
unzip awscliv2.zip
44+
sudo ./aws/install --update
45+
46+
# sam cli
47+
wget https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip
48+
unzip aws-sam-cli-linux-x86_64.zip -d ./sam-cli
49+
sudo ./sam-cli/install --update
50+
51+
# node 18
52+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
53+
source ~/.bashrc
54+
nvm install 18
55+
56+
# docker
57+
sudo yum install docker -y
58+
sudo service docker start
59+
sudo usermod -a -G docker ec2-user
60+
61+
# local .bashrc scripts
62+
mkdir -p ~/.bashrc.d
63+
cat <<_EOF > ~/.bashrc.d/bob-prefs
64+
65+
_bash_history_sync() {
66+
builtin history -a
67+
}
68+
69+
# modifications needed only in interactive mode
70+
if [ "\$PS1" != "" ]; then
71+
# keep more history
72+
shopt -s histappend
73+
export HISTSIZE=100000
74+
export HISTFILESIZE=100000
75+
export PROMPT_COMMAND="history -a;"
76+
77+
if [[ "$PROMPT_COMMAND" != *_bash_history_sync* ]]; then
78+
PROMPT_COMMAND="_bash_history_sync; $PROMPT_COMMAND"
79+
fi
80+
81+
# default prompt (from Cloud9)
82+
_prompt_user() {
83+
if [ "\$USER" = root ]; then
84+
echo "\$USER"
85+
else
86+
echo ""
87+
fi
88+
}
89+
PS1='\[\033[01;32m\]\$(_prompt_user)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$(__git_ps1 " (%s)" 2>/dev/null) \$ '
90+
91+
alias python=python3
92+
alias pip=pip3
93+
alias interpreter="interpreter --model bedrock/us.anthropic.claude-3-haiku-20240307-v1:0"
94+
fi
95+
_EOF
96+
97+
popd
98+
99+
echo "DONE - Please reboot to complete the setup."

0 commit comments

Comments
 (0)