Skip to content
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

Enable IRSA Mode for Kubernetes Deployments #98

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Instance struct {
DisableBasicMetrics bool `yaml:"disable_basic_metrics"`
DisableEnhancedMetrics bool `yaml:"disable_enhanced_metrics"`
Labels map[string]string `yaml:"labels"` // may be empty
IRSAEnabled bool `yaml:"irsa_enabled"`

// TODO Type InstanceType `yaml:"type"` // may be empty for old pmm-managed
}
Expand Down
15 changes: 15 additions & 0 deletions sessions/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,21 @@ func (s *Sessions) GetSession(region, instance string) (*session.Session, *Insta
}

func buildCredentials(instance config.Instance) (*credentials.Credentials, error) {
// If IRSA is enabled, let the AWS SDK use the default credential provider chain,
// which includes the service account role credentials.
if instance.IRSAEnabled {
// Create a new session with just the region set, no credentials provided explicitly.
// This allows the SDK to use the credentials mounted by IRSA.
stsSession, err := session.NewSession(&aws.Config{
Region: aws.String(instance.Region),
})
if err != nil {
return nil, err
}

return stsSession.Config.Credentials, nil
}

if instance.AWSRoleArn != "" {
stsSession, err := session.NewSession(&aws.Config{
Region: aws.String(instance.Region),
Expand Down
Loading