Skip to content

Commit 3b4db9d

Browse files
authored
add extra variables (#9)
* worklytics_host as a variable * parameterize TODO output * bump version number * suggestion to customerize * more use of host stuff * fix move * update remote example * Update README.md
1 parent 84f3e2a commit 3b4db9d

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ This module creates infra to support exporting data from Worklytics to AWS.
77

88
It is published in the [Terraform Registry](https://registry.terraform.io/modules/Worklytics/worklytics-export/aws/latest).
99

10+
If it does not meet your needs, feel free to directly copy the `main.tf` file into your own Terraform
11+
configuration and adapt it to your requirements.
12+
1013
## Usage
1114

1215
from Terraform registry:
1316
```hcl
1417
module "worklytics-export" {
1518
source = "terraform-aws-worklytics-export"
16-
version = "~> 0.3.0"
19+
version = "~> 0.4.0"
1720
1821
# numeric ID of your Worklytics Tenant SA
1922
worklytics_tenant_id = "123123123123"
@@ -23,7 +26,7 @@ module "worklytics-export" {
2326
via GitHub:
2427
```hcl
2528
module "worklytics-export" {
26-
source = "git::https://github.com/worklytics/terraform-aws-worklytics-export/?ref=v0.3.0"
29+
source = "git::https://github.com/worklytics/terraform-aws-worklytics-export/?ref=v0.4.0"
2730
2831
# numeric ID of your Worklytics Tenant SA
2932
worklytics_tenant_id = "123123123123"
@@ -121,4 +124,4 @@ and [style conventions](https://developer.hashicorp.com/terraform/language/synta
121124

122125
See [examples/basic/](examples/basic/) for a simple example of how to use this module.
123126

124-
127+
(c) 2023 Worklytics, Co

examples/basic-remote/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ terraform {
88

99
module "worklytics_export" {
1010
source = "terraform-aws-worklytics-export"
11-
version = "~> 0.3.0"
11+
version = "~> 0.4.0"
1212

1313
resource_name_prefix = var.resource_name_prefix
1414
worklytics_tenant_id = var.worklytics_tenant_id
15+
worklytics_host = var.worklytics_host
16+
todos_as_outputs = var.todos_as_outputs
17+
todos_as_local_files = var.todos_as_local_files
1518
}
1619

1720
output "worklytics_export_bucket_id" {

main.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,22 @@ locals {
112112
todo_content = <<EOT
113113
# Configure Data Export in Worklytics
114114
115-
1. Ensure you're authenticated with Worklytics. Either sign-in at [https://app.worklytics.co](https://app.worklytics.co)
116-
with your organization's SSO provider *or* request OTP link from your Worklytics support team.
117-
2. Visit `https://app.worklytics.co/analytics/data-export/connect?bucket=${aws_s3_bucket
115+
1. Ensure you're authenticated with Worklytics. Either sign-in at [https://${var.worklytics_host}](https://${var.worklytics_host})
116+
with your organization's SSO provider *or* request OTP link from your Worklytics support.
117+
2. Visit `https://${var.worklytics_host}/analytics/data-export/connect?bucket=${aws_s3_bucket
118118
.worklytics_export.bucket}&roleArn=${aws_iam_role.for_worklytics_tenant.arn}`
119119
3. Review any additional settings (such as the Dataset type you'd like to export) and adjust
120120
values as you see fit, then click "Create Data Export".
121121
122122
Alternatively, you may follow the manual instructions below:
123123
124-
1. Visit [https://app.worklytics.co/analytics/data-export](https://app.worklytics.co/analytics/data-export)
124+
1. Visit [https://${var.worklytics_host}/analytics/data-export](https://${var.worklytics_host}/analytics/data-export)
125125
(or login into Worklytics, and navigate to Manage --> Export Data).
126126
2. Click on the 'Create New Data Export' button in the upper right.
127127
3. Fill in the form with the following values:
128128
- **Data Export Name** - choose a name that will help you identify this export in the future.
129129
- **Data Export Type** - choose the type of data you'd like to export. Check our
130-
[Data Export Documentation](https://app.worklytics.co/docs/data-export) for a complete
130+
[Data Export Documentation](https://${var.worklytics_host}/docs/data-export) for a complete
131131
description of all the available datasets.
132132
- **Data Destination** - choose 'Amazon S3', use `${aws_s3_bucket.worklytics_export.bucket}`
133133
for the **Bucket** field, and `${aws_iam_role.for_worklytics_tenant.arn}` for the **Role ARN**
@@ -137,8 +137,15 @@ EOT
137137
}
138138

139139
resource "local_file" "todo" {
140+
count = var.todos_as_local_files ? 1 : 0
141+
140142
filename = "TODO - configure export in worklytics.md"
141143

142144
content = local.todo_content
143145
}
144146

147+
# moved in 0.4.0
148+
moved {
149+
from = local_file.todo
150+
to = local_file.todo[0]
151+
}

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ output "worklytics_tenant_aws_role" {
1313
}
1414

1515
output "todo_markdown" {
16-
value = local.todo_content
16+
value = var.todos_as_outputs ? local.todo_content : null
1717
description = "Actions that must be performed outside of Terraform (markdown format)."
1818
}

variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,20 @@ variable "enable_aws_s3_bucket_public_access_block" {
2020
default = true
2121
}
2222

23+
variable "worklytics_host" {
24+
type = string
25+
description = "host of worklytics instance where tenant resides. (e.g. app.worklytics.co for prod; but may differ for dev/staging)"
26+
default = "app.worklytics.co"
27+
}
28+
29+
variable "todos_as_outputs" {
30+
type = bool
31+
description = "whether to render TODOs as outputs (former useful if you're using Terraform Cloud/Enterprise, or somewhere else where the filesystem is not readily accessible to you)"
32+
default = false
33+
}
34+
35+
variable "todos_as_local_files" {
36+
type = bool
37+
description = "whether to render TODOs as flat files"
38+
default = true
39+
}

0 commit comments

Comments
 (0)