Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions examples/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EXAMPLE FULL USAGE OF THE TERRAFORM-KUBERNETES-CLUSTER-ROLE MODULE
#
# And some more meaningful information.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

module "terraform-kubernetes-cluster-role" {
source = "git@github.com:mineiros-io/terraform-google-service-account.git?ref=v0.1.2"
# All required module arguments

account_id = "service-account-id"


# All optional module arguments set to the default values
display_name = "Service Account"
project = "project id"

service_account_keys_count = 1

# All optional module configuration arguments set to the default values.
# Those are maintained for terraform 0.12 but can still be used in terraform 0.13
# Starting with terraform 0.13 you can additionally make use of module level
# count, for_each and depends_on features.
module_enabled = true
module_depends_on = []
}
#----------------------------------------------------------------------------------------------#------------------------
# SERVICE ACCOUNT KEY OUTPUT
# ----------------------------------------------------------------------------------------------------------------------
output "service_account_key" {
description = "All attributes of the created `google_service_account_key` resource."
value = try(module.terraform-kubernetes-cluster-role.service_account_key, null)
sensitive = true
}
# ----------------------------------------------------------------------------------------------------------------------
# EXAMPLE PROVIDER CONFIGURATION
# ----------------------------------------------------------------------------------------------------------------------

provider "google" {
version = "~> 4.0"
}

#----------------------------------------------------------------------------------------------------------------------
# ENVIRONMENT VARIABLES:
# ----------------------------------------------------------------------------------------------------------------------
# You can provide your credentials via the
# https://cloud.google.com/docs/authentication/application-default-credentials#GAC
# ----------------------------------------------------------------------------------------------------------------------

9 changes: 9 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ resource "google_organization_iam_member" "organization" {

member = "serviceAccount:${google_service_account.service_account[0].email}"
}

resource "google_service_account_key" "key" {
count = var.service_account_keys_count

service_account_id = google_service_account.service_account[0].name
key_algorithm = var.key_algorithm
public_key_type = var.public_key_type
private_key_type = var.private_key_type
}
6 changes: 6 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ output "organization_iam_member" {
description = "All attributes of the created `google_organization_iam_member` resource."
value = try(google_organization_iam_member.organization, null)
}

output "service_account_key" {
description = "All attributes of the created `google_service_account_key` resource."
value = try(google_service_account_key.key, null)
sensitive = true
}
1 change: 0 additions & 1 deletion test/unit-complete/_generated_google.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT
// TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl

variable "gcp_project" {
default = null
Expand Down
11 changes: 11 additions & 0 deletions test/unit-complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,14 @@ module "test2" {
}
]
}


module "test-sa-key" {
source = "../.."

module_enabled = true

account_id = "test-sa-key-${local.random_suffix}"
service_account_keys_count = 1

}
1 change: 0 additions & 1 deletion test/unit-disabled/_generated_google.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT
// TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl

variable "gcp_project" {
default = null
Expand Down
1 change: 0 additions & 1 deletion test/unit-minimal/_generated_google.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT
// TERRAMATE: originated from generate_hcl block on /test/terramate_google.tm.hcl

variable "gcp_project" {
default = null
Expand Down
24 changes: 24 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,30 @@ variable "computed_members_map" {
}
}

variable "service_account_keys_count" {
type = number
description = "(Optional) The number of service account keys to be generated attached to this account."
default = 0
}

variable "key_algorithm" {
type = string
description = "(Optional) The algorithm used to generate the key."
default = "KEY_ALG_RSA_2048"
}

variable "public_key_type" {
type = string
description = "(Optional) The output format of the public key requested."
default = "TYPE_X509_PEM_FILE"
}

variable "private_key_type" {
type = string
description = "(Optional) The output format of the private key."
default = "TYPE_GOOGLE_CREDENTIALS_FILE"
}

# ------------------------------------------------------------------------------
# MODULE CONFIGURATION PARAMETERS
# These variables are used to configure the module.
Expand Down
1 change: 0 additions & 1 deletion versions.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT
// TERRAMATE: originated from generate_hcl block on /terramate.tm.hcl

terraform {
required_version = "~> 1.0, != 1.1.0, != 1.1.1"
Expand Down