Skip to content

Commit b192650

Browse files
Copilotsgbaird
andcommitted
Update boto3 credentials documentation and clarify bucket settings
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
1 parent 3486a36 commit b192650

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

src/ac_training_lab/a1_cam/README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Key considerations:
4141

4242
![S3 Public Access Settings](https://github.com/user-attachments/assets/fb694a7f-4dc0-4baf-a603-01bfa74d3165)
4343

44-
- **Bucket Versioning**: Enable (recommended for production use)
44+
- **Bucket Versioning**: Can be left disabled by default. Enable if you want to keep multiple versions of files (less applicable when uploading timestamped images as this camera does)
4545
- **Default encryption**: Enable Server-side encryption with Amazon S3 managed keys (SSE-S3)
4646

4747
### 3. Create IAM Credentials
@@ -92,17 +92,15 @@ Replace `your-bucket-name` with your actual bucket name.
9292
- You'll receive an `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
9393
- **Important**: These credentials will only be shown once, so save them immediately
9494

95-
### 4. Configure Bucket Policies (Optional)
96-
97-
If you need to access images via public URLs, you can configure bucket policies. See:
98-
- [Using bucket policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)
99-
- [Bucket policy examples](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html)
100-
101-
For the a1_cam device, the default configuration generates URLs like:
95+
The a1_cam device generates URLs like:
10296
```
10397
https://{BUCKET_NAME}.s3.{AWS_REGION}.amazonaws.com/{object_name}
10498
```
10599

100+
If you need to configure additional bucket policies, see:
101+
- [Using bucket policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)
102+
- [Bucket policy examples](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html)
103+
106104
## boto3 Setup
107105

108106
The device uses [boto3](https://boto3.amazonaws.com/v1/documentation/api/latest/index.html), the AWS SDK for Python, to upload images to S3.
@@ -113,13 +111,28 @@ boto3 is included in the device `requirements.txt` and will be installed when yo
113111

114112
### Configuration
115113

116-
The device reads AWS credentials from the `my_secrets.py` file (see Secrets section below for setup).
114+
The device code explicitly passes AWS credentials to boto3 from the `my_secrets.py` file. This approach keeps all credentials in one place and avoids the need to configure `~/.aws/credentials` on the Raspberry Pi.
115+
116+
Add the following to your `my_secrets.py` file (see Secrets section below for creating this file):
117+
118+
```python
119+
AWS_ACCESS_KEY_ID = "your-aws-access-key-id"
120+
AWS_SECRET_ACCESS_KEY = "your-aws-secret-access-key"
121+
AWS_REGION = "us-east-2" # or your chosen region
122+
BUCKET_NAME = "rpi-zero2w-toolhead-camera" # or your bucket name
123+
```
124+
125+
The device.py code passes these credentials directly to boto3.client():
126+
```python
127+
s3 = boto3.client(
128+
"s3",
129+
aws_access_key_id=AWS_ACCESS_KEY_ID,
130+
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
131+
region_name=AWS_REGION,
132+
)
133+
```
117134

118-
Required AWS credentials:
119-
- `AWS_ACCESS_KEY_ID` - Your IAM user access key
120-
- `AWS_SECRET_ACCESS_KEY` - Your IAM user secret key
121-
- `AWS_REGION` - The region where your S3 bucket is located (e.g., `us-east-2`)
122-
- `BUCKET_NAME` - Your S3 bucket name
135+
**Note**: While boto3 also supports reading credentials from `~/.aws/credentials` or environment variables, this implementation explicitly passes them to keep all device secrets centralized in `my_secrets.py`.
123136

124137
### Additional Resources
125138

src/ac_training_lab/a1_cam/my_secrets_example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
CAMERA_WRITE_TOPIC = f"bambu_a1_mini/response/{DEVICE_SERIAL}"
88
BUCKET_NAME = "your-bucket-name"
99
AWS_REGION = "your-region"
10+
AWS_ACCESS_KEY_ID = "your-aws-access-key-id"
11+
AWS_SECRET_ACCESS_KEY = "your-aws-secret-access-key"

0 commit comments

Comments
 (0)