terranetes-controller icon indicating copy to clipboard operation
terranetes-controller copied to clipboard

Support specifying multiple Providers

Open KashifSaadat opened this issue 2 years ago • 0 comments

Currently a Configuration resource has a provider defined as follows:

apiVersion: terraform.appvia.io/v1alpha1
kind: Configuration
metadata:
  name: <CONFIGURATION-NAME>
spec:
  module: <MODULE-SOURCE>
  providerRef:
    name: <PROVIDER-CRD-NAME>

This has two limitations:

  1. Only one provider can be specified for a Module, which is a problem when a Module requires additional Providers. Either you would have to fork and modify your Module specifying the provider block inside it (bad practice), or separate out resources based on the provider into their own Modules and create each one as an individual Configuration resource (more maintenance effort and introduces complexity where there may be interlinked dependencies).
  2. If a Provider has required configuration (e.g. a url or region), it cannot be provided or overridden within the Configuration Spec. It has to be defined in the Provider resource, which is Clusterwide and so all Configuration resources would use the same spec and can't have variations.

It would be good to have support for these cases, allowing to define a Provider locally, provide configuration to merge into an existing Provider, or prevent modifications in more sensitive cases. For example:

apiVersion: terraform.appvia.io/v1alpha1
kind: Configuration
metadata:
  name: <CONFIGURATION-NAME>
spec:
  module: <MODULE-SOURCE>
  providerRef:
  - name: aws
     configuration:
       tags:
       - ManagedBy: "Terraform"
       - Repository: "https://github.com/appvia/terranetes-controller"
  - name: elasticsearch
     provider: "phillbaker/elasticsearch"
     configuration:
       region: "eu-west-2"

Or if you didn't want to allow developers to modify the configuration of a specific Provider they are referencing:

apiVersion: terraform.appvia.io/v1alpha1
kind: Provider
metadata:
  name: aws
spec:
  allowMergeConfiguration: false
  provider: "aws"
  serviceAccount: "terranetes-executor"
  source: injected

KashifSaadat avatar Dec 20 '22 16:12 KashifSaadat