Installing a GCP connector on GKE using Terraform Create a connector on Google Kubernetes Engine
Connectors are secure on-premises components that link Apono to your resources:
No secrets are read, cached, or stored
No account admin privileges need to be granted to Apono
The connector contacts your secret store or key vault to sync data or provision access
Once set up, this connector will enable you to sync data from cloud applications and grant and revoke access permissions through Google Kubernetes Engine (GKE).
Prerequisites
Account-specific Apono authentication value
Use the following steps to obtain your token:
Click Cloud installation .
Click Cloud installation > GCP > Install and Connect GCP Project > CLI (GKE) .
Copy the token listed on the page in step 1 .
Google Cloud Command Line Interface (Google Cloud CLI)
Information for your Google Cloud instance:
Tag Key-Value Pairs (if used)
Optional :
Install a connector
Use the following sections to install a connector for either your Google Project or Google Organization .
Project
Follow these steps to install an Apono connector for a Google Project:
In your shell environment, log in to Google Cloud with an account possessing Owner permissions.
Copy gcloud auth application-default login
At the shell prompt, set the environment variables.
Copy export TF_VAR_PROJECT_ID = "<GCP_PROJECT_ID>"
export TF_VAR_REGION = "<GCP_REGION>"
export TF_VAR_NAME = "<GKE_CLUSTER_NAME>"
export TF_VAR_LOCATION = "<GCP_CLUSTER_REGION>"
export TF_VAR_APONO_TOKEN = "<APONO_TOKEN>"
export TF_VAR_TAGS = "<{tag1=" value1 "}>"
(Optional) Set the following optional environment variables.
Copy export TF_VAR_CONNECTOR_ID = "<APONO_CONNECTOR_NAME>"
export TF_VAR_SERVICE_ACCOUNT_NAME = "<GCP_SERVICE_ACCOUNT_NAME>"
export TF_VAR_NAMESPACE = "<NAMESPACE>"
In a new or existing Terraform (.tf) file, add the following provider and module information to create a connector.
Copy provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}
At the Terraform CLI, download and install the provider plugin and module.
Apply the Terraform changes. The proposed changes and a confirmation prompt will be listed.
Enter yes to confirm deploying the changes to your Google Project instance.
On the Connectors page, verify that the connector has been deployed.
Organization
Follow these steps to install an Apono connector for a Google Organization:
In your shell environment, log in to Google Cloud with an account possessing Organization Administrator permissions.
Copy gcloud alpha auth application-default login
At the shell prompt, set the environment variables.
Copy export TF_VAR_PROJECT_ID = "<GCP_PROJECT_ID>"
export TF_VAR_REGION = "<GCP_REGION>"
export TF_VAR_NAME = "<GKE_CLUSTER_NAME>"
export TF_VAR_LOCATION = "<GCP_CLUSTER_REGION>"
export TF_VAR_APONO_TOKEN = "<APONO_TOKEN>"
export TF_VAR_ORGANIZATION_ID = "<GCP_ORGANIZATION_ID>"
export TF_VAR_TAGS = "<{tag1=" value1 "}>"
(Optional) Set the following optional environment variables.
Copy export TF_VAR_CONNECTOR_ID = "<APONO_CONNECTOR_NAME>"
export TF_VAR_SERVICE_ACCOUNT_NAME = "<GCP_SERVICE_ACCOUNT_NAME>"
export TF_VAR_NAMESPACE = "<NAMESPACE>"
In a new or existing Terraform (.tf) file, add the following provider and module information to create a connector.
Copy provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
organizationId = "{var.ORGANIZATION_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}
At the Terraform CLI, download and install the provider plugin and module.
Apply the Terraform changes. The proposed changes and a confirmation prompt will be listed.
Enter yes to confirm deploying the changes to your Google Organization instance.
On the Connectors page, verify that the connector has been deployed.
FAQ
Can the Apono Terraform module be pinned to a version? Yes. You can append the version number to the source
location with the ?ref=vX.X.X
query string.
The following examples pin the version to 1.0.0 for a connector without permissions.
Copy provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector?ref=v1.0.0"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}
Pinned Version (Organization)
Copy provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector?ref=v1.0.0"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
organizationId = "{var.ORGANIZATION_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}