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

feat(pod-identity): add option for pod-identity #1459

Merged
merged 2 commits into from
Aug 14, 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
2 changes: 1 addition & 1 deletion apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ type Tag struct {
// ProviderCredentials required to authenticate.
type ProviderCredentials struct {
// Source of the provider credentials.
// +kubebuilder:validation:Enum=None;Secret;IRSA;WebIdentity;Upbound
// +kubebuilder:validation:Enum=None;Secret;IRSA;WebIdentity;PodIdentity;Upbound
Source xpv1.CredentialsSource `json:"source"`

// WebIdentity defines the options for assuming an IAM role with a Web Identity.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
#
# SPDX-License-Identifier: CC0-1.0

apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: pod-identity
spec:
credentials:
source: PodIdentity
7 changes: 7 additions & 0 deletions internal/clients/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
// authentication types
authKeyIRSA = "IRSA"
authKeyWebIdentity = "WebIdentity"
authKeyPodIdentity = "PodIdentity"
authKeyUpbound = "Upbound"
// authKeySAML = "SAML"

Expand All @@ -49,6 +50,7 @@ const (
errAWSConfig = "failed to get AWS config"
errAWSConfigIRSA = "failed to get AWS config using IAM Roles for Service Accounts"
errAWSConfigWebIdentity = "failed to get AWS config using web identity token"
errAWSConfigPodIdentity = "failed to get AWS config using pod identity"
errAWSConfigUpbound = "failed to get AWS config using Upbound identity"

upboundProviderIdentityTokenFile = "/var/run/secrets/upbound.io/provider/token"
Expand Down Expand Up @@ -101,6 +103,11 @@ func GetAWSConfigWithoutTracking(ctx context.Context, c client.Client, obj runti
if err != nil {
return nil, errors.Wrap(err, errAWSConfigIRSA)
}
case authKeyPodIdentity:
cfg, err = UseDefault(ctx, region)
if err != nil {
return nil, errors.Wrap(err, errAWSConfigPodIdentity)
}
case authKeyWebIdentity:
cfg, err = UseWebIdentityToken(ctx, region, &pc.Spec, c)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions package/crds/aws.upbound.io_providerconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ spec:
- Secret
- IRSA
- WebIdentity
- PodIdentity
- Upbound
type: string
upbound:
Expand Down
Loading