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

[Backport release-0.46] Make assume_role_with_web_identity provider configuration value a list #1057

Merged
merged 1 commit into from
Jan 3, 2024
Merged
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
14 changes: 10 additions & 4 deletions internal/clients/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,29 @@ func pushDownTerraformSetupBuilder(ctx context.Context, c client.Client, pc *v1b
if pc.Spec.Credentials.WebIdentity == nil {
return errors.New(`spec.credentials.webIdentity of ProviderConfig cannot be nil when the credential source is "WebIdentity"`)
}
ps.Configuration[keyAssumeRoleWithWebIdentity] = map[string]any{
webIdentityConfig := map[string]any{
keyRoleArn: aws.ToString(pc.Spec.Credentials.WebIdentity.RoleARN),
keyWebIdentityTokenFile: os.Getenv(envWebIdentityTokenFile),
}
if pc.Spec.Credentials.WebIdentity.RoleSessionName != "" {
ps.Configuration[keySessionName] = pc.Spec.Credentials.WebIdentity.RoleSessionName
webIdentityConfig[keySessionName] = pc.Spec.Credentials.WebIdentity.RoleSessionName
}
ps.Configuration[keyAssumeRoleWithWebIdentity] = []any{
webIdentityConfig,
}
case authKeyUpbound:
if pc.Spec.Credentials.Upbound == nil || pc.Spec.Credentials.Upbound.WebIdentity == nil {
return errors.New(`spec.credentials.upbound.webIdentity of ProviderConfig cannot be nil when the credential source is "Upbound"`)
}
ps.Configuration[keyAssumeRoleWithWebIdentity] = map[string]any{
webIdentityConfig := map[string]any{
keyRoleArn: aws.ToString(pc.Spec.Credentials.Upbound.WebIdentity.RoleARN),
keyWebIdentityTokenFile: upboundProviderIdentityTokenFile,
}
if pc.Spec.Credentials.Upbound.WebIdentity.RoleSessionName != "" {
ps.Configuration[keySessionName] = pc.Spec.Credentials.Upbound.WebIdentity.RoleSessionName
webIdentityConfig[keySessionName] = pc.Spec.Credentials.Upbound.WebIdentity.RoleSessionName
}
ps.Configuration[keyAssumeRoleWithWebIdentity] = []any{
webIdentityConfig,
}
case authKeySecret:
data, err := resource.CommonCredentialExtractor(ctx, s, c, pc.Spec.Credentials.CommonCredentialSelectors)
Expand Down
Loading