-
Notifications
You must be signed in to change notification settings - Fork 8
Add AWS config loader and update S3 client setup #526
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
Conversation
Introduced awsx/config.go to provide a unified AWS configuration loader supporting both confx and environment variables. Added comprehensive tests in awsx/config_test.go. Updated s3x/s3.go to use AWS SDK v2 config directly in S3 client setup, removing direct access key fields from S3 config.
Eliminated the accessID and accessKey fields from the example.yaml S3 configuration, likely to rely on AWS default credentials or environment configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a unified AWS configuration loader and modernizes S3 client setup by migrating from direct access key fields to AWS SDK v2 configuration patterns.
- Adds a new
awsx/config.go
module that provides centralized AWS configuration loading supporting both confx and environment variables - Updates S3 client setup to accept AWS SDK v2 config directly instead of separate access key fields
- Removes direct access key configuration from S3 config structure
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
awsx/config.go | New AWS configuration loader with support for confx and environment variables |
awsx/config_test.go | Comprehensive test suite for the AWS configuration loader |
s3x/s3.go | Updated S3 client setup to use AWS SDK v2 config parameter |
s3x/example/example.yaml | Removed direct access key fields from example configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Replaces the SetupAWSConfigFactory with a direct SetupAWSConfig function, simplifying the API and removing unnecessary indirection.
Eliminated the unused lifecycle import and updated the SetupAWSConfig function signature to remove the lifecycle parameter, simplifying AWS configuration setup.
Refactored awsx/config.go to eliminate the LoadConfig function and move its logic into SetupAWSConfig. Updated tests in awsx/config_test.go to use SetupAWSConfig instead of LoadConfig for consistency and simplification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
awsx/config.go:1
- The os.Setenv calls modify global environment state without synchronization, which could cause race conditions in concurrent usage. Consider using config.LoadDefaultConfig with config.WithCredentialsProvider to avoid global state modification.
package awsx
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
func SetupAWSConfig(ctx context.Context, conf *Config) (*aws.Config, error) { | ||
// Set environment variables from confx config if provided | ||
if conf.Region != "" { | ||
os.Setenv("AWS_REGION", conf.Region) | ||
} | ||
if conf.AccessKeyID != "" { | ||
os.Setenv("AWS_ACCESS_KEY_ID", conf.AccessKeyID) | ||
} | ||
if conf.SecretAccessKey != "" { | ||
os.Setenv("AWS_SECRET_ACCESS_KEY", conf.SecretAccessKey) | ||
} | ||
if conf.SessionToken != "" { | ||
os.Setenv("AWS_SESSION_TOKEN", conf.SessionToken) | ||
} |
Copilot
AI
Oct 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting credentials in environment variables globally affects the entire process and could expose credentials to other parts of the application. Consider using aws.NewCredentialsCache with credentials.NewStaticCredentialsProvider instead to avoid modifying global environment state.
Copilot uses AI. Check for mistakes.
Introduced awsx/config.go to provide a unified AWS configuration loader supporting both confx and environment variables. Added comprehensive tests in awsx/config_test.go. Updated s3x/s3.go to use AWS SDK v2 config directly in S3 client setup, removing direct access key fields from S3 config.