Skip to content

Commit e6cbf89

Browse files
authored
feat: Improvements for Auth0 Components (cloudposse/terraform-aws-components#1104)
1 parent f4b8c53 commit e6cbf89

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

src/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ components:
6767
6868
| Name | Source | Version |
6969
|------|--------|---------|
70+
| <a name="module_auth0_ssm_parameters"></a> [auth0\_ssm\_parameters](#module\_auth0\_ssm\_parameters) | cloudposse/ssm-parameter-store/aws | 0.13.0 |
7071
| <a name="module_auth0_tenant"></a> [auth0\_tenant](#module\_auth0\_tenant) | cloudposse/stack-config/yaml//modules/remote-state | 1.5.0 |
7172
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
7273
| <a name="module_iam_roles_auth0_provider"></a> [iam\_roles\_auth0\_provider](#module\_iam\_roles\_auth0\_provider) | ../../account-map/modules/iam-roles | n/a |
@@ -96,6 +97,7 @@ components:
9697
| <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 |
9798
| <a name="input_callbacks"></a> [callbacks](#input\_callbacks) | Allowed Callback URLs | `list(string)` | `[]` | no |
9899
| <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 |
100+
| <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 |
99101
| <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 |
100102
| <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 |
101103
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |

src/provider-auth0-client.tf

+54-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ variable "auth0_tenant_tenant_name" {
2525
default = ""
2626
}
2727

28+
locals {
29+
auth0_tenant_environment_name = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
30+
auth0_tenant_stage_name = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
31+
auth0_tenant_tenant_name = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
32+
}
33+
2834
module "auth0_tenant" {
2935
source = "cloudposse/stack-config/yaml//modules/remote-state"
3036
version = "1.5.0"
@@ -33,9 +39,9 @@ module "auth0_tenant" {
3339

3440
component = var.auth0_tenant_component_name
3541

36-
environment = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
37-
stage = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
38-
tenant = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
42+
environment = local.auth0_tenant_environment_name
43+
stage = local.auth0_tenant_stage_name
44+
tenant = local.auth0_tenant_tenant_name
3945
}
4046

4147
#
@@ -61,9 +67,9 @@ provider "aws" {
6167
module "iam_roles_auth0_provider" {
6268
source = "../../account-map/modules/iam-roles"
6369

64-
environment = length(var.auth0_tenant_environment_name) > 0 ? var.auth0_tenant_environment_name : module.this.environment
65-
stage = length(var.auth0_tenant_stage_name) > 0 ? var.auth0_tenant_stage_name : module.this.stage
66-
tenant = length(var.auth0_tenant_tenant_name) > 0 ? var.auth0_tenant_tenant_name : module.this.tenant
70+
environment = local.auth0_tenant_environment_name
71+
stage = local.auth0_tenant_stage_name
72+
tenant = local.auth0_tenant_tenant_name
6773

6874
context = module.this.context
6975
}
@@ -99,3 +105,45 @@ provider "auth0" {
99105
client_secret = data.aws_ssm_parameter.auth0_client_secret.value
100106
debug = var.auth0_debug
101107
}
108+
109+
#
110+
# Finally if enabled, create a duplicate of the AWS SSM parameters for Auth0 in this account.
111+
#
112+
variable "create_auth0_ssm_parameters_enabled" {
113+
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."
114+
type = bool
115+
default = false
116+
}
117+
118+
module "auth0_ssm_parameters" {
119+
source = "cloudposse/ssm-parameter-store/aws"
120+
version = "0.13.0"
121+
122+
enabled = local.enabled && var.create_auth0_ssm_parameters_enabled
123+
124+
parameter_write = [
125+
{
126+
name = module.auth0_tenant[0].outputs.domain_ssm_path
127+
value = data.aws_ssm_parameter.auth0_domain.value
128+
type = "SecureString"
129+
overwrite = "true"
130+
description = "Auth0 domain value for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
131+
},
132+
{
133+
name = module.auth0_tenant[0].outputs.client_id_ssm_path
134+
value = data.aws_ssm_parameter.auth0_client_id.value
135+
type = "SecureString"
136+
overwrite = "true"
137+
description = "Auth0 client ID for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
138+
},
139+
{
140+
name = module.auth0_tenant[0].outputs.client_secret_ssm_path
141+
value = data.aws_ssm_parameter.auth0_client_secret.value
142+
type = "SecureString"
143+
overwrite = "true"
144+
description = "Auth0 client secret for the Auth0 ${local.auth0_tenant_tenant_name}-${local.auth0_tenant_environment_name}-${local.auth0_tenant_stage_name} tenant"
145+
},
146+
]
147+
148+
context = module.this.context
149+
}

0 commit comments

Comments
 (0)