Skip to content

Commit

Permalink
feat: Improvements for Auth0 Components (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
milldr authored Aug 27, 2024
1 parent f5c5a6f commit e3c4ffd
Show file tree
Hide file tree
Showing 15 changed files with 892 additions and 7 deletions.
2 changes: 2 additions & 0 deletions modules/auth0/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ components:
| Name | Source | Version |
|------|--------|---------|
| <a name="module_auth0_ssm_parameters"></a> [auth0\_ssm\_parameters](#module\_auth0\_ssm\_parameters) | cloudposse/ssm-parameter-store/aws | 0.13.0 |
| <a name="module_auth0_tenant"></a> [auth0\_tenant](#module\_auth0\_tenant) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 |
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
| <a name="module_iam_roles_auth0_provider"></a> [iam\_roles\_auth0\_provider](#module\_iam\_roles\_auth0\_provider) | ../../account-map/modules/iam-roles | n/a |
Expand Down Expand Up @@ -96,6 +97,7 @@ components:
| <a name="input_auth0_tenant_tenant_name"></a> [auth0\_tenant\_tenant\_name](#input\_auth0\_tenant\_tenant\_name) | The name of the tenant where the Auth0 tenant component is deployed. Yes this is a bit redundant, since Auth0 also calls this resource a tenant. Defaults to the tenant of the current stack. | `string` | `""` | no |
| <a name="input_callbacks"></a> [callbacks](#input\_callbacks) | Allowed Callback URLs | `list(string)` | `[]` | no |
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
| <a name="input_create_auth0_ssm_parameters_enabled"></a> [create\_auth0\_ssm\_parameters\_enabled](#input\_create\_auth0\_ssm\_parameters\_enabled) | Whether or not to create a duplicate of the AWS SSM parameter for the Auth0 domain, client ID, and client secret in this account. | `bool` | `false` | no |
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
Expand Down
60 changes: 54 additions & 6 deletions modules/auth0/app/provider-auth0-client.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ variable "auth0_tenant_tenant_name" {
default = ""
}

locals {
auth0_tenant_environment_name = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
auth0_tenant_stage_name = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
auth0_tenant_tenant_name = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
}

module "auth0_tenant" {
source = "cloudposse/stack-config/yaml//modules/remote-state"
version = "1.5.0"
Expand All @@ -33,9 +39,9 @@ module "auth0_tenant" {

component = var.auth0_tenant_component_name

environment = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
stage = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
tenant = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
environment = local.auth0_tenant_environment_name
stage = local.auth0_tenant_stage_name
tenant = local.auth0_tenant_tenant_name
}

#
Expand All @@ -61,9 +67,9 @@ provider "aws" {
module "iam_roles_auth0_provider" {
source = "../../account-map/modules/iam-roles"

environment = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
stage = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
tenant = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
environment = local.auth0_tenant_environment_name
stage = local.auth0_tenant_stage_name
tenant = local.auth0_tenant_tenant_name

context = module.this.context
}
Expand Down Expand Up @@ -99,3 +105,45 @@ provider "auth0" {
client_secret = data.aws_ssm_parameter.auth0_client_secret.value
debug = var.auth0_debug
}

#
# Finally if enabled, create a duplicate of the AWS SSM parameters for Auth0 in this account.
#
variable "create_auth0_ssm_parameters_enabled" {
description = "Whether or not to create a duplicate of the AWS SSM parameter for the Auth0 domain, client ID, and client secret in this account."
type = bool
default = false
}

module "auth0_ssm_parameters" {
source = "cloudposse/ssm-parameter-store/aws"
version = "0.13.0"

enabled = local.enabled && var.create_auth0_ssm_parameters_enabled

parameter_write = [
{
name = module.auth0_tenant[0].outputs.domain_ssm_path
value = data.aws_ssm_parameter.auth0_domain.value
type = "SecureString"
overwrite = "true"
description = "Auth0 domain value for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
},
{
name = module.auth0_tenant[0].outputs.client_id_ssm_path
value = data.aws_ssm_parameter.auth0_client_id.value
type = "SecureString"
overwrite = "true"
description = "Auth0 client ID for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
},
{
name = module.auth0_tenant[0].outputs.client_secret_ssm_path
value = data.aws_ssm_parameter.auth0_client_secret.value
type = "SecureString"
overwrite = "true"
description = "Auth0 client secret for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
},
]

context = module.this.context
}
Loading

0 comments on commit e3c4ffd

Please sign in to comment.