Skip to content

Instantly share code, notes, and snippets.

@jasonforte
Created July 31, 2025 11:41
Show Gist options
  • Select an option

  • Save jasonforte/a723bc0b0424f18919922600d9693157 to your computer and use it in GitHub Desktop.

Select an option

Save jasonforte/a723bc0b0424f18919922600d9693157 to your computer and use it in GitHub Desktop.
Connecting Elixir (Phoenix) to Amazon Aurora DSQL
package main
import (
"context"
"flag"
"fmt"
"log"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/dsql/auth"
)
func main() {
// Define command line flags
hostname := flag.String("hostname", "", "Aurora DSQL hostname")
region := flag.String("region", "", "AWS region")
flag.Parse()
// Validate required arguments
if *hostname == "" {
log.Fatal("hostname is required")
}
if *region == "" {
log.Fatal("region is required")
}
// Load AWS configuration
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(*region))
if err != nil {
log.Fatalf("unable to load SDK config: %v", err)
}
// Generate authentication token
authToken, err := auth.GenerateDbConnectAuthToken(context.Background(), *hostname, *region, cfg.Credentials, func(options *auth.TokenOptions) {})
if err != nil {
log.Fatalf("failed to generate auth token: %v", err)
}
// Output the authentication token
fmt.Print(authToken)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment