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.
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/PKG-INFO +1 -1
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/pyproject.toml +1 -1
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/access_key.py +1 -1
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/terraform.py +194 -198
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/terraform_backend.py +197 -201
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/aws_environ.py +22 -9
- fogies-0.0.0.dev8/src/fogies/tools/claude_sync.py +130 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/environ.py +25 -16
- fogies-0.0.0.dev8/src/fogies/tools/go.py +138 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/ollama.py +1 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/terraform.py +57 -32
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/README.md +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/__init__.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/aws_access_key.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/aws.toml.template +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/backend_status.toml.template +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/includes/templates/poetry.toml.template +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/py.typed +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/pyfogies.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/ready_poll.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/retry.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/__init__.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/format.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/lint.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/poetry.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tasks/test.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/templates.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/__init__.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/access_key_permissions.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/alb.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/backend.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/cloudwatch.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/ecr.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/ecs.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/hosted_zone.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/terraform/network.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/__init__.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/boto.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/command.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/tools/terraform_backend.py +0 -0
- {fogies-0.0.0.dev7 → fogies-0.0.0.dev8}/src/fogies/typing.py +0 -0
|
@@ -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,
|
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if
|
|
128
|
-
raise ValueError("
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
--init
|
|
145
|
-
--
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if
|
|
152
|
-
raise ValueError("--init-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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)
|