Skip to content

Commit 26a4375

Browse files
committed
docs(m365): improve variable descriptions for input/output storage container urls
update tf_vars_to_adoc to support version 8+ of hcl2 library
1 parent 9af5aa2 commit 26a4375

5 files changed

Lines changed: 57 additions & 22 deletions

File tree

m365/README.adoc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,21 @@ Optional::
9797
Advanced::
9898
`create_app` (bool) [default=True]::: If true, the app will be created. If false, the app will be imported
9999
`prefix_override` (string) [default=None]::: Prefix for resource names. If null, one will be generated from app_name
100-
`input_storage_container_url` (string) [default=None]::: If not null, input container to read configs from (must give permissions to service account). Otherwise by default will create storage container. Expect an https url pointing to a container
101-
`output_storage_container_url` (string) [default=None]::: If not null, output container to put results in (must give permissions to service account or use SAS). Otherwise by default will create storage container. Expect an https url pointing to a container
100+
`input_storage_container_url` (string) [default=None]::: If not null, input container to read configs from (must assign blob reader role role to service account `sp_object_id` manually).
101+
Otherwise by default will create storage container.
102+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
103+
Note that the container must have "adhoc" and "scheduled" directories. These are not created automatically in this case
104+
`output_storage_container_url` (string) [default=None]::: If not null, output container to put results in (must give permissions to service account `sp_object_id` or use SAS).
105+
Otherwise by default will create storage container.
106+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
102107
`output_storage_container_sas` (string) [default=None]::: If not null, shared access signature token (query string) to use when writing results to the output storage container. Set this when the container is in an external tenant (the owner of that container will provide the value).
103108
`tenants_dir_path` (string) [default=./tenants]::: Relative path to directory containing tenant configuration files in yaml
104109
`container_registry` (object) [default=None]::: Credentials for logging into registry with container image
105110
`container_image` (string) [default=ghcr.io/cisagov/scubaconnect-m365:latest]::: Docker image to use for running ScubaGear.
106111
`container_memory_gb` (number) [default=3]::: Amount of memory to allocate for ScubaGear container. Due to memory leaks in some dependencies, this may need to be increased if running on many tenants
107112
`secondary_app_info` (object) [default=None]::: Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
108-
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
109-
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
113+
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
114+
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
110115

