atlas-init 0.1.0__py3-none-any.whl → 0.1.1__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.
atlas_init/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from pathlib import Path
2
2
 
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
 
5
5
 
6
6
  def running_in_repo() -> bool:
@@ -1,69 +1,69 @@
1
1
  repo_aliases:
2
- mongodb/terraform-provider-mongodbatlas: tf
3
- mongodb/mongodbatlas-cloudformation-resources: cfn
2
+ mongodb/terraform-provider-mongodbatlas: tf
3
+ mongodb/mongodbatlas-cloudformation-resources: cfn
4
4
  test_suites:
5
5
  - name: cluster
6
6
  repo_go_packages:
7
7
  cfn:
8
- - 'cfn-resources/cluster'
8
+ - cfn-resources/cluster
9
9
  - name: federated
10
10
  repo_go_packages:
11
11
  tf:
12
- - 'internal/service/federatedsettingsorgrolemapping'
12
+ - internal/service/federatedsettingsorgrolemapping
13
13
  vars:
14
14
  use_federated_vars: true
15
- - name: project
16
- vars:
17
- use_project_extra: true
18
- repo_go_packages:
19
- cfn:
20
- - 'cfn-resources/project'
21
- - name: network_peering
22
- vars:
23
- use_aws_vpc: true
24
- use_aws_vars: true
25
- use_vpc_peering: true
15
+ - name: network
26
16
  repo_go_packages:
27
17
  tf:
28
- - 'internal/service/networkpeering'
29
- - name: network
30
- vars:
18
+ - internal/service/privatelinkendpointservicedatafederationonlinearchive
19
+ vars:
31
20
  use_private_link: true
21
+ - name: network_peering
32
22
  repo_go_packages:
33
23
  tf:
34
- - 'internal/service/privatelinkendpointservicedatafederationonlinearchive'
35
- - name: privatelink
24
+ - internal/service/networkpeering
36
25
  vars:
37
- use_aws_vpc: true
26
+ use_vpc_peering: true
38
27
  use_aws_vars: true
28
+ use_aws_vpc: true
29
+ - name: privatelink
39
30
  repo_go_packages:
40
31
  tf:
41
- - 'internal/service/privatelinkendpointservice'
42
- - name: stream_connection
43
- repo_go_packages:
44
- tf:
45
- - 'internal/service/streamconnection'
46
- cfn:
47
- - 'cfn-resources/stream-connection'
32
+ - internal/service/privatelinkendpointservice
48
33
  vars:
49
- cluster_info: true
50
- stream_instance: true
51
- - name: search_index
34
+ use_aws_vars: true
35
+ use_aws_vpc: true
36
+ - name: project
52
37
  repo_go_packages:
53
- tf:
54
- - 'internal/service/searchindex'
38
+ cfn:
39
+ - cfn-resources/project
55
40
  vars:
56
- cluster_info: true
41
+ use_project_extra: true
57
42
  - name: s3
58
43
  repo_go_packages:
59
44
  tf:
60
- - 'internal/service/cloudbackupsnapshotexportbucket'
45
+ - internal/service/cloudbackupsnapshotexportbucket
61
46
  vars:
62
47
  use_aws_s3: true
63
48
  - name: s3_with_cluster
64
49
  repo_go_packages:
65
50
  tf:
66
- - 'internal/service/cloudbackupsnapshotexportjob'
51
+ - internal/service/cloudbackupsnapshotexportjob
67
52
  vars:
68
- use_aws_s3: true
69
53
  cluster_info_m10: true
54
+ use_aws_s3: true
55
+ - name: search_index
56
+ repo_go_packages:
57
+ tf:
58
+ - internal/service/searchindex
59
+ vars:
60
+ cluster_info: true
61
+ - name: stream_connection
62
+ repo_go_packages:
63
+ tf:
64
+ - internal/service/streamconnection
65
+ cfn:
66
+ - cfn-resources/stream-connection
67
+ vars:
68
+ cluster_info: true
69
+ stream_instance: true
atlas_init/cli.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ import os
2
3
  import sys
3
4
  from collections.abc import Callable
4
5
  from functools import partial
@@ -10,6 +11,7 @@ from zero_3rdparty.file_utils import iter_paths
10
11
  from atlas_init import running_in_repo
11
12
  from atlas_init.cli_cfn.app import app as app_cfn
12
13
  from atlas_init.cli_helper import sdk_auto_changes
