Major overhaul of the module, upgraded to be compatible with the latest Terraform version
This commit is contained in:
parent
425a63a6a5
commit
bc0fbc4d0f
50
main.tf
50
main.tf
@ -1,24 +1,36 @@
|
|||||||
module "enabled" {
|
locals {
|
||||||
source = "git::git@github.com:webuildyourcloud/terraform-local-boolean.git"
|
email = var.email
|
||||||
value = var.enabled
|
#handle = var.handle
|
||||||
|
name = var.name
|
||||||
|
roles = var.roles
|
||||||
|
#admin = var.admin
|
||||||
}
|
}
|
||||||
|
|
||||||
data "null_data_source" "this" {
|
data "datadog_role" "standard_role" {
|
||||||
count = "module.enabled.value ? length(var.users) : 0"
|
filter = "Datadog Standard Role"
|
||||||
|
|
||||||
inputs {
|
|
||||||
handle = lookup(var.users[count.index], "handle")
|
|
||||||
email = lookup(var.users[count.index], "email", lookup(var.users[count.index], "handle"))
|
|
||||||
name = lookup(var.users[count.index], "name")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "datadog_user" "this" {
|
data "datadog_role" "admin_role" {
|
||||||
count = "module.enabled.value ? length(var.users) : 0"
|
filter = "Datadog Admin Role"
|
||||||
disabled = lookup(var.users[count.index], "disabled", false)
|
|
||||||
email = lookup(var.users[count.index], "email", lookup(var.users[count.index], "handle"))
|
|
||||||
handle = lookup(var.users[count.index], "handle")
|
|
||||||
is_admin = lookup(var.users[count.index], "is_admin", false)
|
|
||||||
name = lookup(var.users[count.index], "name")
|
|
||||||
role = lookup(var.users[count.index], "role", "st")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data "datadog_role" "readonly_role" {
|
||||||
|
filter = "Datadog Read Only Role"
|
||||||
|
}
|
||||||
|
resource "datadog_user" "add_datadog_user" {
|
||||||
|
email = local.email
|
||||||
|
#handle = local.handle
|
||||||
|
name = local.name
|
||||||
|
#admin = local.admin
|
||||||
|
roles = [data.datadog_role.standard_role.id]
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "datadog_user" "add_datadog_admin_user" {
|
||||||
|
email = local.email
|
||||||
|
#handle = local.handle
|
||||||
|
name = local.name
|
||||||
|
#admin = local.admin
|
||||||
|
roles = [data.datadog_role.admin_role.id]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
66
outputs.tf
66
outputs.tf
@ -1,33 +1,33 @@
|
|||||||
output "disabled" {
|
#output "disabled" {
|
||||||
description = "List of user disabled status"
|
# description = "List of user disabled status"
|
||||||
value = compact(concat(datadog_user.this.*.disabled, list("")))
|
# value = compact(concat(datadog_user.this.*.disabled, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "ids" {
|
#output "ids" {
|
||||||
description = "List of user IDs"
|
# description = "List of user IDs"
|
||||||
value = compact(concat(datadog_user.this.*.id, list("")))
|
# value = compact(concat(datadog_user.this.*.id, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "verified" {
|
#output "verified" {
|
||||||
description = "List of user verified status"
|
# description = "List of user verified status"
|
||||||
value = compact(concat(datadog_user.this.*.verified, list("")))
|
# value = compact(concat(datadog_user.this.*.verified, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "emails" {
|
#output "emails" {
|
||||||
description = "List of user emails"
|
# description = "List of user emails"
|
||||||
value = compact(concat(data.null_data_source.this.*.outputs.email, list("")))
|
# value = compact(concat(data.null_data_source.this.*.outputs.email, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "handles" {
|
#output "handles" {
|
||||||
description = "List of user handles"
|
# description = "List of user handles"
|
||||||
value = compact(concat(data.null_data_source.this.*.outputs.handle, list("")))
|
# value = compact(concat(data.null_data_source.this.*.outputs.handle, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "names" {
|
#output "names" {
|
||||||
description = "List of user names"
|
# description = "List of user names"
|
||||||
value = compact(concat(data.null_data_source.this.*.outputs.name, list("")))
|
# value = compact(concat(data.null_data_source.this.*.outputs.name, list("")))
|
||||||
}
|
#}
|
||||||
|
#
|
||||||
output "users" {
|
#output "users" {
|
||||||
value = "var.users"
|
# value = "var.users"
|
||||||
}
|
#}
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
module "datadog-users" {
|
|
||||||
source = "git::git@github.com:webuildyourcloud/terraform-datadog-users.git"
|
|
||||||
|
|
||||||
users = [
|
|
||||||
{
|
|
||||||
name = "user1"
|
|
||||||
handle = "user1@example.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = "admin1"
|
|
||||||
handle = "admin1@example.com"
|
|
||||||
admin = "true"
|
|
||||||
disabled = "false"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = "dis1"
|
|
||||||
handle = "dis1@example.com"
|
|
||||||
email = "disy1@example.com"
|
|
||||||
disabled = "true"
|
|
||||||
role = "ro"
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
variable "enabled" {
|
|
||||||
description = "Set to false to prevent the module from creating anything"
|
|
||||||
default = true
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "users" {
|
|
||||||
description = "List of Datadog user maps to manage"
|
|
||||||
type = list(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "datadog_api_key" {
|
|
||||||
description = "The datadog API key"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "datadog_app_key" {
|
|
||||||
description = "The datadog APP key"
|
|
||||||
type = string
|
|
||||||
}
|
|
||||||
|
|
||||||
#variable "api_url" {
|
|
||||||
# description = "Which API to Connect to, we are using the EU one for GDPR compliance"
|
|
||||||
# type = string
|
|
||||||
# default = "https://api.datadoghq.eu"
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "http_client_retry_enabled" {
|
|
||||||
# description = "Enables Request retries on HTTP status codes 429 and 5xx"
|
|
||||||
# type = bool
|
|
||||||
# default = true
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "http_client_retry_timeout" {
|
|
||||||
# description = "Sets the number of HTTP request retry timeout period"
|
|
||||||
# type = string
|
|
||||||
# default = ""
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "validate" {
|
|
||||||
# description = "Validates the provided APP and API keys during provider initialization"
|
|
||||||
# type = bool
|
|
||||||
# default = true
|
|
||||||
#}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 0.13"
|
|
||||||
}
|
|
||||||
86
variables.tf
86
variables.tf
@ -1,33 +1,43 @@
|
|||||||
variable "enabled" {
|
variable "admin" {
|
||||||
description = "Set to false to prevent the module from creating anything"
|
description = "Boolean to set if user is an admin or not"
|
||||||
default = true
|
default = false
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "users" {
|
variable "name" {
|
||||||
description = "List of Datadog user maps to manage"
|
description = "Name of the User"
|
||||||
type = list(string)
|
type = string
|
||||||
|
default = ""
|
||||||
# users = [
|
|
||||||
# {
|
|
||||||
# name = "user1"
|
|
||||||
# handle = "user1@example.com"
|
|
||||||
# },
|
|
||||||
# {
|
|
||||||
# name = "admin1"
|
|
||||||
# handle = "admin1@example.com"
|
|
||||||
# admin = "true"
|
|
||||||
# disabled = "false"
|
|
||||||
# },
|
|
||||||
# {
|
|
||||||
# name = "dis1"
|
|
||||||
# handle = "dis1@example.com"
|
|
||||||
# email = "disy1@example.com"
|
|
||||||
# disabled = "true"
|
|
||||||
# role = "ro"
|
|
||||||
# },
|
|
||||||
# ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "email" {
|
||||||
|
description = "Email address of the user"
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "handle" {
|
||||||
|
description = "Handle of the user (usualy the email address)"
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "roles" {
|
||||||
|
description = "Role can be ro normal and admin, default is normal"
|
||||||
|
type = string
|
||||||
|
default = "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
#variable "user" {
|
||||||
|
# description = "List of Datadog user maps to manage"
|
||||||
|
# type = map(string)
|
||||||
|
# default = {
|
||||||
|
# name = ""
|
||||||
|
# email = ""
|
||||||
|
# hanlde = ""
|
||||||
|
# role = ""
|
||||||
|
# }
|
||||||
|
#}
|
||||||
|
|
||||||
variable "datadog_api_key" {
|
variable "datadog_api_key" {
|
||||||
description = "The datadog API key"
|
description = "The datadog API key"
|
||||||
type = string
|
type = string
|
||||||
@ -37,27 +47,3 @@ variable "datadog_app_key" {
|
|||||||
description = "The datadog APP key"
|
description = "The datadog APP key"
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
#variable "api_url" {
|
|
||||||
# description = "Which API to Connect to, we are using the EU one for GDPR compliance"
|
|
||||||
# type = string
|
|
||||||
# default = "https://api.datadoghq.eu"
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "http_client_retry_enabled" {
|
|
||||||
# description = "Enables Request retries on HTTP status codes 429 and 5xx"
|
|
||||||
# type = bool
|
|
||||||
# default = true
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "http_client_retry_timeout" {
|
|
||||||
# description = "Sets the number of HTTP request retry timeout period"
|
|
||||||
# type = string
|
|
||||||
# default = ""
|
|
||||||
#}
|
|
||||||
#
|
|
||||||
#variable "validate" {
|
|
||||||
# description = "Validates the provided APP and API keys during provider initialization"
|
|
||||||
# type = bool
|
|
||||||
# default = true
|
|
||||||
#}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user