Skip to content

Commit f46953a

Browse files
authored
Merge pull request #3 from aws-samples/dev
updated README
2 parents 0e5037e + bacb1b3 commit f46953a

File tree

3 files changed

+70
-30
lines changed

3 files changed

+70
-30
lines changed

README.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Intelligent BI Demo
1+
# Generative BI Demo Application
22

33
[中文文档](README_CN.md)
44
## Introduction
@@ -12,14 +12,24 @@ A NLQ(Natural Language Query) demo using Amazon Bedrock, Amazon OpenSearch with
1212
### 1. Prepare EC2 Instance
1313
Create an EC2 with following configuration:
1414

15-
- Software Image (AMI): Amazon Linux 2023
16-
- Virtual server type (instance type): t3.large or higher
17-
- Firewall (security group): Allow 22, 80 port
15+
- OS Image (AMI): Amazon Linux 2023
16+
- Instance type: t3.large or higher
17+
- VPC: use default one and choose a public subnet
18+
- Security group: Allow access to 22, 80 port from anywhere (Select "Allow SSH traffic from Anywhere" and "Allow HTTP traffic from the internet")
1819
- Storage (volumes): 1 GP3 volume(s) - 30 GiB
1920

2021
### 2. Config Permission
21-
Bind an IAM Role to your EC2 instance.
22-
And attach an inline policy to this IAM Role with following permissions:
22+
23+
2.1 IAM Role's permission
24+
25+
Create a new IAM role with name genbirag-service-role and settings below:
26+
- Trusted entity type: AWS Service
27+
- Service: EC2
28+
- Use Case: EC2 - Allows EC2 instances to call AWS services on your behalf.
29+
30+
Skip "Add permission" and create this role first.
31+
32+
After the role is created, and then add permission by creating inline policy as below:
2333
```json
2434
{
2535
"Version": "2012-10-17",
@@ -29,7 +39,6 @@ And attach an inline policy to this IAM Role with following permissions:
2939
"Effect": "Allow",
3040
"Action": [
3141
"bedrock:*",
32-
"secretsmanager:GetSecretValue",
3342
"dynamodb:*"
3443
],
3544
"Resource": "*"
@@ -38,21 +47,27 @@ And attach an inline policy to this IAM Role with following permissions:
3847
}
3948
```
4049

50+
Finally, Bind this IAM instance profile (IAM Role) to your EC2 instance.
51+
52+
2.2 Amazon Bedrock's Model Permission
53+
4154
Make sure you have enabled model access in AWS Console in us-west-2 (Oregon) region for Anthropic Claude model and Amazon Titan embedding model.
55+
![Bedrock](assets/bedrock_model_access.png)
4256

4357
### 3. Install Docker and Docker Compose
4458

45-
On the EC2 instance, log in to the SSH command line as the ec2-user user or use the AWS EC2 Instance Connect feature in the EC2 console to log in to the command line. In the session, execute the following commands. If you are not this user, you can switch with the following command:
59+
Log in to the EC2 instance using SSH command as the ec2-user user or use the AWS EC2 Instance Connect feature in the EC2 console to log in to the command line.
4660

47-
Note: Execute each command one line at a time.
61+
In the session, execute the following commands. **Note: Execute each command one line at a time.**
4862

63+
If you are not this user, you can switch with the following command:
4964
```bash
5065
sudo su - ec2-user
5166
```
5267

5368
```bash
5469
# Install components
55-
sudo dnf install docker python3-pip git -y && pip3 install docker-compose
70+
sudo dnf install docker python3-pip git -y && pip3 install -U awscli && pip3 install docker-compose
5671

5772
# Fix docker python wrapper 7.0 SSL version issue
5873
pip3 install docker==6.1.3
@@ -79,35 +94,40 @@ sudo sh -c "echo 'vm.max_map_count=262144' > /etc/sysctl.conf" && sudo sysctl -p
7994
# Clone the code
8095
git clone https://github.com/aws-samples/generative-bi-using-rag.git
8196

82-
# Build docker images locally
83-
cd generative-bi-using-rag/application && cp .env.template .env && docker-compose build
97+
# Config the Environment Variable in .env file, modify AWS_DEFAULT_REGION to the region same as the EC2 instance.
98+
cd generative-bi-using-rag/application && cp .env.template .env
99+
100+
# Build docker images locally
101+
docker-compose build
84102

85103
# Start all services
86104
docker-compose up -d
87105

88106
# Wait 3 minutes for MySQL and OpenSearch to initialize
89107
sleep 180
90108
```
91-
Here is the English translation:
92109

93110
### 5. Initialize MySQL
94111

95112
In the terminal, continue executing the following commands:
96113

97114
```bash
98-
cd initial_data && unzip init_mysql_db.sql.zip && cd ..
115+
cd initial_data && wget https://github.com/fengxu1211/generative-bi-using-rag/raw/demo_data/application/initial_data/init_mysql_db.sql.zip
116+
117+
unzip init_mysql_db.sql.zip && cd ..
118+
99119
docker exec nlq-mysql sh -c "mysql -u root -ppassword -D llm < /opt/data/init_mysql_db.sql"
100120
```
101121

102-
### 6. Initialize OpenSearch
122+
### 6. Initialize Amazon OpenSearch docker version
103123

104124
6.1 Initialize the index for the sample data by creating a new index:
105125