14
+ from atlas_init.cli_helper.go import run_go_tests
13
15
  from atlas_init.cli_helper.run import (
14
16
  run_binary_command_is_ok,
15
17
  run_command_exit_on_failure,
@@ -55,7 +57,7 @@ from atlas_init.settings.path import (
55
57
  dump_vscode_dotenv,
56
58
  repo_path_rel_path,
57
59
  )
58
- from atlas_init.settings.rich_utils import configure_logging
60
+ from atlas_init.settings.rich_utils import configure_logging, hide_secrets
59
61
 
60
62
  logger = logging.getLogger(__name__)
61
63
  app = typer.Typer(name="atlas_init", invoke_without_command=True, no_args_is_help=True)
@@ -89,7 +91,7 @@ def main(
89
91
  explicit_env_vars: dict[str, str] = {}
90
92
  if project_name != "":
91
93
  explicit_env_vars[as_env_var_name("project_name")] = project_name
92
- configure_logging(log_level)
94
+ log_handler = configure_logging(log_level)
93
95
  logger.info(f"running in repo: {running_in_repo()} python location:{sys.executable}")
94
96
  missing_env_vars, ambiguous_env_vars = AtlasInitSettings.check_env_vars(
95
97
  profile,
@@ -104,6 +106,7 @@ def main(
104
106
  )
105
107
  if missing_env_vars or ambiguous_env_vars:
106
108
  raise typer.Exit(1)
109
+ hide_secrets(log_handler, {**os.environ})
107
110
  command = ctx.invoked_subcommand
108
111
  logger.info(f"in the app callback, log-level: {log_level}, command: {command}")
109
112
 
@@ -135,7 +138,7 @@ def apply(context: typer.Context, *, skip_outputs: bool = False):
135
138
  run_terraform(settings, "apply", extra_args)
136
139
  except TerraformRunError as e:
137
140
  logger.error(repr(e)) # noqa: TRY400
138
- return
141
+ raise typer.Exit(1) from e
139
142
 
140
143
  if not skip_outputs:
141
144
  export_outputs(settings)
@@ -149,6 +152,9 @@ def apply(context: typer.Context, *, skip_outputs: bool = False):
149
152
  def destroy(context: typer.Context):
150
153
  extra_args = context.args
151
154
  settings = init_settings()
155
+ if not settings.tf_state_path.exists():
156
+ logger.warning(f"no terraform state found {settings.tf_state_path}, exiting")
157
+ return
152
158
  tf_vars = get_tf_vars(settings, [])
153
159
  dump_tf_vars(settings, tf_vars)
154
160
  try:
@@ -164,9 +170,15 @@ def test_go():
164
170
  suites = active_suites(settings)
165
171
  sorted_suites = sorted(suite.name for suite in suites)
166
172
  logger.info(f"running go tests for {len(suites)} test-suites: {sorted_suites}")
167
- raise NotImplementedError("fix me later!") # noqa
168
- # package_prefix = settings.config.go_package_prefix(repo_alias)
169
- # run_go_tests(repo_path, repo_alias, package_prefix, settings, active_suites)
173
+ match repo_alias := current_repo():
174
+ case Repo.CFN:
175
+ raise NotImplementedError
176
+ case Repo.TF:
177
+ repo_path = current_repo_path()
178
+ package_prefix = settings.config.go_package_prefix(repo_alias)
179
+ run_go_tests(repo_path, repo_alias, package_prefix, settings, suites)
180
+ case _:
181
+ raise NotImplementedError
170
182
 
171
183
 
172
184
  @app_command()
@@ -2,8 +2,6 @@ import logging
2
2
  import os
3
3
  from pathlib import Path
4
4
 
5
- import dotenv
6
-
7
5
  from atlas_init.cli_helper.run import run_command_is_ok
8
6
  from atlas_init.settings.config import TestSuite
9
7
  from atlas_init.settings.env_vars import AtlasInitSettings
@@ -18,7 +16,12 @@ def run_go_tests(
18
16
  settings: AtlasInitSettings,
19
17
  groups: list[TestSuite],
20
18
  ):
21
- test_env = os.environ | dotenv.dotenv_values(settings.env_vars_vs_code)
19
+ extra_vars = settings.load_env_vars(settings.env_vars_vs_code)
20
+ logger.info(f"go test env-vars-extra: {sorted(extra_vars)}")
21
+ test_env = os.environ | extra_vars
22
+ ci_value = test_env.pop("CI", None)
23
+ if ci_value:
24
+ logger.warning(f"pooped CI={ci_value}")
22
25
  for group in groups:
23
26
  packages = ",".join(f"{package_prefix}/{pkg}" for pkg in group.repo_go_packages.get(repo_alias, []))
24
27
  if not packages:
@@ -19,8 +19,8 @@ from atlas_init.settings.env_vars import AtlasInitSettings
19
19
  logger = logging.getLogger(__name__)
20
20
 
21
21
 
22
- def get_tf_vars(settings: AtlasInitSettings, active_groups: list[TestSuite]) -> dict[str, Any]:
23
- tf_vars = TerraformVars()
22
+ def get_tf_vars(settings: AtlasInitSettings, active_groups: list[TestSuite]) -> dict[str, Any]: # type: ignore
23
+ tf_vars = TerraformVars() # type: ignore
24
24
  tf_vars = sum((group.vars for group in active_groups), start=tf_vars)
25
25
  return {
26
26
  "atlas_public_key": settings.MONGODB_ATLAS_PUBLIC_KEY,
@@ -41,28 +41,22 @@ class TerraformRunError(Exception):
41
41
 
42
42
  @dataclass
43
43
  class state_copier: # noqa: N801
44
- profile_path: Path
44
+ state_path: Path
45
45
  tf_path: Path
46
46
 
47
- @property
48
- def state_path(self) -> Path:
49
- return self.profile_path / "tf_state"
50
-
51
47
  def __enter__(self):
52
- if not self.state_path.exists():
53
- return
48
+ self.state_path.mkdir(exist_ok=True, parents=True)
54
49
  for state_path, rel_path in iter_paths_and_relative(self.state_path, "terraform.tfstate*", rglob=False):
55
50
  copy(state_path, self.tf_path / rel_path)
56
51
 
57
52
  def __exit__(self, *_):
58
- if not self.tf_path.exists():
59
- return
53
+ self.tf_path.mkdir(exist_ok=True, parents=True)
60
54
  for state_path, rel_path in iter_paths_and_relative(self.tf_path, "terraform.tfstate*", rglob=False):
61
55
  state_path.rename(self.state_path / rel_path)
62
56
 
63
57
 
64
58
  def run_terraform(settings: AtlasInitSettings, command: str, extra_args: list[str]):
65
- with state_copier(settings.profile_dir, settings.tf_path):
59
+ with state_copier(settings.tf_state_path, settings.tf_path):
66
60
  _run_terraform(settings, command, extra_args)
67
61
 
68
62
 
@@ -103,12 +97,11 @@ def dump_tf_vars(settings: AtlasInitSettings, tf_vars: dict[str, Any]):
103
97
 
104
98
 
105
99
  def export_outputs(settings: AtlasInitSettings) -> None:
106
- output_path = settings.profile_dir / "tf_outputs.json"
107
- with state_copier(settings.profile_dir, settings.tf_path):
100
+ with state_copier(settings.tf_state_path, settings.tf_path):
108
101
  result = run_command_receive_result(
109
102
  "terraform output -json",
110
103
  settings.tf_path,
111
104
  logger,
112
105
  env=os.environ | {"TF_DATA_DIR": settings.tf_data_dir},
113
106
  )
114
- output_path.write_text(result)
107
+ settings.tf_outputs_path.write_text(result)
@@ -3,10 +3,11 @@ from __future__ import annotations
3
3
  import fnmatch
4
4
  import logging
5
5
  from collections.abc import Iterable
6
+ from functools import total_ordering
6
7
  from pathlib import Path
7
8
  from typing import Any
8
9
 
9
- from model_lib import Entity
10
+ from model_lib import Entity, dump_ignore_falsy
10
11
  from pydantic import Field, model_validator
11
12
 
12
13
  from atlas_init.repos.path import owner_project_name
@@ -14,6 +15,7 @@ from atlas_init.repos.path import owner_project_name
14
15
  logger = logging.getLogger(__name__)
15
16
 
16
17
 
18
+ @dump_ignore_falsy
17
19
  class TerraformVars(Entity):
18
20
  cluster_info: bool = False
19
21
  cluster_info_m10: bool = False
@@ -26,8 +28,8 @@ class TerraformVars(Entity):
26
28
  use_aws_s3: bool = False
27
29
  use_federated_vars: bool = False
28
30
 
29
- def __add__(self, other: TerraformVars):
30
- assert isinstance(other, TerraformVars)
31
+ def __add__(self, other: TerraformVars): # type: ignore
32
+ assert isinstance(other, TerraformVars) # type: ignore
31
33
  kwargs = {k: v or getattr(other, k) for k, v in self}
32
34
  return type(self)(**kwargs)
33
35
 
@@ -61,6 +63,8 @@ class TerraformVars(Entity):
61
63
  return config
62
64
 
63
65
 
66
+ @dump_ignore_falsy
67
+ @total_ordering
64
68
  class TestSuite(Entity):
65
69
  __test__ = False
66
70
 
@@ -68,7 +72,12 @@ class TestSuite(Entity):
68
72
  sequential_tests: bool = False
69
73
  repo_go_packages: dict[str, list[str]] = Field(default_factory=dict)
70
74
  repo_globs: dict[str, list[str]] = Field(default_factory=dict)
71
- vars: TerraformVars = Field(default_factory=TerraformVars)
75
+ vars: TerraformVars = Field(default_factory=TerraformVars) # type: ignore
76
+
77
+ def __lt__(self, other) -> bool:
78
+ if not isinstance(other, TestSuite): # type: ignore
79
+ raise TypeError
80
+ return self.name < other.name
72
81
 
73
82
  def all_globs(self, repo_alias: str) -> list[str]:
74
83
  go_packages = self.repo_go_packages.get(repo_alias, [])
@@ -95,8 +104,8 @@ class RepoAliasNotFoundError(ValueError):
95
104
 
96
105
 
97
106
  class AtlasInitConfig(Entity):
98
- test_suites: list[TestSuite] = Field(default_factory=list)
99
107
  repo_aliases: dict[str, str] = Field(default_factory=dict)
108
+ test_suites: list[TestSuite] = Field(default_factory=list) # type: ignore
100
109
 
101
110
  def repo_alias(self, repo_url_path: str) -> str:
102
111
  alias = self.repo_aliases.get(repo_url_path)
@@ -115,7 +124,7 @@ class AtlasInitConfig(Entity):
115
124
  alias: str | None,
116
125
  change_paths: Iterable[str],
117
126
  forced_test_suites: list[str],
118
- ) -> list[TestSuite]:
127
+ ) -> list[TestSuite]: # type: ignore
119
128
  forced_suites = set(forced_test_suites)
120
129
  if forced_test_suites:
121
130
  logger.warning(f"using forced test suites: {forced_test_suites}")
@@ -143,7 +152,7 @@ def active_suites(
143
152
  repo_path: Path,
144
153
  cwd_rel_path: str,
145
154
  forced_test_suites: list[str],
146
- ) -> list[TestSuite]:
155
+ ) -> list[TestSuite]: # type: ignore
147
156
  repo_url_path = owner_project_name(repo_path)
148
157
  repo_alias = config.repo_alias(repo_url_path)
149
158
  logger.info(f"repo_alias={repo_alias}, repo_path={repo_path}, repo_url_path={repo_url_path}")
@@ -47,11 +47,11 @@ class ExternalSettings(BaseSettings):
47
47
  MONGODB_ATLAS_PRIVATE_KEY: str
48
48
  MONGODB_ATLAS_PUBLIC_KEY: str
49
49
  MONGODB_ATLAS_BASE_URL: str = "https://cloud-dev.mongodb.com/"
50
- ci: bool = False
50
+ non_interactive: bool = False
51
51
 
52
52
  @property
53
53
  def is_interactive(self) -> bool:
54
- return not self.ci
54
+ return not self.non_interactive
55
55
 
56
56
 
57
57
  def as_env_var_name(field_name: str) -> str:
@@ -145,6 +145,17 @@ class AtlasInitPaths(BaseSettings):
145
145
  def tf_vars_path(self) -> Path:
146
146
  return self.tf_data_dir / "vars.auto.tfvars.json"
147
147
 
148
+ @property
149
+ def tf_state_path(self) -> Path:
150
+ return self.profile_dir / "tf_state"
151
+
152
+ @property
153
+ def tf_outputs_path(self) -> Path:
154
+ return self.profile_dir / "tf_outputs.json"
155
+
156
+ def load_env_vars(self, path: Path) -> dict[str, str]:
157
+ return load_dotenv(path)
158
+
148
159
  def load_env_vars_generated(self) -> dict[str, str]:
149
160
  env_path = self.env_vars_generated
150
161
  assert env_path.exists(), f"no env-vars exist {env_path} have you forgotten apply?"
@@ -9,11 +9,46 @@ class _LogLevel(BaseModel):
9
9
  log_level: Literal["INFO", "WARNING", "ERROR", "CRITICAL"]
10
10
 
11
11
 
12
- def configure_logging(log_level: str = "INFO"):
12
+ def remove_secrets(message: str, secrets: list[str]) -> str:
13
+ for secret in secrets:
14
+ message = message.replace(secret, "***")
15
+ return message
16
+
17
+
18
+ class SecretsHider(logging.Filter):
19
+ def __init__(self, secrets: list[str], name: str = "") -> None:
20
+ self.secrets = secrets
21
+ super().__init__(name)
22
+
23
+ def filter(self, record: logging.LogRecord) -> bool:
24
+ record.msg = remove_secrets(record.msg, self.secrets)
25
+ return True
26
+
27
+
28
+ dangerous_keys = ["key", "id", "secret"]
29
+ safe_keys: list[str] = ["/"]
30
+
31
+
32
+ def hide_secrets(handler: logging.Handler, secrets_dict: dict[str, str]) -> None:
33
+ secrets_to_hide = set()
34
+ for key, value in secrets_dict.items():
35
+ if not isinstance(value, str):
36
+ continue
37
+ key_lower = key.lower()
38
+ if any(safe in key_lower for safe in safe_keys):
39
+ continue
40
+ if any(danger in key_lower for danger in dangerous_keys):
41
+ secrets_to_hide.add(value)
42
+ handler.addFilter(SecretsHider(list(secrets_to_hide), name="secrets-hider"))
43
+
44
+
45
+ def configure_logging(log_level: str = "INFO") -> logging.Handler:
13
46
  _LogLevel(log_level=log_level) # type: ignore
47
+ handler = RichHandler(rich_tracebacks=True)
14
48
  logging.basicConfig(
15
49
  level=logging.getLevelName(log_level),
16
50
  format="%(message)s",
17
51
  datefmt="[%X]",
18
- handlers=[RichHandler(rich_tracebacks=True)],
52
+ handlers=[handler],
19
53
  )
54
+ return handler
@@ -0,0 +1,149 @@
1
+ # This file is maintained automatically by "terraform init".
2
+ # Manual edits may be lost in future updates.
3
+
4
+ provider "registry.terraform.io/hashicorp/aws" {
5
+ version = "5.49.0"
6
+ constraints = "~> 5.0"
7
+ hashes = [
8
+ "h1:BKrMq4aIOvXbJA9fd0kdmIm3Q01MQcheDIEzXtrkNf4=",
9
+ "h1:EMzIW40AXkmr5qYv2ynb6ToWO7oRwMNYHwHo20kXAdY=",
10
+ "h1:HemCol/k4BjtyRE6GpfECiFU7JF+O3ayqfVQBwsgizQ=",
11
+ "h1:RZtXnBRpO4LNmmz0tXJQLa2heqk9VFGblFZtRCZkm/M=",
12
+ "h1:Y3xvYjzBIwYSbcnZDcs6moiy30uxRoY5oT2ExQHKG5A=",
13
+ "zh:0979b07cdeffb868ea605e4bbc008adc7cccb5f3ba1d3a0b794ea3e8fff20932",
14
+ "zh:2121a0a048a1d9419df69f3561e524b7e8a6b74ba0f57bd8948799f12b6ad3a1",
15
+ "zh:573362042ba0bd18e98567a4f45d91b09eb0d223513518ba04f16a646a906403",
16
+ "zh:57be7a4d6c362be2fa586d270203f4eac1ee239816239a9503b86ebc8fa1fef0",
17
+ "zh:5c72ed211d9234edd70eac9d77c3cafc7bbf819d1c28332a6d77acf227c9a23c",
18
+ "zh:7786d1a9781f8e8c0079bf58f4ed4aeddec0caf54ad7ddcf43c47936d545a04f",
19
+ "zh:82133e7d39787ee91ed41988da71beecc2ecb900b5da94b3f3d77fbc4d4dc722",
20
+ "zh:8cdb1c154dead85be8352afd30eaf41c59249de9e7e0a8eb4ab8e625b90a4922",
21
+ "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425",
22
+ "zh:ac215fd1c3bd647ae38868940651b97a53197688daefcd70b3595c84560e5267",
23
+ "zh:c45db22356d20e431639061a72e07da5201f4937c1df6b9f03f32019facf3905",
24
+ "zh:c9ba90e62db9a4708ed1a4e094849f88ce9d44c52b49f613b30bb3f7523b8d97",
25
+ "zh:d2be3607be2209995c80dc1d66086d527de5d470f73509e813254067e8287106",
26
+ "zh:e3fa20090f3cebf3911fc7ef122bd8c0505e3330ab7d541fa945fea861205007",
27
+ "zh:ef1b9d5c0b6279323f2ecfc322db8083e141984cfe1bb2f33c0f4934fccb69e3",
28
+ ]
29
+ }
30
+
31
+ provider "registry.terraform.io/hashicorp/http" {
32
+ version = "3.4.2"
33
+ constraints = "3.4.2"
34
+ hashes = [
35
+ "h1:Te941FhpXymGvOraU9IQiMrvDVCMAF4gwjvyVZuvRtk=",
36
+ "h1:YxJewcIIT5sF2h8N+F7eZMsdEimpDpveAOzq/RUiUEo=",
37
+ "h1:eqo0hkFNrixeaT93PC5NiU893s7rUwwOMeqnCjjj3u0=",
38
+ "h1:v6Hn+15SfN2SI281Sp+uNXdWhD197ycP07fnaoGpPcc=",
39
+ "h1:vaoPfsLm6mOk6avKTrWi35o+9p4fEeZAY3hzYoXVTfo=",
40
+ "zh:0ba051c9c8659ce0fec94a3d50926745f11759509c4d6de0ad5f5eb289f0edd9",
41
+ "zh:23e6760e8406fef645913bf47bfab1ca984c1c5805d2bb0ef8310b16913d29cd",
42
+ "zh:3c69fde4548bfe65b968534c4df8d699648c921d6a065b97fec5faece73a442b",
43
+ "zh:41c7f9a8c117704b7a8fa96a57ebfb92b72129d9625128eeb0dee7d5a09d1110",
44
+ "zh:59d09d2e00727df10565cc82a33250b44201fcd353eb2b1579507a5a0adcce18",
45
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
46
+ "zh:c95b2f63d4357b3068531b90d9dca62a32551d7693defb7ab14b650b5d139c57",
47
+ "zh:cc0a3bbd3026191b35f417d3a8f26bdfad376d15be9e8d99a8803487ca5b0105",
48
+ "zh:d1185c6abb3ba25123fb7df1ad7dbe2b9cd8f43962628da551040fbe1934656f",
49
+ "zh:dfb26fccab7ecdc150f67415e6cfe19d699dc43e8bf5722f36032b17b46a0fbe",
50
+ "zh:eb1fcc00073bc0463f64e49600a73d925b1a0c0ae5b94dd7b67d3ebac248a113",
51
+ "zh:ec9b9ad69cf790cb0603a1036d758063bbbc35c0c75f72dd04a1eddaf46ad010",
52
+ ]
53
+ }
54
+
55
+ provider "registry.terraform.io/hashicorp/local" {
56
+ version = "2.4.1"
57
+ constraints = "2.4.1"
58
+ hashes = [
59
+ "h1:7lfUMKAsu/HRUUs02tJxBle9XvSuNKkpTOqcFqMe5JI=",
60
+ "h1:FzraUapGrJoH3ZOWiUT2m6QpZAD+HmU+JmqZgM4/o2Y=",
61
+ "h1:V2G4qygMV0uHy+QTMlrjSyYgzpYmYyB6gWuE09+5CPI=",
62
+ "h1:gpp25uNkYJYzJVnkyRr7RIBVfwLs9GSq2HNnFpTRBg0=",
63
+ "h1:kgA44Hg57WNSNH/tEzpOSLEk7U3fkAkYxActZEvX0Q4=",
64
+ "zh:244b445bf34ddbd167731cc6c6b95bbed231dc4493f8cc34bd6850cfe1f78528",
65
+ "zh:3c330bdb626123228a0d1b1daa6c741b4d5d484ab1c7ae5d2f48d4c9885cc5e9",
66
+ "zh:5ff5f9b791ddd7557e815449173f2db38d338e674d2d91800ac6e6d808de1d1d",
67
+ "zh:70206147104f4bf26ae67d730c995772f85bf23e28c2c2e7612c74f4dae3c46f",
68
+ "zh:75029676993accd6bef933c196b2fad51a9ec8a69a847dbbe96ec8ebf7926cdc",
69
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
70
+ "zh:7d48d5999fe1fcdae9295a7c3448ac1541f5a24c474bd82df6d4fa3732483f2b",
71
+ "zh:b766b38b027f0f84028244d1c2f990431a37d4fc3ac645962924554016507e77",
72
+ "zh:bfc7ad301dada204cf51c59d8bd6a9a87de5fddb42190b4d6ba157d6e08a1f10",
73
+ "zh:c902b527702a8c5e2c25a6637d07bbb1690cb6c1e63917a5f6dc460efd18d43f",
74
+ "zh:d68ae0e1070cf429c46586bc87580c3ed113f76241da2b6e4f1a8348126b3c46",
75
+ "zh:f4903fd89f7c92a346ae9e666c2d0b6884c4474ae109e9b4bd15e7efaa4bfc29",
76
+ ]
77
+ }
78
+
79
+ provider "registry.terraform.io/hashicorp/null" {
80
+ version = "3.2.2"
81
+ hashes = [
82
+ "h1:Gef5VGfobY5uokA5nV/zFvWeMNR2Pmq79DH94QnNZPM=",
83
+ "h1:IMVAUHKoydFrlPrl9OzasDnw/8ntZFerCC9iXw1rXQY=",
84
+ "h1:m467k2tZ9cdFFgHW7LPBK2GLPH43LC6wc3ppxr8yvoE=",
85
+ "h1:vWAsYRd7MjYr3adj8BVKRohVfHpWQdvkIwUQ2Jf5FVM=",
86
+ "h1:zT1ZbegaAYHwQa+QwIFugArWikRJI9dqohj8xb0GY88=",
87
+ "zh:3248aae6a2198f3ec8394218d05bd5e42be59f43a3a7c0b71c66ec0df08b69e7",
88
+ "zh:32b1aaa1c3013d33c245493f4a65465eab9436b454d250102729321a44c8ab9a",
89
+ "zh:38eff7e470acb48f66380a73a5c7cdd76cc9b9c9ba9a7249c7991488abe22fe3",
90
+ "zh:4c2f1faee67af104f5f9e711c4574ff4d298afaa8a420680b0cb55d7bbc65606",
91
+ "zh:544b33b757c0b954dbb87db83a5ad921edd61f02f1dc86c6186a5ea86465b546",
92
+ "zh:696cf785090e1e8cf1587499516b0494f47413b43cb99877ad97f5d0de3dc539",
93
+ "zh:6e301f34757b5d265ae44467d95306d61bef5e41930be1365f5a8dcf80f59452",
94
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
95
+ "zh:913a929070c819e59e94bb37a2a253c228f83921136ff4a7aa1a178c7cce5422",
96
+ "zh:aa9015926cd152425dbf86d1abdbc74bfe0e1ba3d26b3db35051d7b9ca9f72ae",
97
+ "zh:bb04798b016e1e1d49bcc76d62c53b56c88c63d6f2dfe38821afef17c416a0e1",
98
+ "zh:c23084e1b23577de22603cff752e59128d83cfecc2e6819edadd8cf7a10af11e",
99
+ ]
100
+ }
101
+
102
+ provider "registry.terraform.io/hashicorp/random" {
103
+ version = "3.6.1"
104
+ hashes = [
105
+ "h1:12+TxYsSS5bzT7uiE2w0ke2WxmhehRV7uKU1wKUUnmM=",
106
+ "h1:1OlP753r4lOKlBprL0HdZGWerm5DCabD5Mli8k8lWAg=",
107
+ "h1:8iqExjtAvirFTJkpm5YyYD+fC+DGV8NTJzKsE2c70VA=",
108
+ "h1:Xx3UvdKXObNTjfd4yYHDcFalYZujg7NBY/VpZISiTb4=",
109
+ "h1:a+Goawwh6Qtg4/bRWzfDtIdrEFfPlnVy0y4LdUQY3nI=",
110
+ "zh:2a0ec154e39911f19c8214acd6241e469157489fc56b6c739f45fbed5896a176",
111
+ "zh:57f4e553224a5e849c99131f5e5294be3a7adcabe2d867d8a4fef8d0976e0e52",
112
+ "zh:58f09948c608e601bd9d0a9e47dcb78e2b2c13b4bda4d8f097d09152ea9e91c5",
113
+ "zh:5c2a297146ed6fb3fe934c800e78380f700f49ff24dbb5fb5463134948e3a65f",
114
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
115
+ "zh:7ce41e26f0603e31cdac849085fc99e5cd5b3b73414c6c6d955c0ceb249b593f",
116
+ "zh:8c9e8d30c4ef08ee8bcc4294dbf3c2115cd7d9049c6ba21422bd3471d92faf8a",
117
+ "zh:93e91be717a7ffbd6410120eb925ebb8658cc8f563de35a8b53804d33c51c8b0",
118
+ "zh:982542e921970d727ce10ed64795bf36c4dec77a5db0741d4665230d12250a0d",
119
+ "zh:b9d1873f14d6033e216510ef541c891f44d249464f13cc07d3f782d09c7d18de",
120
+ "zh:cfe27faa0bc9556391c8803ade135a5856c34a3fe85b9ae3bdd515013c0c87c1",
121
+ "zh:e4aabf3184bbb556b89e4b195eab1514c86a2914dd01c23ad9813ec17e863a8a",
122
+ ]
123
+ }
124
+
125
+ provider "registry.terraform.io/mongodb/mongodbatlas" {
126
+ version = "1.16.0"
127
+ constraints = ">= 1.4.3, 1.16.0"
128
+ hashes = [
129
+ "h1:3xNtkJvf24ChFvQm8yl7QCf2K/KOJNF4UQNpDiZgATo=",
130
+ "h1:Hmk5/O4IyOsLAc4sEChPkrP0bGetebqR0Wrz0RUNGvs=",
131
+ "h1:IP2Gb4KrKAwmUSG5B0oqKYQOyGQjkeazVokw+TIuVcU=",
132
+ "h1:cWeuysKYmhgvWhf6g7kC5yKsgP7uNzTFTapcAxAHMkQ=",
133
+ "h1:nRsHPefWnvdHuPKUUlamC65meS60AvSg8UNL2Jp0P04=",
134
+ "zh:086a72493614a00fd5e38c7c0d077269f0069dd0d9d0cbfa1b0b1834278870b3",
135
+ "zh:11489ece5a1683f65ea64898c8a4cd06300cd91ae8bebbf05631020d5b549186",
136
+ "zh:4a45180e6d951affb27cab0320c845fb97e1e5e0396227d9f38a27f70ede113b",
137
+ "zh:4c63c33f100d20af6cce8d3c66f7c9df9a1b8d777c402a085bd888185d6c8ac5",
138
+ "zh:673cb0986e2a3b6de919f5778c574842cc26502a75b1d197bf2dae5758b5b98b",
139
+ "zh:7822d563d0ddaefbc476fbfd8772edc0bc7a7e53304eeb2e34ad827947e36601",
140
+ "zh:7ad9a83ae72e83b1c179dd2952b16b2d1e31a34ea62ab685eb3b97025a0cf8be",
141
+ "zh:928aed6481fdd7a81dd9127068438533c76ddb34fbb4cd9da71c8398bd7edefc",
142
+ "zh:932543248081671d8cc5a3dcbc46cf0e4e83d3a2c333f5486e78677509b0718c",
143
+ "zh:968bb58413656bd2064776cb9c5a4f435beebbe63edcbe3801d82a558be14bcf",
144
+ "zh:b88b4368b501aa0159c3804d82b61e5ef71c380dd6889424003a4ca37c5aff5f",
145
+ "zh:c9a98c72d1b6183dec7555a90ad0ed8a3741820d998332c33cd9a08ea26e78b4",
146
+ "zh:d2f1f716cd8a3de58f23f384254847aa06eb3e0b0fe5d7ffe13aec7ada3d69ef",
147
+ "zh:d70d14be3db7a1d8bb2528d8761bb8dc02ca4a06ee14657e57d2b2cec6217e13",
148
+ ]
149
+ }
atlas_init/tf/always.tf CHANGED
@@ -9,6 +9,7 @@ resource "random_password" "username" {
9
9
  }
10
10
 
11
11
  data "http" "myip" {
12
+ count = var.use_project_myip ? 1 : 0
12
13
  url = "https://ipv4.icanhazip.com"
13
14
  }
14
15
 
@@ -38,6 +39,7 @@ resource "mongodbatlas_project" "project" {
38
39
  }
39
40
 
40
41
  resource "mongodbatlas_project_ip_access_list" "mongo-access" {
42
+ count = var.use_project_myip ? 1 : 0
41
43
  project_id = mongodbatlas_project.project.id
42
- cidr_block = "${chomp(data.http.myip.response_body)}/32"
43
- }
44
+ cidr_block = "${chomp(data.http.myip[0].response_body)}/32"
45
+ }
@@ -33,6 +33,11 @@ variable "project_name" {
33
33
  }