111116
[#onboard]
112117
=== Onboarding a Tenant

m365/terraform/env/example/variables.tf

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,22 @@ variable "prefix_override" {
102102
variable "input_storage_container_url" {
103103
default = null
104104
type = string
105-
description = "If not null, input container to read configs from (must give permissions to service account). Otherwise by default will create storage container. Expect an https url pointing to a container"
105+
description = <<-EOT
106+
If not null, input container to read configs from (must assign blob reader role role to service account `sp_object_id` manually).
107+
Otherwise by default will create storage container.
108+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
109+
Note that the container must have "adhoc" and "scheduled" directories. These are not created automatically in this case
110+
EOT
106111
}
107112

108113
variable "output_storage_container_url" {
109114
default = null
110115
type = string
111-
description = "If not null, output container to put results in (must give permissions to service account or use SAS). Otherwise by default will create storage container. Expect an https url pointing to a container"
116+
description = <<-EOT
117+
If not null, output container to put results in (must give permissions to service account `sp_object_id` or use SAS).
118+
Otherwise by default will create storage container.
119+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
120+
EOT
112121
}
113122

114123
variable "output_storage_container_sas" {
@@ -151,11 +160,11 @@ variable "container_memory_gb" {
151160
}
152161

153162
variable "secondary_app_info" {
154-
description = <<EOF
163+
description = <<-EOT
155164
Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
156165
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
157166
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
158-
EOF
167+
EOT
159168
type = object({
160169
app_id = string
161170
environment_to_use = string
@@ -165,4 +174,4 @@ variable "secondary_app_info" {
165174
condition = var.secondary_app_info == null ? true : contains(["commercial", "gcchigh"], var.secondary_app_info.environment_to_use)
166175
error_message = "Valid values for create_mode are (Default, PointInTimeRestore, Replica)"
167176
}
168-
}
177+
}

m365/terraform/modules/container/variables.tf

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,22 @@ variable "schedule_interval" {
2525
variable "input_storage_container_url" {
2626
default = null
2727
type = string
28-
description = "If not null, input container to read configs from (must give permissions to service account). Otherwise by default will create storage container. Expect an https url pointing to a container"
28+
description = <<-EOT
29+
If not null, input container to read configs from (must assign blob reader role role to service account `sp_object_id` manually).
30+
Otherwise by default will create storage container.
31+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
32+
Note that the container must have "adhoc" and "scheduled" directories. These are not created automatically in this case
33+
EOT
2934
}
3035

3136
variable "output_storage_container_url" {
3237
default = null
3338
type = string
34-
description = "If not null, output container to put results in (must give permissions to service account or use SAS). Otherwise by default will create storage container. Expect an https url pointing to a container"
39+
description = <<-EOT
40+
If not null, output container to put results in (must give permissions to service account `sp_object_id` or use SAS).
41+
Otherwise by default will create storage container.
42+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
43+
EOT
3544
}
3645

3746
variable "output_storage_container_sas" {
@@ -123,11 +132,11 @@ variable "cert_info" {
123132
}
124133

125134
variable "secondary_app_info" {
126-
description = <<EOF
135+
description = <<-EOT
127136
Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
128137
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
129138
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
130-
EOF
139+
EOT
131140
type = object({
132141
app_id = string
133142
environment_to_use = string

m365/terraform/variables.tf

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,22 @@ variable "prefix_override" {
102102
variable "input_storage_container_url" {
103103
default = null
104104
type = string
105-
description = "If not null, input container to read configs from (must give permissions to service account). Otherwise by default will create storage container. Expect an https url pointing to a container"
105+
description = <<-EOT
106+
If not null, input container to read configs from (must assign blob reader role role to service account `sp_object_id` manually).
107+
Otherwise by default will create storage container.
108+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
109+
Note that the container must have "adhoc" and "scheduled" directories. These are not created automatically in this case
110+
EOT
106111
}
107112

108113
variable "output_storage_container_url" {
109114
default = null
110115
type = string
111-
description = "If not null, output container to put results in (must give permissions to service account or use SAS). Otherwise by default will create storage container. Expect an https url pointing to a container"
116+
description = <<-EOT
117+
If not null, output container to put results in (must give permissions to service account `sp_object_id` or use SAS).
118+
Otherwise by default will create storage container.
119+
Expect a container URL like: https://<account>.blob.core.windows.net/<container>
120+
EOT
112121
}
113122

114123
variable "output_storage_container_sas" {
@@ -151,11 +160,11 @@ variable "container_memory_gb" {
151160
}
152161

153162
variable "secondary_app_info" {
154-
description = <<EOF
163+
description = <<-EOT
155164
Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
156165
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
157166
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
158-
EOF
167+
EOT
159168
type = object({
160169
app_id = string
161170
environment_to_use = string
@@ -165,4 +174,4 @@ variable "secondary_app_info" {
165174
condition = var.secondary_app_info == null ? true : contains(["commercial", "gcchigh"], var.secondary_app_info.environment_to_use)
166175
error_message = "Valid values for create_mode are (Default, PointInTimeRestore, Replica)"
167176
}
168-
}
177+
}

utils/tf_vars_to_adoc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import hcl2
1+
import hcl2 # written for version 8+
2+
from hcl2 import SerializationOptions
23
import argparse
34
import re
5+
import codecs
46

7+
hcl_opts = SerializationOptions(strip_string_quotes=True, preserve_heredocs=False)
58
COMMENT_HEADER_REGEX = r'###\s*(.*?)\s*#*\s*variable\s*"(.*)"'
69

710
parser = argparse.ArgumentParser("Converts a variables.tf file to an asciidoc description list. Treats comment blocks starting with ### as section headers")
811
parser.add_argument("variables_tf")
912
args = parser.parse_args()
1013

1114
with open(args.variables_tf, 'r') as f:
12-
d = hcl2.load(f)
15+
d = hcl2.load(f, serialization_options=hcl_opts)
1316
f.seek(0)
1417
text = '\n'.join(f.readlines())
1518
category_matches = re.findall(COMMENT_HEADER_REGEX, text, flags=re.MULTILINE)
@@ -23,5 +26,5 @@
2326
if t.startswith("object"):
2427
t = "object"
2528
default = f"[default={v[name]['default']}]" if "default" in v[name] else ""
26-
desc = v[name]["description"]
27-
print(f"`{name}` ({t}) {default}::: {desc.strip()}")
29+
desc = codecs.decode(v[name]["description"], 'unicode_escape')
30+
print(f"`{name}` ({t}) {default}::: {desc}")

0 commit comments

Comments
 (0)