Skip to content

Commit 915aceb

Browse files
fix: Implement IRSA mode to allow k8s deployments to use mounted service account auth (#98)
1 parent 929f899 commit 915aceb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type Instance struct {
2626
DisableBasicMetrics bool `yaml:"disable_basic_metrics"`
2727
DisableEnhancedMetrics bool `yaml:"disable_enhanced_metrics"`
2828
Labels map[string]string `yaml:"labels"` // may be empty
29+
IRSAEnabled bool `yaml:"irsa_enabled"`
2930

3031
// TODO Type InstanceType `yaml:"type"` // may be empty for old pmm-managed
3132
}

sessions/sessions.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ func (s *Sessions) GetSession(region, instance string) (*session.Session, *Insta
183183
}
184184

185185
func buildCredentials(instance config.Instance) (*credentials.Credentials, error) {
186+
// If IRSA is enabled, let the AWS SDK use the default credential provider chain,
187+
// which includes the service account role credentials.
188+
if instance.IRSAEnabled {
189+
// Create a new session with just the region set, no credentials provided explicitly.
190+
// This allows the SDK to use the credentials mounted by IRSA.
191+
stsSession, err := session.NewSession(&aws.Config{
192+
Region: aws.String(instance.Region),
193+
})
194+
if err != nil {
195+
return nil, err
196+
}
197+
198+
return stsSession.Config.Credentials, nil
199+
}
200+
186201
if instance.AWSRoleArn != "" {
187202
stsSession, err := session.NewSession(&aws.Config{
188203
Region: aws.String(instance.Region),

0 commit comments

Comments
 (0)