Skip to content

Conversation

@siwachabhi
Copy link
Contributor

Description

The ExpectedBucketOwner parameter is not supported by the S3 create_bucket API call. It is only valid for operations on existing buckets (like put_bucket_lifecycle_configuration, head_bucket, etc).

This fix removes the unsupported parameter from both us-east-1 and regional bucket creation calls, resolving API errors during bucket creation.

Fixes #330
Related to PR #331

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Changes Made

Source Code (src/bedrock_agentcore_starter_toolkit/services/s3.py)

  • Removed ExpectedBucketOwner parameter from create_bucket() call for us-east-1 region
  • Removed ExpectedBucketOwner parameter from create_bucket() call for other regions
  • Kept ExpectedBucketOwner in put_bucket_lifecycle_configuration() where it is valid

Tests (tests/services/test_s3.py)

  • Updated test_create_bucket_us_east_1 assertion to match corrected API call
  • Updated test_create_bucket_other_region assertion to match corrected API call

Testing

  • Unit tests pass locally (15/15 S3 tests passing)
  • Integration tests pass (66/66 related tests passing)
  • Test coverage remains above 90%
  • Manual testing completed

Test Results

tests/services/test_s3.py::TestCreateS3Bucket::test_create_bucket_us_east_1 PASSED
tests/services/test_s3.py::TestCreateS3Bucket::test_create_bucket_other_region PASSED
All 15 S3 service tests passing
All 66 related tests (S3, CodeBuild, launch operations) passing

Checklist

  • My code follows the project's style guidelines (ruff/pre-commit)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Security Checklist

  • No hardcoded secrets or credentials
  • No new security warnings from bandit
  • Dependencies are from trusted sources
  • No sensitive data logged

Breaking Changes

None. This is a bug fix that corrects API usage to match AWS S3 API specifications.

Additional Notes

The ExpectedBucketOwner parameter is documented in the AWS S3 API as only being valid for operations on existing buckets, not bucket creation. This fix aligns the code with the official API specification.

AWS S3 API Reference:

The ExpectedBucketOwner parameter is not supported by the S3 create_bucket
API call. It is only valid for operations on existing buckets.

This fix removes the parameter from both us-east-1 and regional bucket
creation calls, resolving API errors during bucket creation.

Changes:
- Removed ExpectedBucketOwner from create_bucket() calls in s3.py
- Updated test assertions to match corrected API calls

Fixes #330
Related to PR #331

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Adi0987 Adi0987 merged commit 0c57292 into main Nov 6, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] agentcore launch fails after attempting to create an S3 bucket

2 participants