Home > database >  Secure the source code in Terraform script
Secure the source code in Terraform script

Time:06-24

I would need suggections to secure the below code in a better way, instead using the User name and password in the code what is the better way of doing it ?

provider "kubernetes" {
    version = "~> 1.11"
    load_config_file = "false"
    host = azurerm_kubernetes_cluster.aks.kube_admin_config.0.host
    username = azurerm_kubernetes_cluster.aks.kube_admin_config.0.username
    password = azurerm_kubernetes_cluster.aks.kube_admin_config.0.password

CodePudding user response:

Thank You YoshiMbele for your suggestion.

The most preffred and convenient would probably be to inject environment variables with the credentials into your CI/CD environment or you can also using Environment Variables

To use this technique, declare variables for the secrets you wish to pass in:

variable.tf

variable "username" {
  description = "The username for the DB master user"
  type        = string
}
variable "password" {
  description = "The password for the DB master user"
  type        = string
}

you can also use different way of passing variable values of terraform like terraform.tfvars and input variable.

For the security purpose would suggest you to use of Azure Key Vault to store the credential.

  • Related