Skip to content

Latest commit

 

History

History
389 lines (248 loc) · 12.6 KB

API.md

File metadata and controls

389 lines (248 loc) · 12.6 KB

Apache 2.0 License Gitpod ready-to-code npm version PyPI version Build badge Release badge

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 module. You can avoid running cdktf get as pre-synth step.

This project uses projen and 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.

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.

API Reference

Constructs

GKEAuth

  • Implements: cdktf.ITerraformDependable

Initializers

import { GKEAuth } from 'cdktf-gke-auth'

new GKEAuth(scope: Construct, id: string, props: ClusterInfo)
Name Type Description
scope constructs.Construct No description.
id string No description.
props ClusterInfo No description.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: string

propsRequired

Methods

Name Description
toString Returns a string representation of this construct.

toString
public toString(): string

Returns a string representation of this construct.

Static Functions

Name Description
isConstruct Checks if x is a construct.

isConstruct
import { GKEAuth } from 'cdktf-gke-auth'

GKEAuth.isConstruct(x: any)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
authCredentials AuthCredentials No description.
clientConfig @cdktf/provider-google.dataGoogleClientConfig.DataGoogleClientConfig No description.
clusterCaCertificate string No description.
clusterCaCertificatePEM string No description.
clusterInfo @cdktf/provider-google.dataGoogleContainerCluster.DataGoogleContainerCluster No description.
context string No description.
fqn string No description.
host string No description.
kubeConfigRaw string No description.
token string No description.

nodeRequired
public readonly node: Node;
  • Type: constructs.Node

The tree node.


authCredentialsRequired
public readonly authCredentials: AuthCredentials;

clientConfigRequired
public readonly clientConfig: DataGoogleClientConfig;
  • Type: @cdktf/provider-google.dataGoogleClientConfig.DataGoogleClientConfig

clusterCaCertificateRequired
public readonly clusterCaCertificate: string;
  • Type: string

clusterCaCertificatePEMRequired
public readonly clusterCaCertificatePEM: string;
  • Type: string

clusterInfoRequired
public readonly clusterInfo: DataGoogleContainerCluster;
  • Type: @cdktf/provider-google.dataGoogleContainerCluster.DataGoogleContainerCluster

contextRequired
public readonly context: string;
  • Type: string

fqnRequired
public readonly fqn: string;
  • Type: string

hostRequired
public readonly host: string;
  • Type: string

kubeConfigRawRequired
public readonly kubeConfigRaw: string;
  • Type: string

tokenRequired
public readonly token: string;
  • Type: string

Structs

AuthCredentials

Initializer

import { AuthCredentials } from 'cdktf-gke-auth'

const authCredentials: AuthCredentials = { ... }

Properties

Name Type Description
clusterCaCertificate string No description.
host string No description.
token string No description.

clusterCaCertificateRequired
public readonly clusterCaCertificate: string;
  • Type: string

hostRequired
public readonly host: string;
  • Type: string

tokenRequired
public readonly token: string;
  • Type: string

ClusterInfo

Initializer

import { ClusterInfo } from 'cdktf-gke-auth'

const clusterInfo: ClusterInfo = { ... }

Properties

Name Type Description
clusterName string No description.
location string No description.
projectId string No description.

clusterNameRequired
public readonly clusterName: string;
  • Type: string

locationRequired
public readonly location: string;
  • Type: string

projectIdRequired
public readonly projectId: string;
  • Type: string