atlas-init 0.4.5__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. atlas_init/__init__.py +1 -1
  2. atlas_init/cli.py +2 -0
  3. atlas_init/cli_cfn/cfn_parameter_finder.py +59 -51
  4. atlas_init/cli_cfn/example.py +8 -16
  5. atlas_init/cli_helper/go.py +6 -10
  6. atlas_init/cli_root/mms_released.py +46 -0
  7. atlas_init/cli_tf/app.py +3 -84
  8. atlas_init/cli_tf/ci_tests.py +493 -0
  9. atlas_init/cli_tf/codegen/__init__.py +0 -0
  10. atlas_init/cli_tf/codegen/models.py +97 -0
  11. atlas_init/cli_tf/codegen/openapi_minimal.py +74 -0
  12. atlas_init/cli_tf/github_logs.py +7 -94
  13. atlas_init/cli_tf/go_test_run.py +385 -132
  14. atlas_init/cli_tf/go_test_summary.py +331 -4
  15. atlas_init/cli_tf/go_test_tf_error.py +380 -0
  16. atlas_init/cli_tf/hcl/modifier.py +14 -12
  17. atlas_init/cli_tf/hcl/modifier2.py +87 -0
  18. atlas_init/cli_tf/mock_tf_log.py +1 -1
  19. atlas_init/cli_tf/{schema_v2_api_parsing.py → openapi.py} +95 -17
  20. atlas_init/cli_tf/schema_v2.py +43 -1
  21. atlas_init/crud/__init__.py +0 -0
  22. atlas_init/crud/mongo_client.py +115 -0
  23. atlas_init/crud/mongo_dao.py +296 -0
  24. atlas_init/crud/mongo_utils.py +239 -0
  25. atlas_init/repos/go_sdk.py +12 -3
  26. atlas_init/repos/path.py +110 -7
  27. atlas_init/settings/config.py +3 -6
  28. atlas_init/settings/env_vars.py +5 -1
  29. atlas_init/settings/interactive2.py +134 -0
  30. atlas_init/tf/.terraform.lock.hcl +59 -59
  31. atlas_init/tf/always.tf +5 -5
  32. atlas_init/tf/main.tf +3 -3
  33. atlas_init/tf/modules/aws_kms/aws_kms.tf +1 -1
  34. atlas_init/tf/modules/aws_s3/provider.tf +2 -1
  35. atlas_init/tf/modules/aws_vpc/provider.tf +2 -1
  36. atlas_init/tf/modules/cfn/cfn.tf +0 -8
  37. atlas_init/tf/modules/cfn/kms.tf +5 -5
  38. atlas_init/tf/modules/cfn/provider.tf +7 -0
  39. atlas_init/tf/modules/cfn/variables.tf +1 -1
  40. atlas_init/tf/modules/cloud_provider/cloud_provider.tf +1 -1
  41. atlas_init/tf/modules/cloud_provider/provider.tf +2 -1
  42. atlas_init/tf/modules/cluster/cluster.tf +31 -31
  43. atlas_init/tf/modules/cluster/provider.tf +2 -1
  44. atlas_init/tf/modules/encryption_at_rest/provider.tf +2 -1
  45. atlas_init/tf/modules/federated_vars/federated_vars.tf +1 -1
  46. atlas_init/tf/modules/federated_vars/provider.tf +2 -1
  47. atlas_init/tf/modules/project_extra/project_extra.tf +1 -10
  48. atlas_init/tf/modules/project_extra/provider.tf +8 -0
  49. atlas_init/tf/modules/stream_instance/provider.tf +8 -0
  50. atlas_init/tf/modules/stream_instance/stream_instance.tf +0 -9
  51. atlas_init/tf/modules/vpc_peering/provider.tf +10 -0
  52. atlas_init/tf/modules/vpc_peering/vpc_peering.tf +0 -10
  53. atlas_init/tf/modules/vpc_privatelink/versions.tf +2 -1
  54. atlas_init/tf/outputs.tf +1 -0
  55. atlas_init/tf/providers.tf +1 -1
  56. atlas_init/tf/variables.tf +7 -7
  57. atlas_init/typer_app.py +4 -8
  58. {atlas_init-0.4.5.dist-info → atlas_init-0.6.0.dist-info}/METADATA +7 -4
  59. atlas_init-0.6.0.dist-info/RECORD +121 -0
  60. atlas_init-0.4.5.dist-info/RECORD +0 -105
  61. {atlas_init-0.4.5.dist-info → atlas_init-0.6.0.dist-info}/WHEEL +0 -0
  62. {atlas_init-0.4.5.dist-info → atlas_init-0.6.0.dist-info}/entry_points.txt +0 -0
  63. {atlas_init-0.4.5.dist-info → atlas_init-0.6.0.dist-info}/licenses/LICENSE +0 -0
atlas_init/repos/path.py CHANGED
@@ -1,4 +1,9 @@
1
+ from __future__ import annotations
2
+ import logging
3
+ import re
4
+ from collections import defaultdict
1
5
  from collections.abc import Callable
6
+ from dataclasses import dataclass
2
7
  from enum import StrEnum
