Skip to content

Latest commit

 

History

History
190 lines (156 loc) · 3.68 KB

kubernetes_service_account.md

File metadata and controls

190 lines (156 loc) · 3.68 KB

kubernetes_service_account

back

Index

Terraform

terraform {
  required_providers {
    kubernetes = ">= 2.0.3"
  }
}

top

Example Usage

module "kubernetes_service_account" {
  source = "./modules/kubernetes/r/kubernetes_service_account"

  # automount_service_account_token - (optional) is a type of bool
  automount_service_account_token = null

  image_pull_secret = [{
    name = null
  }]

  metadata = [{
    annotations      = {}
    generate_name    = null
    generation       = null
    labels           = {}
    name             = null
    namespace        = null
    resource_version = null
    self_link        = null
    uid              = null
  }]

  secret = [{
    name = null
  }]

  timeouts = [{
    create = null
  }]
}

top

Variables

variable "automount_service_account_token" {
  description = "(optional) - Enable automatic mounting of the service account token"
  type        = bool
  default     = null
}

variable "image_pull_secret" {
  description = "nested block: NestingSet, min items: 0, max items: 0"
  type = set(object(
    {
      name = string
    }
  ))
  default = []
}

variable "metadata" {
  description = "nested block: NestingList, min items: 1, max items: 1"
  type = set(object(
    {
      annotations      = map(string)
      generate_name    = string
      generation       = number
      labels           = map(string)
      name             = string
      namespace        = string
      resource_version = string
      self_link        = string
      uid              = string
    }
  ))
}

variable "secret" {
  description = "nested block: NestingSet, min items: 0, max items: 0"
  type = set(object(
    {
      name = string
    }
  ))
  default = []
}

variable "timeouts" {
  description = "nested block: NestingSingle, min items: 0, max items: 0"
  type = set(object(
    {
      create = string
    }
  ))
  default = []
}

top

Resource

resource "kubernetes_service_account" "this" {
  # automount_service_account_token - (optional) is a type of bool
  automount_service_account_token = var.automount_service_account_token

  dynamic "image_pull_secret" {
    for_each = var.image_pull_secret
    content {
      # name - (optional) is a type of string
      name = image_pull_secret.value["name"]
    }
  }

  dynamic "metadata" {
    for_each = var.metadata
    content {
      # annotations - (optional) is a type of map of string
      annotations = metadata.value["annotations"]
      # generate_name - (optional) is a type of string
      generate_name = metadata.value["generate_name"]
      # labels - (optional) is a type of map of string
      labels = metadata.value["labels"]
      # name - (optional) is a type of string
      name = metadata.value["name"]
      # namespace - (optional) is a type of string
      namespace = metadata.value["namespace"]
    }
  }

  dynamic "secret" {
    for_each = var.secret
    content {
      # name - (optional) is a type of string
      name = secret.value["name"]
    }
  }

  dynamic "timeouts" {
    for_each = var.timeouts
    content {
      # create - (optional) is a type of string
      create = timeouts.value["create"]
    }
  }

}

top

Outputs

output "default_secret_name" {
  description = "returns a string"
  value       = kubernetes_service_account.this.default_secret_name
}

output "id" {
  description = "returns a string"
  value       = kubernetes_service_account.this.id
}

output "this" {
  value = kubernetes_service_account.this
}

top