Skip to content

Commit

Permalink
Forward the AWS profile to the EKS cluster (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret authored Jul 25, 2024
1 parent 64b8a46 commit 36fff86
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions scenarios/aws/eks/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func Run(ctx *pulumi.Context) error {
windowsNodeRole,
},
ServiceRole: clusterRole,
ProviderCredentialOpts: &eks.KubeconfigOptionsArgs{
ProfileName: pulumi.String(awsEnv.Profile()),
},
}, pulumi.Timeouts(&pulumi.CustomTimeouts{
Create: "30m",
Update: "30m",
Expand All @@ -121,9 +124,16 @@ func Run(ctx *pulumi.Context) error {
return err
}

clusterKubeConfig, err := cluster.GetKubeconfig(ctx, &eks.ClusterGetKubeconfigArgs{
ProfileName: pulumi.String(awsEnv.Profile()),
})
if err != nil {
return err
}

// Building Kubernetes provider
eksKubeProvider, err := kubernetes.NewProvider(awsEnv.Ctx(), awsEnv.Namer.ResourceName("k8s-provider"), &kubernetes.ProviderArgs{
Kubeconfig: cluster.KubeconfigJson,
Kubeconfig: clusterKubeConfig,
EnableServerSideApply: pulumi.BoolPtr(true),
DeleteUnreachable: pulumi.BoolPtr(true),
}, awsEnv.WithProviders(config.ProviderAWS))
Expand All @@ -133,7 +143,7 @@ func Run(ctx *pulumi.Context) error {

// Filling Kubernetes component from EKS cluster
comp.ClusterName = cluster.EksCluster.Name()
comp.KubeConfig = cluster.KubeconfigJson
comp.KubeConfig = clusterKubeConfig
comp.KubeProvider = eksKubeProvider

// Deps for nodes and workloads
Expand Down

0 comments on commit 36fff86

Please sign in to comment.