106126
```bash
107127
docker exec nlq-webserver python opensearch_deploy.py
108128
```
109129

110-
If the script fails due to any errors, delete the index and rerun the previous command:
130+
If the command fails due to any errors, delete the index and rerun the previous command:
111131

112132
```bash
113133
curl -XDELETE -k -u admin:admin "https://localhost:9200/uba"

README_CN.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 智能BI演示
1+
# 生成式BI演示应用
22

33
## 介绍
44

@@ -11,14 +11,23 @@
1111
### 1. 准备EC2实例
1212
创建具有以下配置的EC2实例:
1313

14-
- 软件镜像(AMI): Amazon Linux 2023
15-
- 虚拟服务器类型(实例类型): t3.large或更高配置
16-
- 防火墙(安全组): 允许22, 80端口
14+
- OS镜像(AMI): Amazon Linux 2023
15+
- 实例类型: t3.large或更高配置
16+
- VPC: 使用默认的VPC并部署在公有子网
17+
- 安全组: 允许任何位置访问22, 80端口 (勾选允许来自以下对象的SSH流量和允许来自互联网的HTTP流量)
1718
- 存储(卷): 1个GP3卷 - 30 GiB
1819

19-
### 2. 配置权限
20-
为您的EC2实例绑定IAM角色, 可以参考[EC2文档-使用IAM角色](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#working-with-iam-roles)
21-
并为此IAM角色附加以下权限的内联策略:
20+
### 2. 配置权限
21+
22+
2.1 IAM Role的权限
23+
24+
创建一个新的IAM Role,名字为genbirag-service-role,具体设置为:
25+
- 信任实体:AWS服务
26+
- 服务: EC2
27+
- 使用场景:EC2 - Allows EC2 instances to call AWS services on your behalf.
28+
跳过"添加权限", 先创建出这个Role。
29+
30+
当Role创建好之后,再通过创建内联策略来添加以下权限:
2231
```json
2332
{
2433
"Version": "2012-10-17",
@@ -28,29 +37,34 @@
2837
"Effect": "Allow",
2938
"Action": [
3039
"bedrock:*",
31-
"secretsmanager:GetSecretValue",
3240
"dynamodb:*"
3341
],
3442
"Resource": "*"
3543
}
3644
]
3745
}
3846
```
47+
最后为你的EC2实例绑定IAM角色, 可以参考[EC2文档-使用IAM角色](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#working-with-iam-roles)
48+
49+
2.2 Amazon Bedrock的模型访问权限
3950

4051
确保您已在us-west-2(美国西部(俄勒冈州))区域的AWS控制台中为Anthropic Claude模型和Amazon Titan嵌入模型启用了模型访问。
52+
![Bedrock](assets/bedrock_model_access.png)
4153

4254
### 3. 安装Docker和Docker Compose
43-
在EC2中,以ec2-user用户通过SSH命令行登录或者使用AWS EC2控制台的EC2 Instance Connect功能登录命令行,在会话下执行以下命令。 如果不是此用户,您可以使用以下命令切换:
55+
在EC2中,以ec2-user用户通过SSH命令行登录或者使用AWS EC2控制台的EC2 Instance Connect功能登录命令行,在会话下执行以下命令。
4456

45-
注意:所有命令请一行一行执行。
57+
**注意:所有命令请一行一行执行。**
58+
59+
如果不是此用户,您可以使用以下命令切换:
4660

4761
```bash
4862
sudo su - ec2-user
4963
```
5064

5165
```bash
5266
# 安装组件
53-
sudo dnf install docker python3-pip git -y && pip3 install docker-compose
67+
sudo dnf install docker python3-pip git -y && pip3 install -U awscli && pip3 install docker-compose
5468

5569
# 修复docker的python包装器7.0 SSL版本问题
5670
pip3 install docker==6.1.3
@@ -77,8 +91,11 @@ sudo sh -c "echo 'vm.max_map_count=262144' > /etc/sysctl.conf" && sudo sysctl -p
7791
# 克隆代码
7892
git clone https://github.com/aws-samples/generative-bi-using-rag.git
7993

94+
# 在.env文件里配置环境变量,修改AWS_DEFAULT_REGION为你的EC2所在的区域
95+
cd generative-bi-using-rag/application && cp .env.template .env
96+
8097
# 在本地构建docker镜像
81-
cd generative-bi-using-rag/application && cp .env.template .env && docker-compose build
98+
docker-compose build
8299

83100
# 启动所有服务
84101
docker-compose up -d
@@ -90,11 +107,14 @@ sleep 180
90107
### 5. 初始化MySQL
91108
在终端里继续执行以下命令:
92109
```bash
93-
cd initial_data && unzip init_mysql_db.sql.zip && cd ..
110+
cd initial_data && wget https://github.com/fengxu1211/generative-bi-using-rag/raw/demo_data/application/initial_data/init_mysql_db.sql.zip
111+
112+
unzip init_mysql_db.sql.zip && cd ..
113+
94114
docker exec nlq-mysql sh -c "mysql -u root -ppassword -D llm < /opt/data/init_mysql_db.sql"
95115
```
96116

97-
### 6. 初始化OpenSearch
117+
### 6. 初始化Amazon OpenSearch docker版本
98118

99119
6.1 通过创建新索引来初始化示例数据的索引
100120
```bash

assets/bedrock_model_access.png

65.5 KB
Loading

0 commit comments

Comments
 (0)