34
34
  }
35
35
 
36
+ variable "use_project_myip" {
37
+ type = bool
38
+ default = false
39
+ }
40
+
36
41
  variable "out_dir" {
37
42
  type = string
38
43
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: atlas-init
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Project-URL: Documentation, https://github.com/EspenAlbert/atlas-init#readme
5
5
  Project-URL: Issues, https://github.com/EspenAlbert/atlas-init/issues
6
6
  Project-URL: Source, https://github.com/EspenAlbert/atlas-init
@@ -23,7 +23,9 @@ Requires-Dist: tenacity==8.2.3
23
23
  Requires-Dist: typer==0.12.0
24
24
  Description-Content-Type: text/markdown
25
25
 
26
- # Atlas Init - A CLI for developing with MongoDB Atlas
26
+ # Atlas Init - A CLI for developing integrations with MongoDB Atlas
27
+
28
+ [![codecov](https://codecov.io/github/EspenAlbert/atlas-init/graph/badge.svg?token=DR7FDJXNZY)](https://codecov.io/github/EspenAlbert/atlas-init)
27
29
 
28
30
  Currently, used with
29
31
  - <https://github.com/mongodb/terraform-provider-mongodbatlas>
@@ -68,6 +70,8 @@ source .venv/bin/activate # ensure you are in your preferred python env
68
70
  ### 2. Local development, run from github repo
69
71
 
70
72
  ```shell
73
+ git clone https://github.com/EspenAlbert/atlas-init
74
+ cd atlas-init
71
75
  brew install pre-commit uv hatch
72
76
  # https://github.com/astral-sh/uv <-- python packaging lightning fast
73
77
  # https://hatch.pypa.io/latest/ <-- uv compatible build system for python
@@ -76,19 +80,25 @@ pre-commit install
76
80
 
77
81
  # check that everything works
78
82
  pre-commit run --all-files
83
+
84
+ # configure your virtualenv
79
85
  cd py
80
86
  hatch test
81
- VENV_PATH=$(hatch env find hatch-test) # your venv path
82
- cd ..
87
+ export VENV_DIR=$(hatch env find hatch-test | grep py3.12) # hatch venv path for env=hatch-test
88
+ export VENV_PYTHON=$VENV_DIR/bin/python
89
+ $VENV_PYTHON # ensure you are in shell with python3.12 (cmd+d to exit)
90
+ cd .. # back to repo root
83
91
 
84
- # open in your IDE
92
+ # open in your IDE with virtualenv enabled
85
93
  code .
86
- # select venv path from $VENV_PATH output
94
+ # select venv path from $VENV_PYTHON output as python interpreter
87
95
 
88
96
  # to make it easy to invoke from any terminal
89
- export pyexe=$(which python) # VENV_PATH above
90
- export pypath=$(pwd)/py
91
- echo "alias atlas_init='export PYTHONPATH=$pypath && \"$pyexe\" -m atlas_init'" >> ~/.zprofile # replace with your shell profile
97
+ export pypath=$(pwd)/py # pwd=repo root(atlas-init)
98
+ echo "alias atlas_init='export PYTHONPATH=$pypath && \"$VENV_PYTHON\" -m atlas_init'" >> ~/.zprofile # replace with your shell profile
99
+
100
+ # test that it works
101
+ atlas_init # should show how to use the cli
92
102
  ```
93
103
 
94
104
  ### 3. `pip install` local wheel
@@ -140,3 +150,12 @@ provider_installation {
140
150
 
141
151
  }
142
152
  ```
153
+
154
+ ### Re-generating the lock files
155
+ ```shell
156
+ terraform providers lock \
157
+ -platform=darwin_amd64 \
158
+ -platform=linux_amd64 \
159
+ -platform=darwin_arm64 \
160
+ -platform=linux_arm64
161
+ # -platform=windows_amd64 \
@@ -1,7 +1,7 @@
1
- atlas_init/__init__.py,sha256=F14PVpz01PXFYFq9nBPKgNteb0-NOECpL4K9CS8TWLY,376
1
+ atlas_init/__init__.py,sha256=nxYhj4r6g5B1cOn6xF2mSn99hp8VxU4lXIg4funFVnc,376
2
2
  atlas_init/__main__.py,sha256=dY1dWWvwxRZMmnOFla6RSfti-hMeLeKdoXP7SVYqMUc,52
3
- atlas_init/atlas_init.yaml,sha256=z1yqKwwjxbYuLs0pJ5v8Ao33ntqdUQo-2hGvYPdkH_I,1552
4
- atlas_init/cli.py,sha256=XrWxi1_-9lgit4h5e2f_sWpdGEuEUf2bsrHVSP-p88c,9168
3
+ atlas_init/atlas_init.yaml,sha256=qC4zHwmqm6ui9VuAwE3tYrIFDklQ0Gm1Sh9il2l2WdQ,1518
4
+ atlas_init/cli.py,sha256=FbSCjKikTAOrrxyA5cPqqIcEK5hHy4y4pBw6AO46AkM,9639
5
5
  atlas_init/cli_args.py,sha256=6ucjRGLGde1XcZIfUCGrWbmQLJB9bWZaXxyAsYXMSSw,427
6
6
  atlas_init/terraform.yaml,sha256=5Cxaru1FpnSJqHKRZ7j8YDhMV4h50e3iiahBz3eWlD0,726
7
7
  atlas_init/cli_cfn/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -9,11 +9,11 @@ atlas_init/cli_cfn/app.py,sha256=6Y_KZ5WH_sOr24AO-7JdwrVsAdGXy5grUE575uIs30U,985
9
9
  atlas_init/cli_cfn/cfn.py,sha256=87G3VpMWmus7pY06rWu_s3lFPAJeYn85I43dH5w0cDQ,12492
10
10
  atlas_init/cli_cfn/cfn_parameter_finder.py,sha256=QFlLrWh0g4HwGAlK_M9OmhG61mTtxIBGzSx1VgDSMfs,7441
11
11
  atlas_init/cli_helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- atlas_init/cli_helper/go.py,sha256=-pmW9CQ45wgAksjHcQ8rGKwu2QB62RYe2M_R4D1ia20,1047
12
+ atlas_init/cli_helper/go.py,sha256=LVMXTWvEYOHOul_UG5uQT3QAoL0H1f1O7e4d-11kPrw,1232
13
13
  atlas_init/cli_helper/run.py,sha256=NEjFP1yttPe3Sg9JFnDbRreEWProb-plvKwomBsQz8w,2517
14
14
  atlas_init/cli_helper/sdk.py,sha256=exh58-VZwxtosaxM269C62EEy1VnpJPOVziPDPkGsmE,2983
15
15
  atlas_init/cli_helper/sdk_auto_changes.py,sha256=oWyXw7P0PdO28hclRvza_RcIVXAyzu0lCYTJTNBDMeo,189
16
- atlas_init/cli_helper/tf_runner.py,sha256=M4CTfUg5YHnel8vULXx0r63ViFh1tSklKio0t2h4sv8,3799
16
+ atlas_init/cli_helper/tf_runner.py,sha256=vNi8f34LJZkPnvZZnB2MMyfTVMBPwS_1nrD-stO0-iM,3690
17
17
  atlas_init/cli_tf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  atlas_init/cli_tf/app.py,sha256=Xspc5qp3f4Uir5hgxcF3DaFg28ld1iWARtbhfq7uI04,2644
19
19
  atlas_init/cli_tf/schema.py,sha256=AFALXAju4OBVZQ8T9REtoench6HKmQ88bmmzHC_BxII,3258
@@ -25,16 +25,17 @@ atlas_init/repos/cfn.py,sha256=zSrQ_csdh5HsO7Yoc_bC65j9SMsiSYEhd_0ug8gAIb8,2279
25
25
  atlas_init/repos/go_sdk.py,sha256=6_ENYMP6yQufo1dXJbLJFDxCuq-8oeTYiGAPC61Uauc,424
26
26
  atlas_init/repos/path.py,sha256=N1VdelcMb2YuNbdoZtyL9ChuFEu7Kz4VwOIV7eefzTE,4160
27
27
  atlas_init/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- atlas_init/settings/config.py,sha256=0OC1xFSIVhPFub743Aa8kncWH9c4iP7ByIgu9OA3-6Q,5523
29
- atlas_init/settings/env_vars.py,sha256=NdMAC333wcgQqeUT8xSktNQdaI-fNAnEf7PEreGjvpw,8423
28
+ atlas_init/settings/config.py,sha256=eg1KfDRAbJezpaVTaPYKlteTnzNRm189ZMhg2WPbE9Y,5894
29
+ atlas_init/settings/env_vars.py,sha256=OReAsZ7M4fUZrqSeEoPqizjeRXhEyCpZtB7nqYHdnmY,8745
30
30
  atlas_init/settings/interactive.py,sha256=Xy1Z5WMAOSaJ-vQI_4xjAbSR92rWQgnffwVoDT27L68,340
31
31
  atlas_init/settings/path.py,sha256=Dbp-C8Cr5Q7E-QSpY6_Pe30nNx_e8hT_RYzKn-3fCO4,1998
32
- atlas_init/settings/rich_utils.py,sha256=oMHAGlxouJxS0-4IaHww9DTObV91TvrflR6pGJcGF68,491
33
- atlas_init/tf/always.tf,sha256=QB9FchXSmjZxPfDHtMDk3eRRo9ATL5lFy5wYj8j0UQE,1020
32
+ atlas_init/settings/rich_utils.py,sha256=J75-LGMtGwUAkCwCtjU2DyOeesiFB7rKP54NPb_6UmA,1601
33
+ atlas_init/tf/.terraform.lock.hcl,sha256=wyL4o4Hy1L_9M3U7tXqdZC4OX0uHypCv4MQqZKaeZEI,8206
34
+ atlas_init/tf/always.tf,sha256=dYd7JfxLpeE3sl2jUtbSb6CVya4EuIx9IeFqyE4zCL0,1102
34
35
  atlas_init/tf/main.tf,sha256=0ZH1QiBPmE1rQQoOookddfWoNJZLzoQDZPrtGKhkT6c,3824
35
36
  atlas_init/tf/outputs.tf,sha256=z5VtLuUia4GPzx3Kw0ECUW68Az0p_zvE8PVtZwPfx4w,3452
36
37
  atlas_init/tf/providers.tf,sha256=aBRwlUPQctHMFkFvrXs43Iq9b1og1wo0uSTsbKVt7_g,724
37
- atlas_init/tf/variables.tf,sha256=uH0Nl5AxCjZd4exPz6hUnrB4b0hpPCTW_3_1C4fWJXw,1860
38
+ atlas_init/tf/variables.tf,sha256=-sW-2lNJD2sOIAodUsN-6SKkLIbznOGYVKVYcxsvPQw,1925
38
39
  atlas_init/tf/modules/aws_s3/aws_s3.tf,sha256=SP5vZf5Y2g9Z5yWpBKSKzEEF5FITPycoGKe-kaHoVCI,738
39
40
  atlas_init/tf/modules/aws_s3/provider.tf,sha256=MokTWfkT2IPWfIgGbKcX-UC_PycO9TzjZDOeFA9PLRM,162
40
41
  atlas_init/tf/modules/aws_vars/aws_vars.tf,sha256=VcVOIt-VCu2UdGddN6SjLkavLl-JGex64RnSEIZhWpw,386
@@ -55,7 +56,7 @@ atlas_init/tf/modules/vpc_peering/vpc_peering.tf,sha256=sRmteM23eTQcrTFLjaxeGTXS
55
56
  atlas_init/tf/modules/vpc_privatelink/atlas-privatelink.tf,sha256=FloaaX1MNDvoMZxBnEopeLKyfIlq6kaX2dmx8WWlXNU,1298
56
57
  atlas_init/tf/modules/vpc_privatelink/variables.tf,sha256=gktHCDYD4rz6CEpLg5aiXcFbugw4L5S2Fqc52QYdJyc,255
57
58
  atlas_init/tf/modules/vpc_privatelink/versions.tf,sha256=GlmYD7fOBe4cbILEXX9UjIr1rJKLIaqL_cDGc2u6upg,238
58
- atlas_init-0.1.0.dist-info/METADATA,sha256=Kifr-peIohM93DIQcjrJvtH3Yf2BBsDDKp4z7X8rCPs,4763
59
- atlas_init-0.1.0.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
60
- atlas_init-0.1.0.dist-info/entry_points.txt,sha256=6Ycq_NZ7cym1BCA9YiVhYylJzy6woREjt7QSCSLm-1o,54
61
- atlas_init-0.1.0.dist-info/RECORD,,
59
+ atlas_init-0.1.1.dist-info/METADATA,sha256=Qo8FMgBaZ37BEKYxVvcTQ-FlJ0h96oIOs38nn05wJoI,5504
60
+ atlas_init-0.1.1.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
61
+ atlas_init-0.1.1.dist-info/entry_points.txt,sha256=6Ycq_NZ7cym1BCA9YiVhYylJzy6woREjt7QSCSLm-1o,54
62
+ atlas_init-0.1.1.dist-info/RECORD,,