cdktfgkeauth

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

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.

Documentation

Overview

cdktf-gke-auth

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GKEAuth_IsConstruct

func GKEAuth_IsConstruct(x interface{}) *bool

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.

Returns: true if `x` is an object created from a class which extends `Construct`.

func NewGKEAuth_Override

func NewGKEAuth_Override(g GKEAuth, scope constructs.Construct, id *string, props *ClusterInfo)

Types

type AuthCredentials

type AuthCredentials struct {
	ClusterCaCertificate *string `field:"required" json:"clusterCaCertificate" yaml:"clusterCaCertificate"`
	Host                 *string `field:"required" json:"host" yaml:"host"`
	Token                *string `field:"required" json:"token" yaml:"token"`
}

type ClusterInfo

type ClusterInfo struct {
	ClusterName *string `field:"required" json:"clusterName" yaml:"clusterName"`
	Location    *string `field:"required" json:"location" yaml:"location"`
	ProjectId   *string `field:"required" json:"projectId" yaml:"projectId"`
}

type GKEAuth

type GKEAuth interface {
	constructs.Construct
	cdktf.ITerraformDependable
	AuthCredentials() *AuthCredentials
	ClientConfig() datagoogleclientconfig.DataGoogleClientConfig
	ClusterCaCertificate() *string
	ClusterCaCertificatePEM() *string
	ClusterInfo() datagooglecontainercluster.DataGoogleContainerCluster
	Context() *string
	Fqn() *string
	Host() *string
	KubeConfigRaw() *string
	// The tree node.
	Node() constructs.Node
	Token() *string
	// Returns a string representation of this construct.
	ToString() *string
}

func NewGKEAuth

func NewGKEAuth(scope constructs.Construct, id *string, props *ClusterInfo) GKEAuth

Directories

Path Synopsis
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.
Package jsii contains the functionaility needed for jsii packages to initialize their dependencies and themselves.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL