Sha256: 6011b73d43366169a2c0d5d14e38240b38d4242805d0c3299e9e34203a53d4c7

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module PG
  module AWS_RDS_IAM
    # Generates short-lived authentication tokens for connecting to Amazon RDS instances.
    #
    # @see https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
    class AuthTokenGenerator
      # Creates a new authentication token generator.
      #
      # @param credentials [Aws::CredentialProvider] the IAM credentials with which to sign the token
      # @param region [String] the AWS region in which the RDS instances are running
      def initialize(credentials:, region:)
        @generator = Aws::RDS::AuthTokenGenerator.new(credentials: credentials)
        @region = region
      end

      # Generates an authentication token for connecting to an Amazon RDS instance.
      #
      # @param host [String] the host name of the RDS instance that you want to access
      # @param port [String] the port number used for connecting to your RDS instance
      # @param user [String] the database account that you want to access
      # @return [String] the generated authentication token
      def call(host:, port:, user:)
        @generator.auth_token(region: @region, endpoint: "#{host}:#{port}", user_name: user)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pg-aws_rds_iam-0.5.0 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.4.2 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.4.1 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.4.0 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.3.2 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.3.1 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.3.0 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.2.0 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.1.1 lib/pg/aws_rds_iam/auth_token_generator.rb
pg-aws_rds_iam-0.1.0 lib/pg/aws_rds_iam/auth_token_generator.rb