fogies 0.0.0.dev7__tar.gz → 0.0.0.dev8__tar.gz

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 (41) hide show
  1. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/PKG-INFO +1 -1
  2. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/pyproject.toml +1 -1
  3. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/access_key.py +1 -1
  4. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/terraform.py +194 -198
  5. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/terraform_backend.py +197 -201
  6. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/aws_environ.py +22 -9
  7. fogies-0.0.0.dev8/src/fogies/tools/claude_sync.py +130 -0
  8. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/environ.py +25 -16
  9. fogies-0.0.0.dev8/src/fogies/tools/go.py +138 -0
  10. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/ollama.py +1 -0
  11. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/terraform.py +57 -32
  12. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/README.md +0 -0
  13. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/__init__.py +0 -0
  14. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/aws_access_key.py +0 -0
  15. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/aws.toml.template +0 -0
  16. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/backend_status.toml.template +0 -0
  17. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/poetry.toml.template +0 -0
  18. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/py.typed +0 -0
  19. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/pyfogies.py +0 -0
  20. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/ready_poll.py +0 -0
  21. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/retry.py +0 -0
  22. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/__init__.py +0 -0
  23. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/format.py +0 -0
  24. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/lint.py +0 -0
  25. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/poetry.py +0 -0
  26. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/test.py +0 -0
  27. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/templates.py +0 -0
  28. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/__init__.py +0 -0
  29. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/access_key_permissions.py +0 -0
  30. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/alb.py +0 -0
  31. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/backend.py +0 -0
  32. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/cloudwatch.py +0 -0
  33. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/ecr.py +0 -0
  34. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/ecs.py +0 -0
  35. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/hosted_zone.py +0 -0
  36. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/network.py +0 -0
  37. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/__init__.py +0 -0
  38. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/boto.py +0 -0
  39. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/command.py +0 -0
  40. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/terraform_backend.py +0 -0
  41. {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/typing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fogies
3
- Version: 0.0.0.dev7
3
+ Version: 0.0.0.dev8
4
4
  Summary:
5
5
  Author: James Fogarty
6
6
  Author-email: jayfo@users.noreply.github.com
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "fogies"
3
3
  # Version follows semantic versioning <https://semver.org/>.
4
- version = "0.0.0-dev.7"
4
+ version = "0.0.0-dev.8"
5
5
  description = ""
6
6
  authors = [
7
7
  {name = "James Fogarty",email = "jayfo@users.noreply.github.com"}
@@ -54,7 +54,7 @@ def _resolve_admin_environ(
54
54
  with contextlib.ExitStack() as stack:
55
55
  try:
56
56
  env = stack.enter_context(
57
- aws_environ_from_profile(profile=profile, raise_if_exists=False)
57
+ aws_environ_from_profile(profile=profile, raise_if_env_exists=False)
58
58
  )
59
59
  except ValueError as exc:
60
60
  raise SystemExit(str(exc)) from exc
@@ -1,198 +1,194 @@
1
- """Generic tasks for applying and destroying a Terraform configuration."""
2
-
3
- import pathlib
4
- from contextlib import ExitStack
5
- from typing import Callable, cast
6
-
7
- from invoke.context import Context
8
- from invoke.tasks import Task, task
9
-
10
- from fogies.terraform.backend import BackendConfig
11
- from fogies.tools.aws_environ import AwsEnvironFactory
12
- from fogies.tools.command import CommandParams
13
- from fogies.tools.terraform import (
14
- ApplyParams,
15
- DestroyParams,
16
- InitParams,
17
- TfbackendFactory,
18
- TfvarsFactory,
19
- terraform,
20
- terraform_templated,
21
- )
22
-
23
-
24
- def get_task_apply(
25
- *,
26
- binary_cache_path: pathlib.Path,
27
- module_path: pathlib.Path,
28
- aws_environ_factory: AwsEnvironFactory | None = None,
29
- backend: BackendConfig | None = None,
30
- backend_status_path: pathlib.Path | None = None,
31
- tfbackend_factory: TfbackendFactory | None = None,
32
- tfvars_factory: TfvarsFactory | None = None,
33
- default_init: bool = True,
34
- default_init_upgrade: bool = False,
35
- default_init_reconfigure: bool = False,
36
- default_apply_auto_approve: bool = False,
37
- ) -> Task[Callable[[Context, bool, bool, bool, bool], None]]:
38
- if backend is not None and tfbackend_factory is None:
39
- raise ValueError("tfbackend_factory is required when backend is set")
40
- if (backend_status_path is None) != (backend is None):
41
- raise ValueError("backend_status_path and backend must be provided together")
42
-
43
- @task(name="apply") # pyright: ignore[reportUntypedFunctionDecorator]
44
- def task_apply(
45
- context: Context,
46
- init: bool = default_init,
47
- init_upgrade: bool = default_init_upgrade,
48
- init_reconfigure: bool = default_init_reconfigure,
49
- apply_auto_approve: bool = default_apply_auto_approve,
50
- ) -> None:
51
- """
52
- Apply a Terraform configuration.
53
-
54
- Flags:
55
- --init Run terraform init before apply (downloads providers, sets up backend).
56
- --init-upgrade Pass -upgrade to init; checks for newer provider versions within constraints.
57
- --init-reconfigure Pass -reconfigure to init; re-initializes backend from scratch.
58
- --apply-auto-approve Skip Terraform's interactive confirmation prompt.
59
-
60
- --init-upgrade and --init-reconfigure require --init.
61
- """
62
- if init_upgrade and not init:
63
- raise ValueError("--init-upgrade requires --init")
64
- if init_reconfigure and not init:
65
- raise ValueError("--init-reconfigure requires --init")
66
-
67
- command_params = CommandParams(context=context)
68
- init_params = (
69
- InitParams(upgrade=init_upgrade, reconfigure=init_reconfigure)
70
- if init
71
- else None
72
- )
73
-
74
- with ExitStack() as stack:
75
- templated_paths = stack.enter_context(
76
- terraform_templated(module_path=module_path)
77
- )
78
- if templated_paths:
79
- print("Rendered __PYFOGIES_VERSION__ in:")
80
- for templated_path in templated_paths:
81
- print(" {}".format(templated_path))
82
-
83
- if aws_environ_factory is not None:
84
- _ = stack.enter_context(aws_environ_factory())
85
-
86
- tfbackend_path = (
87
- stack.enter_context(tfbackend_factory()) if tfbackend_factory else None
88
- )
89
- tfvars_path = (
90
- stack.enter_context(tfvars_factory()) if tfvars_factory else None
91
- )
92
-
93
- _ = stack.enter_context(
94
- terraform(
95
- binary_cache_path=binary_cache_path,
96
- command_params=command_params,
97
- module_path=module_path,
98
- backend=backend,
99
- backend_status_path=backend_status_path,
100
- tfbackend_path=tfbackend_path,
101
- tfvars_path=tfvars_path,
102
- init_on_entry=init,
103
- init_params=init_params,
104
- apply_on_entry=True,
105
- apply_params=ApplyParams(auto_approve=apply_auto_approve),
106
- destroy_on_exit=False,
107
- )
108
- )
109
-
110
- return cast(Task[Callable[[Context, bool, bool, bool, bool], None]], task_apply)
111
-
112
-
113
- def get_task_destroy(
114
- *,
115
- binary_cache_path: pathlib.Path,
116
- module_path: pathlib.Path,
117
- aws_environ_factory: AwsEnvironFactory | None = None,
118
- backend: BackendConfig | None = None,
119
- backend_status_path: pathlib.Path | None = None,
120
- tfbackend_factory: TfbackendFactory | None = None,
121
- tfvars_factory: TfvarsFactory | None = None,
122
- default_init: bool = True,
123
- default_init_upgrade: bool = False,
124
- default_init_reconfigure: bool = False,
125
- default_destroy_auto_approve: bool = False,
126
- ) -> Task[Callable[[Context, bool, bool, bool, bool], None]]:
127
- if backend is not None and tfbackend_factory is None:
128
- raise ValueError("tfbackend_factory is required when backend is set")
129
- if (backend_status_path is None) != (backend is None):
130
- raise ValueError("backend_status_path and backend must be provided together")
131
-
132
- @task(name="destroy") # pyright: ignore[reportUntypedFunctionDecorator]
133
- def task_destroy(
134
- context: Context,
135
- init: bool = default_init,
136
- init_upgrade: bool = default_init_upgrade,
137
- init_reconfigure: bool = default_init_reconfigure,
138
- destroy_auto_approve: bool = default_destroy_auto_approve,
139
- ) -> None:
140
- """
141
- Destroy a Terraform configuration.
142
-
143
- Flags:
144
- --init Run terraform init before destroy (downloads providers, sets up backend).
145
- --init-upgrade Pass -upgrade to init; checks for newer provider versions within constraints.
146
- --init-reconfigure Pass -reconfigure to init; re-initializes backend from scratch.
147
- --destroy-auto-approve Skip Terraform's interactive confirmation prompt.
148
-
149
- --init-upgrade and --init-reconfigure require --init.
150
- """
151
- if init_upgrade and not init:
152
- raise ValueError("--init-upgrade requires --init")
153
- if init_reconfigure and not init:
154
- raise ValueError("--init-reconfigure requires --init")
155
-
156
- command_params = CommandParams(context=context)
157
- init_params = (
158
- InitParams(upgrade=init_upgrade, reconfigure=init_reconfigure)
159
- if init
160
- else None
161
- )
162
-
163
- with ExitStack() as stack:
164
- templated_paths = stack.enter_context(
165
- terraform_templated(module_path=module_path)
166
- )
167
- if templated_paths:
168
- print("Rendered __PYFOGIES_VERSION__ in:")
169
- for templated_path in templated_paths:
170
- print(" {}".format(templated_path))
171
-
172
- if aws_environ_factory is not None:
173
- _ = stack.enter_context(aws_environ_factory())
174
-
175
- tfbackend_path = (
176
- stack.enter_context(tfbackend_factory()) if tfbackend_factory else None
177
- )
178
- tfvars_path = (
179
- stack.enter_context(tfvars_factory()) if tfvars_factory else None
180
- )
181
-
182
- _ = stack.enter_context(
183
- terraform(
184
- binary_cache_path=binary_cache_path,
185
- command_params=command_params,
186
- module_path=module_path,
187
- backend=backend,
188
- backend_status_path=backend_status_path,
189
- tfbackend_path=tfbackend_path,
190
- tfvars_path=tfvars_path,
191
- init_on_entry=init,
192
- init_params=init_params,
193
- destroy_on_exit=True,
194
- destroy_params=DestroyParams(auto_approve=destroy_auto_approve),
195
- )
196
- )
197
-
198
- return cast(Task[Callable[[Context, bool, bool, bool, bool], None]], task_destroy)
1
+ """Generic tasks for applying and destroying a Terraform configuration."""
2
+
3
+ import pathlib
4
+ from contextlib import ExitStack
5
+ from typing import Callable, cast
6
+
7
+ from invoke.context import Context
8
+ from invoke.tasks import Task, task
9
+
10
+ from fogies.terraform.backend import BackendConfig
11
+ from fogies.tools.aws_environ import AwsEnvironFactory
12
+ from fogies.tools.command import CommandParams
13
+ from fogies.tools.terraform import (
14
+ ApplyParams,
15
+ DestroyParams,
16
+ InitParams,
17
+ TfbackendFactory,
18
+ TfvarsFactory,
19
+ terraform,
20
+ terraform_templated,
21
+ )
22
+
23
+
24
+ def get_task_apply(
25
+ *,
26
+ binary_cache_path: pathlib.Path,
27
+ module_path: pathlib.Path,
28
+ aws_environ_factory: AwsEnvironFactory | None = None,
29
+ backend: BackendConfig | None = None,
30
+ backend_status_path: pathlib.Path | None = None,
31
+ tfbackend_factory: TfbackendFactory | None = None,
32
+ tfvars_factory: TfvarsFactory | None = None,
33
+ default_init: bool = True,
34
+ default_init_upgrade: bool = False,
35
+ default_init_reconfigure: bool = False,
36
+ default_apply_auto_approve: bool = False,
37
+ ) -> Task[Callable[[Context, bool, bool, bool, bool], None]]:
38
+ if backend is not None and tfbackend_factory is None:
39
+ raise ValueError("tfbackend_factory is required when backend is set")
40
+ if (backend_status_path is None) != (backend is None):
41
+ raise ValueError("backend_status_path and backend must be provided together")
42
+
43
+ @task(name="apply") # pyright: ignore[reportUntypedFunctionDecorator]
44
+ def task_apply(
45
+ context: Context,
46
+ init: bool = default_init,
47
+ init_upgrade: bool = default_init_upgrade,
48
+ init_reconfigure: bool = default_init_reconfigure,
49
+ apply_auto_approve: bool = default_apply_auto_approve,
50
+ ) -> None:
51
+ """
52
+ Apply a Terraform configuration.
53
+
54
+ Flags:
55
+ --init Run terraform init before apply (downloads providers, sets up backend).
56
+ --init-upgrade Pass -upgrade to init; checks for newer provider versions within constraints.
57
+ --init-reconfigure Pass -reconfigure to init; re-initializes backend from scratch.
58
+ --apply-auto-approve Skip Terraform's interactive confirmation prompt.
59
+
60
+ --init-upgrade and --init-reconfigure require --init.
61
+ """
62
+ if init_upgrade and not init:
63
+ raise ValueError("--init-upgrade requires --init")
64
+ if init_reconfigure and not init:
65
+ raise ValueError("--init-reconfigure requires --init")
66
+
67
+ command_params = CommandParams(context=context)
68
+ init_params = (
69
+ InitParams(upgrade=init_upgrade, reconfigure=init_reconfigure)
70
+ if init
71
+ else None
72
+ )
73
+
74
+ with ExitStack() as stack:
75
+ rendered = stack.enter_context(terraform_templated(module_path=module_path))
76
+ if rendered:
77
+ print("Rendered templated placeholders:")
78
+ for rendered_path, placeholders in rendered.items():
79
+ print(" {}: {}".format(rendered_path, ", ".join(placeholders)))
80
+
81
+ if aws_environ_factory is not None:
82
+ _ = stack.enter_context(aws_environ_factory())
83
+
84
+ tfbackend_path = (
85
+ stack.enter_context(tfbackend_factory()) if tfbackend_factory else None
86
+ )
87
+ tfvars_path = (
88
+ stack.enter_context(tfvars_factory()) if tfvars_factory else None
89
+ )
90
+
91
+ _ = stack.enter_context(
92
+ terraform(
93
+ binary_cache_path=binary_cache_path,
94
+ command_params=command_params,
95
+ module_path=module_path,
96
+ backend=backend,
97
+ backend_status_path=backend_status_path,
98
+ tfbackend_path=tfbackend_path,
99
+ tfvars_path=tfvars_path,
100
+ init_on_entry=init,
101
+ init_params=init_params,
102
+ apply_on_entry=True,
103
+ apply_params=ApplyParams(auto_approve=apply_auto_approve),
104
+ destroy_on_exit=False,
105
+ )
106
+ )
107
+
108
+ return cast(Task[Callable[[Context, bool, bool, bool, bool], None]], task_apply)
109
+
110
+
111
+ def get_task_destroy(
112
+ *,
113
+ binary_cache_path: pathlib.Path,
114
+ module_path: pathlib.Path,
115
+ aws_environ_factory: AwsEnvironFactory | None = None,
116
+ backend: BackendConfig | None = None,
117
+ backend_status_path: pathlib.Path | None = None,
118
+ tfbackend_factory: TfbackendFactory | None = None,
119
+ tfvars_factory: TfvarsFactory | None = None,
120
+ default_init: bool = True,
121
+ default_init_upgrade: bool = False,
122
+ default_init_reconfigure: bool = False,
123
+ default_destroy_auto_approve: bool = False,
124
+ ) -> Task[Callable[[Context, bool, bool, bool, bool], None]]:
125
+ if backend is not None and tfbackend_factory is None:
126
+ raise ValueError("tfbackend_factory is required when backend is set")
127
+ if (backend_status_path is None) != (backend is None):
128
+ raise ValueError("backend_status_path and backend must be provided together")
129
+
130
+ @task(name="destroy") # pyright: ignore[reportUntypedFunctionDecorator]
131
+ def task_destroy(
132
+ context: Context,
133
+ init: bool = default_init,
134
+ init_upgrade: bool = default_init_upgrade,
135
+ init_reconfigure: bool = default_init_reconfigure,
136
+ destroy_auto_approve: bool = default_destroy_auto_approve,
137
+ ) -> None:
138
+ """
139
+ Destroy a Terraform configuration.
140
+
141
+ Flags:
142
+ --init Run terraform init before destroy (downloads providers, sets up backend).
143
+ --init-upgrade Pass -upgrade to init; checks for newer provider versions within constraints.
144
+ --init-reconfigure Pass -reconfigure to init; re-initializes backend from scratch.
145
+ --destroy-auto-approve Skip Terraform's interactive confirmation prompt.
146
+
147
+ --init-upgrade and --init-reconfigure require --init.
148
+ """
149
+ if init_upgrade and not init:
150
+ raise ValueError("--init-upgrade requires --init")
151
+ if init_reconfigure and not init:
152
+ raise ValueError("--init-reconfigure requires --init")
153
+
154
+ command_params = CommandParams(context=context)
155
+ init_params = (
156
+ InitParams(upgrade=init_upgrade, reconfigure=init_reconfigure)
157
+ if init
158
+ else None
159
+ )
160
+
161
+ with ExitStack() as stack:
162
+ rendered = stack.enter_context(terraform_templated(module_path=module_path))
163
+ if rendered:
164
+ print("Rendered templated placeholders:")
165
+ for rendered_path, placeholders in rendered.items():
166
+ print(" {}: {}".format(rendered_path, ", ".join(placeholders)))
167
+
168
+ if aws_environ_factory is not None:
169
+ _ = stack.enter_context(aws_environ_factory())
170
+
171
+ tfbackend_path = (
172
+ stack.enter_context(tfbackend_factory()) if tfbackend_factory else None
173
+ )
174
+ tfvars_path = (
175
+ stack.enter_context(tfvars_factory()) if tfvars_factory else None
176
+ )
177
+
178
+ _ = stack.enter_context(
179
+ terraform(
180
+ binary_cache_path=binary_cache_path,
181
+ command_params=command_params,
182
+ module_path=module_path,
183
+ backend=backend,
184
+ backend_status_path=backend_status_path,
185
+ tfbackend_path=tfbackend_path,
186
+ tfvars_path=tfvars_path,
187
+ init_on_entry=init,
188
+ init_params=init_params,
189
+ destroy_on_exit=True,
190
+ destroy_params=DestroyParams(auto_approve=destroy_auto_approve),
191
+ )
192
+ )
193
+
194
+ return cast(Task[Callable[[Context, bool, bool, bool, bool], None]], task_destroy)