@@ -95,6 +95,7 @@ type KopsControlPlaneReconciler struct {
9595 Recorder record.EventRecorder
9696 TfExecPath string
9797 DryRun bool
98+ AWSProviderVersion string
9899 GetKopsClientSetFactory func (configBase string ) (simple.Clientset , error )
99100 BuildCloudFactory func (* kopsapi.Cluster ) (fi.Cloud , error )
100101 PopulateClusterSpecFactory func (ctx context.Context , kopsCluster * kopsapi.Cluster , kopsClientset simple.Clientset , cloud fi.Cloud ) (* kopsapi.Cluster , error )
@@ -748,7 +749,12 @@ func (r *KopsControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
748749 }
749750
750751 // This is needed because this is normally created, but when deleting we don't create the kops resources files
751- err = utils .CreateTerraformFilesFromTemplate ("templates/provider.tf.tpl" , "provider.tf" , terraformOutputDir , nil )
752+ providerData := struct {
753+ Version string
754+ }{
755+ Version : r .AWSProviderVersion ,
756+ }
757+ err = utils .CreateTerraformFilesFromTemplate ("templates/provider.tf.tpl" , "provider.tf" , terraformOutputDir , providerData )
752758 if err != nil {
753759 return resultError , err
754760 }
@@ -939,6 +945,13 @@ func (r *KopsControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
939945 return resultError , err
940946 }
941947
948+ if r .AWSProviderVersion != "" {
949+ err = utils .CreateTerraformFilesFromTemplate ("templates/versions.tf.tpl" , "versions.tf" , terraformOutputDir , r .AWSProviderVersion )
950+ if err != nil {
951+ return resultError , err
952+ }
953+ }
954+
942955 // Only Apply resources if DryRun isn't set from command line
943956 if r .DryRun {
944957 reconciler .log .Info (fmt .Sprintf ("planning Terraform for %s" , kopsControlPlane .ObjectMeta .GetName ()))
0 commit comments