-
Notifications
You must be signed in to change notification settings - Fork 55
Add region to CLI arguments #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3058d7a
273a37e
075a918
89debe0
3e6f243
bcf3939
a916495
284724f
8340aa0
6bb0c5f
8e60bf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |
| import boto3 | ||
| import httpx | ||
| import logging | ||
| import os | ||
| from botocore.auth import SigV4Auth | ||
| from botocore.awsrequest import AWSRequest | ||
| from botocore.credentials import Credentials | ||
|
|
@@ -150,15 +149,13 @@ def create_aws_session(profile: Optional[str] = None) -> boto3.Session: | |
| return session | ||
|
|
||
|
|
||
| def create_sigv4_auth( | ||
| service: str, profile: Optional[str] = None, region: Optional[str] = None | ||
| ) -> SigV4HTTPXAuth: | ||
| def create_sigv4_auth(service: str, region: str, profile: Optional[str] = None) -> SigV4HTTPXAuth: | ||
| """Create SigV4 authentication for AWS requests. | ||
|
|
||
| Args: | ||
| service: AWS service name for SigV4 signing | ||
| profile: AWS profile to use (optional) | ||
| region: AWS region (defaults to AWS_REGION env var or us-west-2) | ||
| region: AWS region (defaults to AWS_REGION env var or us-east-1) | ||
|
|
||
| Returns: | ||
| SigV4HTTPXAuth instance | ||
|
|
@@ -170,10 +167,6 @@ def create_sigv4_auth( | |
| session = create_aws_session(profile) | ||
| credentials = session.get_credentials() | ||
|
|
||
| # Get region from parameter, environment variable, or default | ||
| if not region: | ||
| region = os.environ.get('AWS_REGION', 'us-west-2') | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should pass the region here, from the parsed args rather than fetching it again.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a standalone function, it makes sense to check whether region is not set.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the time we create sigv4 auth, region should have been resolved, and |
||
|
|
||
| # Create SigV4Auth with explicit credentials | ||
| sigv4_auth = SigV4HTTPXAuth( | ||
| credentials=credentials, | ||
|
|
@@ -187,8 +180,8 @@ def create_sigv4_auth( | |
|
|
||
| def create_sigv4_client( | ||
| service: str, | ||
| region: str, | ||
| profile: Optional[str] = None, | ||
| region: Optional[str] = None, | ||
| headers: Optional[Dict[str, str]] = None, | ||
| auth: Optional[httpx.Auth] = None, | ||
| **kwargs: Any, | ||
|
|
@@ -198,7 +191,7 @@ def create_sigv4_client( | |
| Args: | ||
| service: AWS service name for SigV4 signing | ||
| profile: AWS profile to use (optional) | ||
| region: AWS region (optional, defaults to AWS_REGION env var or us-west-2) | ||
| region: AWS region (optional, defaults to AWS_REGION env var or us-east-1) | ||
| headers: Headers to include in requests | ||
| auth: Auth parameter (ignored as we provide our own) | ||
| **kwargs: Additional arguments to pass to httpx.AsyncClient | ||
|
|
@@ -225,7 +218,7 @@ def create_sigv4_client( | |
| ) | ||
|
|
||
| # Create SigV4 auth | ||
| sigv4_auth = create_sigv4_auth(service, profile, region) | ||
| sigv4_auth = create_sigv4_auth(service, region, profile) | ||
|
|
||
| # Create the client with SigV4 auth and error handling event hook | ||
| logger.info("Creating httpx.AsyncClient with SigV4 authentication for service '%s'", service) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.