Skip to content

Commit

Permalink
Merge pull request #78 from luisdavim/injected_identity
Browse files Browse the repository at this point in the history
Injected identity
  • Loading branch information
ytsarev authored Aug 3, 2022
2 parents 7ff0753 + 2e5a3ee commit 6770cb8
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ kubectl apply -f examples/install.yaml

Notice that in this example Provider resource is referencing ControllerConfig with debug enabled.

You can also setup the Terraform Provider using AWS
[IAM Roles for Service Accounts (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html).
For more information, check out the example [setup](./examples/aws-eks-irsa-seup.yaml), the process is
similar to what you would use for the
[provider-aws](https://github.com/crossplane-contrib/provider-aws/blob/master/AUTHENTICATION.md#using-iam-roles-for-serviceaccounts).

## Private Git repository support

To securely propagate git credentials create a `git-credentials` secret in [git credentials store] format.
Expand Down
2 changes: 1 addition & 1 deletion apis/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type ProviderCredentials struct {
Filename string `json:"filename"`

// Source of the provider credentials.
// +kubebuilder:validation:Enum=None;Secret;InjectedIdentity;Environment;Filesystem
// +kubebuilder:validation:Enum=None;Secret;Environment;Filesystem
Source xpv1.CredentialsSource `json:"source"`

xpv1.CommonCredentialSelectors `json:",inline"`
Expand Down
66 changes: 66 additions & 0 deletions examples/aws-eks-irsa-seup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# NOTE: You need a trust policy associated with the role matching the Service Account and OIDC provider
# Something like the following:
# {
# "Version": "2012-10-17",
# "Statement": [
# {
# "Effect": "Allow",
# "Principal": {
# "Federated": "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/${OIDC_PROVIDER}"
# },
# "Action": "sts:AssumeRoleWithWebIdentity",
# "Condition": {
# "StringLike": {
# "${OIDC_PROVIDER}:sub": "system:serviceaccount:${SERVICE_ACCOUNT_NAMESPACE}:provider-terraform-*"
# }
# }
# }
# ]
# }
#
# Where:
# OIDC_PROVIDER=$(aws eks describe-cluster --name "${CLUSTER_NAME}" --region "${AWS_REGION}" --query "cluster.identity.oidc.issuer" --output text | sed -e "s/^https:\/\///")
---
apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
name: terraform-config
labels:
app: crossplane-provider-terraform
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::ACCOUNTID:role/provider-terraform
spec:
image: crossplane/provider-terraform-controller:v0.2.0
args:
- "--debug"
podSecurityContext:
fsGroup: 2000
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: crossplane-provider-terraform
spec:
package: crossplane/provider-terraform:v0.2.0
controllerConfigRef:
name: terraform-config
---
apiVersion: tf.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
annotations: {}
name: aws-irsa
spec:
configuration: |
terraform {
backend "kubernetes" {
secret_suffix = "providerconfig-tf-aws"
namespace = "crossplane-system"
in_cluster_config = true
}
}
provider "aws" {}
credentials:
# Terraform natively supports IRSA auth so we can use None here
- filename: aws.json
source: None
1 change: 0 additions & 1 deletion package/crds/tf.crossplane.io_providerconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ spec:
enum:
- None
- Secret
- InjectedIdentity
- Environment
- Filesystem
type: string
Expand Down

0 comments on commit 6770cb8

Please sign in to comment.