https://github.com/01walid/cdktf-gke-auth
A pure CDK for Terraform construct to authenticate against Google Kubernetes Engine (GKE) without the need of any Terraform module
https://github.com/01walid/cdktf-gke-auth
cdk-constructs cdk-for-terraform cdktf gke jsii k8s kubernetes
Last synced: about 1 year ago
JSON representation
A pure CDK for Terraform construct to authenticate against Google Kubernetes Engine (GKE) without the need of any Terraform module
- Host: GitHub
- URL: https://github.com/01walid/cdktf-gke-auth
- Owner: 01walid
- License: apache-2.0
- Created: 2023-06-03T16:29:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-04T13:26:26.000Z (about 3 years ago)
- Last Synced: 2025-03-17T04:05:19.912Z (about 1 year ago)
- Topics: cdk-constructs, cdk-for-terraform, cdktf, gke, jsii, k8s, kubernetes
- Language: TypeScript
- Homepage: https://constructs.dev/packages/cdktf-gke-auth/
- Size: 171 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cdktf-gke-auth
Easily authenticate against a Google Kubernetes Engine (GKE) within your CDK for Terraform stack. Without the need to
resort to [Google's terraform GKE auth](https://github.com/terraform-google-modules/terraform-google-kubernetes-engine/tree/v26.1.1/modules/auth) module. You can avoid running `cdktf get` as pre-synth step.
This project uses [projen](https://github.com/projen/projen) and [jsii](https://github.com/aws/jsii) to compile the construct to Typescript, Python, Go and .Net (Java upon request).
## Example usage (Typescript)
Install the construct with: `yarn install cdktf-gke-auth`.
```ts
import { GoogleProvider } from "@cdktf/provider-google/lib/provider";
import { TerraformOutput, TerraformStack } from "cdktf";
import { Construct } from "constructs";
import { GKEAuth } from 'cdktf-gke-auth';
export class MyKubeStack extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
new GoogleProvider(this, "google-provider", {});
const auth = new GKEAuth(this, "gke-auth", {
clusterName: "my-cluster",
location: "europe-west1",
projectId: "my-project",
});
// init the Kubernetes provider like so:
new KubernetesProvider(this, "kubernetes", {
...auth.authCredentials
});
// Or a helm provider like so:
new HelmProvider(this, "helm", {
kubernetes: auth.authCredentials,
});
}
}
```
The `GKEAuth` instance expose `host`, `clusterCaCertificate`, `clusterCaCertificatePEM`, and `token` you can use to authenticate using
any of the kubernetes popular cdktf providers.
For other languages examples, checkout this construct on [ConstructHub](https://constructs.dev/packages/cdktf-gke-auth/).