feat: add support for AWS RDS IAM authentication and update dependencies #3086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#3016
AWS RDS IAM Authentication Implementation
Add AWS RDS IAM Authentication Support
This PR introduces AWS RDS IAM authentication support for PostgreSQL connections, enabling secure database access using AWS IAM credentials instead of traditional username/password authentication.
Changes Made
New AWS IAM Utilities (
util/aws_iam.go
)Added
GetRDSAuthToken
function: Generates AWS RDS authentication tokens using IAM credentialsAdded
ExtractHostPort
utility function: Parses host:port strings with PostgreSQL fallbackDatabase Configuration Enhancements (
util/config.go
)Added PostgreSQL IAM configuration fields:
PostgresIAM
(bool): Enables/disables IAM authentication modePostgresIAMRegion
(string): Specifies AWS region for RDS authenticationEnhanced
GetConnectionString
method:PostgresIAM
is enabledDatabase Connection Management (
db/sql/SqlDb.go
)Added connection lifecycle management for IAM:
ConnMaxLifetime
to 14 minutes for IAM-authenticated connectionsTechnical Implementation Details
aws-sdk-go-v2
with modern credential providersEnvironment Variables
SEMAPHORE_DB_POSTGRES_IAM
: Enable IAM authentication (boolean)SEMAPHORE_DB_POSTGRES_IAM_REGION
: AWS region for RDS instance (string)Benefits
Usage Example
Debugging and Logging
The implementation includes comprehensive debug logging:
Error Handling
Robust error handling for common scenarios:
This implementation provides a secure foundation for AWS RDS integration while maintaining full backward compatibility with existing password-based configurations.