provider-terraform: Does not seem to work with IAM roles for service accounts

What happened?

Get the following error:

 Warning  CannotObserveExternalResource  6s (x7 over 103s)     managed/workspace.tf.crossplane.io  cannot diff (i.e. plan) Terraform configuration: error configuring terraform aws provider: no valid credential sources for terraform aws provider found.

How can we reproduce it?

Set the controller config to the following:

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::<account>:role/<rolename>
spec:
  podSecurityContext:
    fsGroup: 2000
  image: crossplane/provider-terraform-controller:v0.2.0
  args: ["-d"]

Can see the annotation however the terraform aws provider does not seem to use it

What environment did it happen in?

Crossplane version: 1.8

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16

Most upvoted comments

I got it working, it turned out to be a condition on the trust policy that wasn’t matching the k8s SA name…

That’s a very common place to find an error.

maybe we should add this to the docs or the examples as it’s normally preferable to run this using a role through injected identity rather than having a secret with the credentials for some IAM user…

Can you push a PR with the updated text?

We should also remove InjectedIdentity from the list of valid options in the CRD since it’s not really supported and we have to use None instead in this scenario…

This is definitely a bug - can you open a new issue for this and we’ll clean it up or if you want to include it in a doc PR that would be fine too.

Thanks!

@luisdavim We put the same type of role annotation on the controllerconfig for terraform so the pod picks up the native AWS ENV and credentials:

apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
  annotations:
    eks.amazonaws.com/role-arn: arn:aws:iam::accountid:role/provider-terraform

which allows the terraform aws provider to use the default set of credentials. Then when we need the aws provider to use a different account we can use the assume_role configuration.