3
8
  from functools import lru_cache
4
9
  from pathlib import Path
@@ -8,6 +13,7 @@ from git import Repo as _GitRepo
8
13
 
9
14
  from atlas_init.settings.path import current_dir, repo_path_rel_path
10
15
 
16
+ logger = logging.getLogger(__name__)
11
17
  GH_OWNER_TERRAFORM_PROVIDER_MONGODBATLAS = "mongodb/terraform-provider-mongodbatlas"
12
18
  GH_OWNER_MONGODBATLAS_CLOUDFORMATION_RESOURCES = "mongodb/mongodbatlas-cloudformation-resources"
13
19
  _KNOWN_OWNER_PROJECTS = {
@@ -59,10 +65,10 @@ def is_resource_call(repo_path: Path) -> Callable[[Path], bool]:
59
65
 
60
66
 
61
67
  def resource_dir(repo_path: Path, full_path: Path) -> Path:
62
- dir_name = resource_name(repo_path, full_path)
63
- if not dir_name:
68
+ if dir_name := resource_name(repo_path, full_path):
69
+ return resource_root(repo_path) / dir_name
70
+ else:
64
71
  raise ValueError(f"no resource name for {full_path}")
65
- return resource_root(repo_path) / dir_name
66
72
 
67
73
 
68
74
  class Repo(StrEnum):
@@ -116,10 +122,10 @@ def resource_name(repo_path: Path, full_path: Path) -> str:
116
122
  is_resource = is_resource_call(repo_path)
117
123
  if not root.exists():
118
124
  raise ValueError(f"no resource root found for {repo_path}")
119
- for parent in [full_path, *full_path.parents]:
120
- if parent.parent == root and is_resource(parent):
121
- return parent.name
122
- return ""
125
+ return next(
126
+ (parent.name for parent in [full_path, *full_path.parents] if parent.parent == root and is_resource(parent)),
127
+ "",
128
+ )
123
129
 
124
130
 
125
131
  def find_paths(assert_repo: Repo | None = None) -> ResourcePaths:
@@ -153,3 +159,100 @@ def find_go_mod_dir(repo_path: Path):
153
159
  return go_mod.parent
154
160
  msg = "go.mod not found or more than 1 level deep"
155
161
  raise ValueError(msg)
162
+
163
+
164
+ def find_test_names(file: Path, prefix: str = "Test") -> list[str]:
165
+ test_names = []
166
+ with file.open("r") as f:
167
+ for line in f:
168
+ if line.startswith(f"func {prefix}"):
169
+ test_name = line.split("(")[0].strip().removeprefix("func ")
170
+ test_names.append(test_name)
171
+ return sorted(test_names)
172
+
173
+
174
+ class MultipleResourceNames(ValueError):
175
+ def __init__(self, names: list[str]):
176
+ super().__init__(f"multiple resource names found: {names}")
177
+ self.names = names
178
+
179
+
180
+ def find_tf_resource_name_in_test(path: Path, provider_prefix: str = "mongodbatlas_") -> str:
181
+ candidates: set[str] = {
182
+ match.group(1) for match in re.finditer(rf"=\s\"{provider_prefix}([a-zA-Z0-9_]+)\.?", path.read_text())
183
+ }
184
+ if len(candidates) > 1:
185
+ pkg_name = path.parent.name
186
+ for candidate in candidates:
187
+ if candidate.replace("_", "") == pkg_name:
188
+ return candidate
189
+ logger.warning(f"multiple resource names found in {path}: {candidates}")
190
+ raise MultipleResourceNames(sorted(candidates))
191
+ return candidates.pop() if candidates else ""
192
+
193
+
194
+ def find_pkg_test_names(pkg_path: Path, prefix: str = "Test") -> list[str]:
195
+ test_names = []
196
+ for test_file in pkg_path.glob("*_test.go"):
197
+ test_names.extend(find_test_names(test_file, prefix))
198
+ return sorted(test_names)
199
+
200
+
201
+ def terraform_resource_test_names(
202
+ repo_path: Path, prefix: str = "Test", package_path: str = "internal/service"
203
+ ) -> dict[str, list[str]]:
204
+ """find all test names in the given package path"""
205
+ pkg_path = terraform_package_path(repo_path, package_path)
206
+ resource_dirs, _ = find_resource_dirs(pkg_path)
207
+ test_names = defaultdict(list)
208
+ for name, pkg_dir in resource_dirs.items():
209
+ for test_file in pkg_dir.glob("*_test.go"):
210
+ test_names[name].extend(find_test_names(test_file, prefix))
211
+ return test_names
212
+
213
+
214
+ def terraform_resources(repo_path: Path, package_path: str = "internal/service") -> list[TFResoure]:
215
+ pkg_path = terraform_package_path(repo_path, package_path)
216
+ resource_dirs, _ = find_resource_dirs(pkg_path)
217
+ resources = []
218
+ for name, pkg_dir in resource_dirs.items():
219
+ test_names = find_pkg_test_names(pkg_dir)
220
+ resources.append(TFResoure(name=name, package_rel_path=str(pkg_dir.relative_to(repo_path)), tests=test_names))
221
+ return resources
222
+
223
+
224
+ def terraform_package_path(repo_path: Path, package_path: str = "internal/service"):
225
+ pkg_path = repo_path / package_path
226
+ if not pkg_path.exists():
227
+ raise ValueError(f"package path not found: {pkg_path}")
228
+ return pkg_path
229
+
230
+
231
+ def find_resource_dirs(pkg_path: Path) -> tuple[dict[str, Path], list[Path]]:
232
+ resource_dirs: dict[str, Path] = {}
233
+ non_resource_dirs: list[Path] = []
234
+ for pkg_dir in pkg_path.iterdir():
235
+ if not pkg_dir.is_dir():
236
+ continue
237
+ if pkg_dir.name == "testdata":
238
+ continue
239
+ found = False
240
+ for test_file in pkg_dir.glob("*_test.go"):
241
+ try:
242
+ if name := find_tf_resource_name_in_test(test_file):
243
+ resource_dirs[name] = pkg_dir
244
+ found = True
245
+ except MultipleResourceNames as e:
246
+ for name in e.names:
247
+ resource_dirs[name] = pkg_dir
248
+ found = True
249
+ if not found:
250
+ non_resource_dirs.append(pkg_dir)
251
+ return resource_dirs, non_resource_dirs
252
+
253
+
254
+ @dataclass
255
+ class TFResoure:
256
+ name: str
257
+ package_rel_path: str
258
+ tests: list[str]
@@ -12,7 +12,7 @@ from typing import Any
12
12
  from model_lib import Entity, IgnoreFalsy
13
13
  from pydantic import Field, model_validator
14
14
 
15
- from atlas_init.repos.path import as_repo_alias, go_package_prefix, owner_project_name, package_glob
15
+ from atlas_init.repos.path import as_repo_alias, find_test_names, go_package_prefix, owner_project_name, package_glob
16
16
 
17
17
  logger = logging.getLogger(__name__)
18
18
 
@@ -95,11 +95,8 @@ class TestSuite(IgnoreFalsy):
95
95
  for package in packages:
96
96
  pkg_name = f"{go_package_prefix(repo_path)}/{package}"
97
97
  for go_file in repo_path.glob(f"{package}/*.go"):
98
- with go_file.open() as f:
99
- for line in f:
100
- if line.startswith(f"func {prefix}"):
101
- test_name = line.split("(")[0].strip().removeprefix("func ")
102
- names[pkg_name][test_name] = go_file.parent
98
+ for name in find_test_names(go_file, prefix):
99
+ names[pkg_name][name] = go_file.parent
103
100
  return names
104
101
 
105
102
  def is_active(self, repo_alias: str, change_paths: Iterable[str]) -> bool:
@@ -64,6 +64,9 @@ class AtlasInitSettings(StaticSettings):
64
64
 
65
65
  non_interactive: bool = False
66
66
 
67
+ mongo_database: str = "atlas_init"
68
+ mongo_url: str = "mongodb://user:pass@localhost:27017?retryWrites=true&w=majority&authSource=admin"
69
+
67
70
  @property
68
71
  def is_interactive(self) -> bool:
69
72
  return not self.non_interactive
@@ -234,6 +237,7 @@ def find_missing_env_vars(required_env_vars: list[str], manual_env_vars: dict[st
234
237
 
235
238
  def init_settings(
236
239
  *settings_classes: type[BaseModel],
240
+ skip_ambiguous_check: bool = False,
237
241
  ) -> AtlasInitSettings:
238
242
  settings = AtlasInitSettings.from_env()
239
243
  profile_env_vars = settings.manual_env_vars
@@ -241,7 +245,7 @@ def init_settings(
241
245
  if vscode_env_vars.exists():
242
246
  profile_env_vars |= load_dotenv(vscode_env_vars)
243
247
  required_env_vars = collect_required_env_vars(list(settings_classes))
244
- ambiguous = detect_ambiguous_env_vars(profile_env_vars)
248
+ ambiguous = [] if skip_ambiguous_check else detect_ambiguous_env_vars(profile_env_vars)
245
249
  missing_env_vars = find_missing_env_vars(required_env_vars, profile_env_vars)
246
250
 
247
251
  if ambiguous:
@@ -0,0 +1,134 @@
1
+ """Inspired by: https://github.com/tmbo/questionary/blob/master/tests/utils.py"""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Callable, TypeVar
5
+
6
+ from prompt_toolkit.input.defaults import create_pipe_input
7
+ from prompt_toolkit.output import DummyOutput
8
+ from questionary import Question, checkbox
9
+ from questionary import confirm as _confirm
10
+ from questionary import select as _select
11
+ from questionary import text as _text
12
+
13
+ T = TypeVar("T")
14
+ TypedAsk = Callable[[Question, type[T]], T]
15
+
16
+ _question_asker: TypedAsk = lambda q, _: q.ask() # noqa: E731
17
+
18
+
19
+ def confirm(prompt_text: str, *, default: bool | None = None) -> bool:
20
+ if default is None:
21
+ return _question_asker(_confirm(prompt_text), bool)
22
+ return _question_asker(_confirm(prompt_text, default=default), bool)
23
+
24
+
25
+ def select_list_multiple(
26
+ prompt_text: str,
27
+ choices: list[str],
28
+ default: list[str] | None = None,
29
+ ) -> list[str]:
30
+ assert choices, "choices must not be empty"
31
+ default = default or []
32
+ return _question_asker(checkbox(prompt_text, choices=choices), list[str]) or default
33
+
34
+
35
+ def text(
36
+ prompt_text: str,
37
+ default: str = "",
38
+ ) -> str:
39
+ return _question_asker(_text(prompt_text, default=default), str)
40
+
41
+
42
+ T = TypeVar("T")
43
+
44
+
45
+ def select_dict(
46
+ prompt_text: str,
47
+ choices: dict[str, T],
48
+ default: str | None = None,
49
+ ) -> T:
50
+ assert choices, "choices must not be empty"
51
+ selection = _question_asker(_select(prompt_text, default=default, choices=list(choices)), str)
52
+ return choices[selection]
53
+
54
+
55
+ StrT = TypeVar("StrT", bound=str)
56
+
57
+
58
+ def select_list(
59
+ prompt_text: str,
60
+ choices: list[StrT],
61
+ default: StrT | None = None,
62
+ ) -> StrT:
63
+ assert choices, "choices must not be empty"
64
+ return _question_asker(_select(prompt_text, default=default, choices=choices), str)
65
+
66
+
67
+ class KeyInput:
68
+ DOWN = "\x1b[B"
69
+ UP = "\x1b[A"
70
+ LEFT = "\x1b[D"
71
+ RIGHT = "\x1b[C"
72
+ ENTER = "\r"
73
+ ESCAPE = "\x1b"
74
+ CONTROLC = "\x03"
75
+ CONTROLN = "\x0e"
76
+ CONTROLP = "\x10"
77
+ BACK = "\x7f"
78
+ SPACE = " "
79
+ TAB = "\x09"
80
+ ONE = "1"
81
+ TWO = "2"
82
+ THREE = "3"
83
+
84
+
85
+ @dataclass
86
+ class question_patcher:
87
+ responses: list[str]
88
+ next_response: int = 0
89
+
90
+ def __enter__(self):
91
+ global _question_asker
92
+ self._old_patcher = _question_asker
93
+ _question_asker = self.ask_question
94
+ return self
95
+
96
+ def __exit__(self, exc_type, exc_val, exc_tb):
97
+ global _question_patcher
98
+ _question_patcher = self._old_patcher
99
+
100
+ def ask_question(self, q: Question, response_type: type[T]) -> T:
101
+ q.application.output = DummyOutput()
102
+
103
+ def run(inp) -> T:
104
+ try:
105
+ input_response = self.responses[self.next_response]
106
+ except IndexError:
107
+ raise ValueError(
108
+ f"Not enough responses provided. Expected {len(self.responses)}, got {self.next_response + 1} questions."
109
+ )
110
+ self.next_response += 1
111
+ inp.send_text(input_response + KeyInput.ENTER + "\r")
112
+ q.application.output = DummyOutput()
113
+ q.application.input = inp
114
+ return q.ask()
115
+
116
+ with create_pipe_input() as inp:
117
+ return run(inp)
118
+
119
+
120
+ if __name__ == "__main__":
121
+ print(select_list("Select an option:", ["Option 1", "Option 2", "Option 3"])) # noqa: T201
122
+ print( # noqa: T201
123
+ select_dict(
124
+ "Select an option:",
125
+ {"Option 1": "1", "Option 2": "2", "Option 3": "3"},
126
+ default="Option 3",
127
+ )
128
+ )
129
+ print(confirm("Can you confirm?", default=True)) # noqa: T201
130
+ print(confirm("Can you confirm?", default=False)) # noqa: T201
131
+ print( # noqa: T201
132
+ select_list_multiple("Select options:", ["Option 1", "Option 2", "Option 3"], ["Option 1"])
133
+ )
134
+ print(text("Enter your name:", default="John Doe")) # noqa: T201
@@ -2,25 +2,25 @@
2
2
  # Manual edits may be lost in future updates.
3
3
 
4
4
  provider "registry.terraform.io/hashicorp/aws" {
5
- version = "5.87.0"
5
+ version = "5.98.0"
6
6
  constraints = "~> 5.0"
7
7
  hashes = [
8
- "h1:IYq3by7O/eJuXzJwOF920z2nZEkw08PkDFdw2xkyhrs=",
9
- "zh:017f237466875c919330b9e214fb33af14fffbff830d3755e8976d8fa3c963c2",
10
- "zh:0776d1e60aa93c85ecbb01144aed2789c8e180bb0f1c811a0aba17ca7247b26c",
11
- "zh:0dfa5c6cfb3724494fdc73f7d042515e88a20da8968959f48b3ec0b937bd8c8f",
12
- "zh:1707a5ead36a7980cb3f83e8b69a67a14ae725bfc990ddfcc209b59400b57b04",
13
- "zh:1c71f54fdd6adcbe547d6577dbb843d72a30fef0ab882d0afbeb8a7b348bc442",
14
- "zh:3563c850a29790957ec3f4d3ba203bfa2e084ac7319035b3f43b91f818a2c9b4",
15
- "zh:520bf6cef53785a92226651d5bebacbbf9314bdbc3211d0bf0903bce4e45149d",
16
- "zh:56f9778575830f6e5c23462c2eccbf2c9afaddb00a69275fcfb33cd1a6d17f4d",
17
- "zh:73e381cb0b1e76d471d7b0952f3d2a80350b507d15bda9b7041ea69077e3b5b5",
18
- "zh:7da74b48f8fa088be758a92407980400cb4b039a8d9ba3c108907e4055e9ad6f",
19
- "zh:8dacfa9623ba2e0197fe7db6faaaa0820a3b91fe00ba9e5d8a646340522bc8dd",
8
+ "h1:neMFK/kP1KT6cTGID+Tkkt8L7PsN9XqwrPDGXVw3WVY=",
9
+ "zh:23377bd90204b6203b904f48f53edcae3294eb072d8fc18a4531c0cde531a3a1",
10
+ "zh:2e55a6ea14cc43b08cf82d43063e96c5c2f58ee953c2628523d0ee918fe3b609",
11
+ "zh:4885a817c16fdaaeddc5031edc9594c1f300db0e5b23be7cd76a473e7dcc7b4f",
12
+ "zh:6ca7177ad4e5c9d93dee4be1ac0792b37107df04657fddfe0c976f36abdd18b5",
13
+ "zh:78bf8eb0a67bae5dede09666676c7a38c9fb8d1b80a90ba06cf36ae268257d6f",
14
+ "zh:874b5a99457a3f88e2915df8773120846b63d820868a8f43082193f3dc84adcb",
15
+ "zh:95e1e4cf587cde4537ac9dfee9e94270652c812ab31fce3a431778c053abf354",
20
16
  "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
21
- "zh:9c2ebd21d697e1a611fe201788dc9e1678949a088afc85d4589563bca484d835",
22
- "zh:ac5d0bbf36f9a6cedbfb63993f6baf0aabdaf21c8d7fc3b1e69ba8cbf344b5f3",
23
- "zh:c2329644179f78a0458b6cf2dd5eaadca4c610fc3577a1b50620544d92df13e8",
17
+ "zh:a75145b58b241d64570803e6565c72467cd664633df32678755b51871f553e50",
18
+ "zh:aa31b13d0b0e8432940d6892a48b6268721fa54a02ed62ee42745186ee32f58d",
19
+ "zh:ae4565770f76672ce8e96528cbb66afdade1f91383123c079c7fdeafcb3d2877",
20
+ "zh:b99f042c45bf6aa69dd73f3f6d9cbe0b495b30442c526e0b3810089c059ba724",
21
+ "zh:bbb38e86d926ef101cefafe8fe090c57f2b1356eac9fc5ec81af310c50375897",
22
+ "zh:d03c89988ba4a0bd3cfc8659f951183ae7027aa8018a7ca1e53a300944af59cb",
23
+ "zh:d179ef28843fe663fc63169291a211898199009f0d3f63f0a6f65349e77727ec",
24
24
  ]
25
25
  }
26
26
 
@@ -65,61 +65,61 @@ provider "registry.terraform.io/hashicorp/local" {
65
65
  }
66
66
 
67
67
  provider "registry.terraform.io/hashicorp/null" {
68
- version = "3.2.3"
68
+ version = "3.2.4"
69
69
  hashes = [
70
- "h1:I0Um8UkrMUb81Fxq/dxbr3HLP2cecTH2WMJiwKSrwQY=",
71
- "zh:22d062e5278d872fe7aed834f5577ba0a5afe34a3bdac2b81f828d8d3e6706d2",
72
- "zh:23dead00493ad863729495dc212fd6c29b8293e707b055ce5ba21ee453ce552d",
73
- "zh:28299accf21763ca1ca144d8f660688d7c2ad0b105b7202554ca60b02a3856d3",
74
- "zh:55c9e8a9ac25a7652df8c51a8a9a422bd67d784061b1de2dc9fe6c3cb4e77f2f",
75
- "zh:756586535d11698a216291c06b9ed8a5cc6a4ec43eee1ee09ecd5c6a9e297ac1",
70
+ "h1:L5V05xwp/Gto1leRryuesxjMfgZwjb7oool4WS1UEFQ=",
71
+ "zh:59f6b52ab4ff35739647f9509ee6d93d7c032985d9f8c6237d1f8a59471bbbe2",
76
72
  "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
77
- "zh:9d5eea62fdb587eeb96a8c4d782459f4e6b73baeece4d04b4a40e44faaee9301",
78
- "zh:a6355f596a3fb8fc85c2fb054ab14e722991533f87f928e7169a486462c74670",
79
- "zh:b5a65a789cff4ada58a5baffc76cb9767dc26ec6b45c00d2ec8b1b027f6db4ed",
80
- "zh:db5ab669cf11d0e9f81dc380a6fdfcac437aea3d69109c7aef1a5426639d2d65",
81
- "zh:de655d251c470197bcbb5ac45d289595295acb8f829f6c781d4a75c8c8b7c7dd",
82
- "zh:f5c68199f2e6076bce92a12230434782bf768103a427e9bb9abee99b116af7b5",
73
+ "zh:795c897119ff082133150121d39ff26cb5f89a730a2c8c26f3a9c1abf81a9c43",
74
+ "zh:7b9c7b16f118fbc2b05a983817b8ce2f86df125857966ad356353baf4bff5c0a",
75
+ "zh:85e33ab43e0e1726e5f97a874b8e24820b6565ff8076523cc2922ba671492991",
76
+ "zh:9d32ac3619cfc93eb3c4f423492a8e0f79db05fec58e449dee9b2d5873d5f69f",
77
+ "zh:9e15c3c9dd8e0d1e3731841d44c34571b6c97f5b95e8296a45318b94e5287a6e",
78
+ "zh:b4c2ab35d1b7696c30b64bf2c0f3a62329107bd1a9121ce70683dec58af19615",
79
+ "zh:c43723e8cc65bcdf5e0c92581dcbbdcbdcf18b8d2037406a5f2033b1e22de442",
80
+ "zh:ceb5495d9c31bfb299d246ab333f08c7fb0d67a4f82681fbf47f2a21c3e11ab5",
81
+ "zh:e171026b3659305c558d9804062762d168f50ba02b88b231d20ec99578a6233f",
82
+ "zh:ed0fe2acdb61330b01841fa790be00ec6beaac91d41f311fb8254f74eb6a711f",
83
83
  ]
84
84
  }
85
85
 
86
86
  provider "registry.terraform.io/hashicorp/random" {
87
- version = "3.6.3"
87
+ version = "3.7.2"
88
88
  hashes = [
89
- "h1:zG9uFP8l9u+yGZZvi5Te7PV62j50azpgwPunq2vTm1E=",
90
- "zh:04ceb65210251339f07cd4611885d242cd4d0c7306e86dda9785396807c00451",
91
- "zh:448f56199f3e99ff75d5c0afacae867ee795e4dfda6cb5f8e3b2a72ec3583dd8",
92
- "zh:4b4c11ccfba7319e901df2dac836b1ae8f12185e37249e8d870ee10bb87a13fe",
93
- "zh:4fa45c44c0de582c2edb8a2e054f55124520c16a39b2dfc0355929063b6395b1",
94
- "zh:588508280501a06259e023b0695f6a18149a3816d259655c424d068982cbdd36",
95
- "zh:737c4d99a87d2a4d1ac0a54a73d2cb62974ccb2edbd234f333abd079a32ebc9e",
89
+ "h1:KG4NuIBl1mRWU0KD/BGfCi1YN/j3F7H4YgeeM7iSdNs=",
90
+ "zh:14829603a32e4bc4d05062f059e545a91e27ff033756b48afbae6b3c835f508f",
91
+ "zh:1527fb07d9fea400d70e9e6eb4a2b918d5060d604749b6f1c361518e7da546dc",
92
+ "zh:1e86bcd7ebec85ba336b423ba1db046aeaa3c0e5f921039b3f1a6fc2f978feab",
93
+ "zh:24536dec8bde66753f4b4030b8f3ef43c196d69cccbea1c382d01b222478c7a3",
94
+ "zh:29f1786486759fad9b0ce4fdfbbfece9343ad47cd50119045075e05afe49d212",
95
+ "zh:4d701e978c2dd8604ba1ce962b047607701e65c078cb22e97171513e9e57491f",
96
96
  "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
97
- "zh:a357ab512e5ebc6d1fda1382503109766e21bbfdfaa9ccda43d313c122069b30",
98
- "zh:c51bfb15e7d52cc1a2eaec2a903ac2aff15d162c172b1b4c17675190e8147615",
99
- "zh:e0951ee6fa9df90433728b96381fb867e3db98f66f735e0c3e24f8f16903f0ad",
100
- "zh:e3cdcb4e73740621dabd82ee6a37d6cfce7fee2a03d8074df65086760f5cf556",
101
- "zh:eff58323099f1bd9a0bec7cb04f717e7f1b2774c7d612bf7581797e1622613a0",
97
+ "zh:7b8434212eef0f8c83f5a90c6d76feaf850f6502b61b53c329e85b3b281cba34",
98
+ "zh:ac8a23c212258b7976e1621275e3af7099e7e4a3d4478cf8d5d2a27f3bc3e967",
99
+ "zh:b516ca74431f3df4c6cf90ddcdb4042c626e026317a33c53f0b445a3d93b720d",
100
+ "zh:dc76e4326aec2490c1600d6871a95e78f9050f9ce427c71707ea412a2f2f1a62",
101
+ "zh:eac7b63e86c749c7d48f527671c7aee5b4e26c10be6ad7232d6860167f99dbb0",
102
102
  ]
103
103
  }
104
104
 
105
105
  provider "registry.terraform.io/mongodb/mongodbatlas" {
106
- version = "1.19.0"
107
- constraints = "1.19.0"
106
+ version = "1.33.0"
107
+ constraints = "1.33.0"
108
108
  hashes = [
109
- "h1:zzKWs4GzWXo+ImMQud/b0ECObJmbtB2wCrK3b98z1ms=",
110
- "zh:3a8198e83b9b2dd1c461049f19464e82ce3f24d9fa7508e0e6dd642e2be70f73",
111
- "zh:3a89a8395624a8e8516c6147b1612798f05e59ed3f13c1f6d8878099c9ca5f6e",
112
- "zh:41ff89b10d5f1069d4bfa093e2d9297f1670863716f60d7b874f076bc37bc2ac",
113
- "zh:5baf75906ccfc658be79b4c02c86032943af18c159f9c80a067ed696f23db527",
114
- "zh:697aa8aebc5f4f8b6c42ba33bd1fec5ab8244555905bf6c6482ebf4733fe7976",
115
- "zh:6d7fe4c2bca1e34e0c881266a463bbe16dd9a2934b7fa6d116c711a56b895f6f",
116
- "zh:6dca00e357d04fbaeab6d2fa336c6704e289c076beef250a3cfe948a901bc4d4",
117
- "zh:877a40cabcc49ee9fb40143dcbd6253d0c08ac1603a71e2cf2dde2d1fbfde574",
118
- "zh:8a43a657196f4917f32f07ea91f056a2be6e7adb8a1fb7df4517ad9b71362c30",
119
- "zh:91ef30b6020da3d5c5781ea6718b5f785c1eb3c7f4677343b31af2297d9f3558",
120
- "zh:9bbc42509526c942db3979eaacd15b96ad454777993a0b002f908f9e9fcef51c",
121
- "zh:b11fd160fcdd9cf7423283af7e0c3f0970b391b5a62ec30fe699ffdd54351896",
122
- "zh:c297a0a188141741f14578cd8db41c309361e37b1b0904e635a7ebd0993e86f7",
123
- "zh:c8af40986dbc42e77d0e34af7ea2d730cb87aa0471236392dbea0926ab95159a",
109
+ "h1:z8zdSte741iw5ij4wkY8XBAXftY7gEsFjYRMjyk1EX0=",
110
+ "zh:04e26c9e1dfd11c114c5dbd4e4375bb3a329fbaa2f39f92d01f6bba9d76923ba",
111
+ "zh:1d175f30a1a2505578c63d7ef76c7c1c846d086ab0e6a1bcebf32d3bfe10a2f6",
112
+ "zh:1fd08f988587efa41121dbe0cae7298fa8aa739c0038aa2443f8deb53e7367ad",
113
+ "zh:4c6c337f7a53882e8b5431ba13276bfd1f423becfd4dbbcb0f68443532354455",
114
+ "zh:4f7028a474d00012280a6069d74584e6eeda2f85be2300040012210f91daa97a",
115
+ "zh:6ad4d292b60350dae24eb1a6721a7b35f34129ad42a00125ffb7ab6b4565eb15",
116
+ "zh:6c8f5a14edd77433f559e8440c2b6ee7333c13e5256aa76a17eb585046bef0c1",
117
+ "zh:8e18a10107beeb9d677e96cc0b25b6f48be9dfbedc62da7bdde7b03b9bfc34b7",
118
+ "zh:9130c4a1c06ba4587235c479eae182f86b4baadd82a90bd3c69ad54cf2a8c37d",
119
+ "zh:a1464ff45db030c6b94f9e80e5890061baf4cb3a8595d473d422e2778fc6a5fb",
120
+ "zh:a20f97e43befeb8a0737cfc2f1a3ea3e483d5928e0baf7dc841bad67d21ac90b",
121
+ "zh:d3e440568d5f3d2197555ba614d08950cb7fbdf605f3ec2f4b6fc9edff563668",
122
+ "zh:de11d29abae0ceefd11b6d21575c3335b586d9b27fd5a8ebc8c40a6ce67c01a9",
123
+ "zh:fea06f8ccd2aec629ca7f24b4cbbd8cba832044d7ee0ee395b3c6e8eab4ed903",
124
124
  ]
125
125
  }
atlas_init/tf/always.tf CHANGED
@@ -10,7 +10,7 @@ resource "random_password" "username" {
10
10
 
11
11
  data "http" "myip" {
12
12
  count = var.use_project_myip ? 1 : 0
13
- url = "https://ipv4.icanhazip.com"
13
+ url = "https://ipv4.icanhazip.com"
14
14
  }
15
15
 
16
16
  data "http" "last_provider_version" {
@@ -35,18 +35,18 @@ resource "mongodbatlas_project" "project" {
35
35
  name = var.project_name
36
36
  org_id = var.org_id
37
37
 
38
- tags = local.tags
38
+ tags = local.tags
39
39
  region_usage_restrictions = var.is_mongodbgov_cloud ? "GOV_REGIONS_ONLY" : null
40
- project_owner_id = length(var.user_id) > 0 ? var.user_id : null
40
+ project_owner_id = length(var.user_id) > 0 ? var.user_id : null
41
41
  }
42
42
 
43
43
  resource "mongodbatlas_project_ip_access_list" "mongo-access" {
44
- count = var.use_project_myip ? 1 : 0
44
+ count = var.use_project_myip ? 1 : 0
45
45
  project_id = mongodbatlas_project.project.id
46
46
  cidr_block = "${chomp(data.http.myip[0].response_body)}/32"
47
47
  }
48
48
 
49
49
  data "mongodbatlas_atlas_user" "this" {
50
- count = length(var.user_id) > 0 ? 1 : 0
50
+ count = length(var.user_id) > 0 ? 1 : 0
51
51
  user_id = var.user_id
52
52
  }
atlas_init/tf/main.tf CHANGED
@@ -141,9 +141,9 @@ module "aws_kms" {
141
141
  access_iam_role_arns = {
142
142
  atlas = module.cloud_provider[0].iam_role_arn
143
143
  }
144
- aws_account_id = local.aws_account_id
145
- aws_region = var.aws_region
146
- key_suffix = var.project_name
144
+ aws_account_id = local.aws_account_id
145
+ aws_region = var.aws_region
146
+ key_suffix = var.project_name
147
147
  }
148
148
 
149
149
  module "federated_vars" {
@@ -5,7 +5,7 @@ variable "aws_region" {
5
5
  type = string
6
6
  }
7
7
  variable "access_iam_role_arns" {
8
- type = map(string)
8
+ type = map(string)
9
9
  description = "static name to arn"
10
10
  }
11
11
 
@@ -2,8 +2,9 @@ terraform {
2
2
  required_providers {
3
3
  mongodbatlas = {
4
4
  source = "mongodb/mongodbatlas"
5
- version = "1.19.0"
5
+ version = "1.33"
6
6
  }
7
7
  }
8
+
8
9
  required_version = ">= 1.0"
9
10
  }
@@ -2,11 +2,12 @@ terraform {
2
2
  required_providers {
3
3
  mongodbatlas = {
4
4
  source = "mongodb/mongodbatlas"
5
- version = "1.19.0"
5
+ version = "1.33"
6
6
  }
7
7
  aws = {
8
8
  source = "hashicorp/aws"
9
9
  }
10
10
  }
11
+
11
12
  required_version = ">= 1.0"
12
13
  }
@@ -1,11 +1,3 @@
1
- terraform {
2
- required_providers {
3
- aws = {
4
- source = "hashicorp/aws"
5
- }
6
- }
7
- }
8
-
9
1
  locals {
10
2
  services_yaml = file("${path.module}/assume_role_services.yaml")
11
3
  resource_actions_yaml = file("${path.module}/resource_actions.yaml")
@@ -19,13 +19,13 @@ locals {
19
19
  Resource = "*"
20
20
  },
21
21
  {
22
- Sid = "Enable IAM User Permissions for Role",
23
- Effect = "Allow",
22
+ Sid = "Enable IAM User Permissions for Role",
23
+ Effect = "Allow",
24
24
  Principal = {
25
25
  AWS = "*"
26
26
  }
27
- Action = "kms:Decrypt",
28
- Resource = "*"
27
+ Action = "kms:Decrypt",
28
+ Resource = "*"
29
29
  Condition = {
30
30
  StringEquals = {
31
31
  "aws:PrincipalArn" = "arn:aws:iam::${var.aws_account_id}:role/${local.role_name}"
@@ -50,5 +50,5 @@ resource "aws_kms_key" "this" {
50
50
  count = var.use_kms_key ? 1 : 0
51
51
  description = "KMS key for ${var.cfn_profile}"
52
52
  deletion_window_in_days = 7
53
- policy = local.kms_key_policy_json
53
+ policy = local.kms_key_policy_json
54
54
  }
@@ -0,0 +1,7 @@
1
+ terraform {
2
+ required_providers {
3
+ aws = {
4
+ source = "hashicorp/aws"
5
+ }
6
+ }
7
+ }
@@ -18,7 +18,7 @@ variable "tags" {
18
18
  }
19
19
 
20
20
  variable "use_kms_key" {
21
- type = bool
21
+ type = bool
22
22
  default = false
23
23
  }
24
24
 
@@ -48,7 +48,7 @@ EOF
48
48
 
49
49
  output "env_vars" {
50
50
  value = {
51
- IAM_ROLE_ID = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
51
+ IAM_ROLE_ID = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
52
52
  AWS_IAM_ROLE_ARN = aws_iam_role.aws_role.arn
53
53
  }
54
54
  }
@@ -2,12 +2,13 @@ terraform {
2
2
  required_providers {
3
3
  mongodbatlas = {
4
4
  source = "mongodb/mongodbatlas"
5
- version = "1.19.0"
5
+ version = "1.33"
6
6
  }
7
7
  aws = {
8
8
  source = "hashicorp/aws"
9
9
  version = "~> 5.0"
10
10
  }
11
11
  }
12
+
12
13
  required_version = ">= 1.0"
13
14
  }