R/custom_rds.R

Defines functions rds_build_auth_token

rds_build_auth_token <- function(endpoint, region, user, creds = NULL) {
  if (!grepl("^https?://", endpoint)) endpoint <- paste0("https://", endpoint)
  req <- new_http_request("GET", endpoint)
  auth_token_params <- list(
    Action = "connect",
    DBUser = user
  )
  req$url$raw_query <- update_query_string(req$url$raw_query, auth_token_params)

  config <- get_config()
  if (is.null(region)) {
    region <- get_region(config$region)
  }
  if (is.null(creds)) {
    creds <- config$credentials$creds
  } else {
    creds <- populate(creds, tag_annotate(Creds()))
  }
  v4 <- Signer(credentials = Credentials(creds = creds))
  req <- sign_with_body(v4, req, NULL, "rds-db", region, 15 * 60, TRUE, Sys.time())

  url <- build_url(req$url)
  url <- gsub("^https?://", "", url)
  return(url)
}

Try the paws.common package in your browser

Any scripts or data that you put into this service are public.

paws.common documentation built on Nov. 12, 2023, 1:08 a.m.