netherframe.backends.aws 0.2.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Netherframe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.4
2
+ Name: netherframe.backends.aws
3
+ Version: 0.2.0
4
+ Summary: AWS backend implementations for Netherframe
5
+ Author: Sourabh Cheedella
6
+ Author-email: Sourabh Cheedella <cheedella.sourabh@gmail.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3.14
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Topic :: System :: Systems Administration
14
+ Requires-Dist: netherframe-core>=0.9.0
15
+ Requires-Dist: boto3>=1.44.4
16
+ Requires-Dist: botocore>=1.44.4
17
+ Requires-Dist: pytest>=9.2.0 ; extra == 'dev'
18
+ Requires-Dist: requests>=2.34.2 ; extra == 'dev'
19
+ Requires-Python: >=3.14
20
+ Project-URL: Homepage, https://netherframe.arsenal.sh
21
+ Project-URL: Repository, https://github.com/arsenal-sh/netherframe
22
+ Provides-Extra: dev
23
+ Description-Content-Type: text/markdown
24
+
25
+ # nf.backends.aws
26
+
27
+ AWS backend implementations for Netherframe Infrastructure as Code framework.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install netherframe.backends.aws
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ```python
38
+ from nf.backends.aws import S3Backend
39
+
40
+ # For Terraform synthesis mode
41
+ backend = S3Backend(nf_scope=stack, bucket="my-terraform-state", key="infrastructure/terraform.tfstate", region="us-east-1", dynamodb_table="terraform-locks")
42
+
43
+ # Backend config values must be literal strings. You may pass Resource objects
44
+ # if their input attributes are literal (for example, bucket=state_bucket).
45
+ # Output references like state_bucket.output.id are not supported for Terraform
46
+ # backend configuration.
47
+
48
+ # For native execution mode
49
+ state_backend = S3Backend.for_native(bucket="my-terraform-state", key="infrastructure/terraform.tfstate", region="us-east-1", dynamodb_table="terraform-locks")
50
+ ```
51
+
52
+ ## Features
53
+
54
+ - S3-based state storage with optional DynamoDB locking
55
+ - Compatible with Terraform's S3 backend
56
+ - Support for encryption (SSE-S3 and SSE-KMS)
57
+ - State locking to prevent concurrent modifications
58
+ - Automatic stale lock detection and cleanup, and force-unlock by lock ID (`nf state force-unlock`)
59
+ - Conditional writes: a write replaces only the state version its run read (conditional put on the object's ETag)
60
+ - Pre-apply checkpoints kept beside the state (`<key>.checkpoints/`)
61
+
62
+
63
+ ## Bootstrap security
64
+
65
+ `S3BackendBootstrapper.bootstrap()` treats its bucket as dedicated state storage:
66
+ it explicitly enables all four S3 public-access blocks and BucketOwnerEnforced
67
+ ownership, and adds a scoped deny for non-TLS non-service requests. The service
68
+ exception avoids relying on redacted service-to-service network context.
69
+ Encryption/versioning remain enabled as configured; state history is not expired.
70
+
71
+ Existing policy statements/document metadata are preserved. A conflicting
72
+ Netherframe transport-policy Sid, malformed policy, failed read or legacy ACL
73
+ ownership stops before security-control writes. Migrate legacy ownership
74
+ explicitly rather than disabling ACLs on a shared bucket without review. The
75
+ bootstrap identity needs read/write permissions for these bucket controls.
76
+ This API manages backend controls; don't also declare competing bucket-policy
77
+ writers in an application stack. No transport policy is proof of a successful
78
+ recovery or of effective account-level permissions. `validate()` still checks
79
+ resource existence only, not full security compliance. No new runtime modules
80
+ or architecture topology are introduced.
@@ -0,0 +1,56 @@
1
+ # nf.backends.aws
2
+
3
+ AWS backend implementations for Netherframe Infrastructure as Code framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install netherframe.backends.aws
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from nf.backends.aws import S3Backend
15
+
16
+ # For Terraform synthesis mode
17
+ backend = S3Backend(nf_scope=stack, bucket="my-terraform-state", key="infrastructure/terraform.tfstate", region="us-east-1", dynamodb_table="terraform-locks")
18
+
19
+ # Backend config values must be literal strings. You may pass Resource objects
20
+ # if their input attributes are literal (for example, bucket=state_bucket).
21
+ # Output references like state_bucket.output.id are not supported for Terraform
22
+ # backend configuration.
23
+
24
+ # For native execution mode
25
+ state_backend = S3Backend.for_native(bucket="my-terraform-state", key="infrastructure/terraform.tfstate", region="us-east-1", dynamodb_table="terraform-locks")
26
+ ```
27
+
28
+ ## Features
29
+
30
+ - S3-based state storage with optional DynamoDB locking
31
+ - Compatible with Terraform's S3 backend
32
+ - Support for encryption (SSE-S3 and SSE-KMS)
33
+ - State locking to prevent concurrent modifications
34
+ - Automatic stale lock detection and cleanup, and force-unlock by lock ID (`nf state force-unlock`)
35
+ - Conditional writes: a write replaces only the state version its run read (conditional put on the object's ETag)
36
+ - Pre-apply checkpoints kept beside the state (`<key>.checkpoints/`)
37
+
38
+
39
+ ## Bootstrap security
40
+
41
+ `S3BackendBootstrapper.bootstrap()` treats its bucket as dedicated state storage:
42
+ it explicitly enables all four S3 public-access blocks and BucketOwnerEnforced
43
+ ownership, and adds a scoped deny for non-TLS non-service requests. The service
44
+ exception avoids relying on redacted service-to-service network context.
45
+ Encryption/versioning remain enabled as configured; state history is not expired.
46
+
47
+ Existing policy statements/document metadata are preserved. A conflicting
48
+ Netherframe transport-policy Sid, malformed policy, failed read or legacy ACL
49
+ ownership stops before security-control writes. Migrate legacy ownership
50
+ explicitly rather than disabling ACLs on a shared bucket without review. The
51
+ bootstrap identity needs read/write permissions for these bucket controls.
52
+ This API manages backend controls; don't also declare competing bucket-policy
53
+ writers in an application stack. No transport policy is proof of a successful
54
+ recovery or of effective account-level permissions. `validate()` still checks
55
+ resource existence only, not full security compliance. No new runtime modules
56
+ or architecture topology are introduced.
@@ -0,0 +1,46 @@
1
+ """AWS backend implementations for Netherframe."""
2
+
3
+ from typing import Any
4
+
5
+ from netherframe.backends.aws.s3 import S3Backend
6
+ from netherframe.backends.aws.s3_backend_bootstrap import (
7
+ S3BackendBootstrapper,
8
+ S3BackendResources,
9
+ )
10
+
11
+ __all__ = ["S3Backend", "S3BackendBootstrapper", "S3BackendResources"]
12
+
13
+ from netherframe.core.backends.backend_bootstrap import BackendBootstrapManager
14
+ from netherframe.core.backends.backend_registry import BackendRegistry
15
+
16
+
17
+ def _register_core_components() -> None:
18
+ """Register the backend classes exposed by this package."""
19
+ BackendBootstrapManager.register_bootstrapper("s3", S3BackendBootstrapper)
20
+ BackendRegistry.register_backend_construct("s3", S3Backend, "netherframe.backends.aws")
21
+ BackendRegistry.register_state_backend("s3", S3Backend, "netherframe.backends.aws")
22
+
23
+
24
+ def _s3_backend_factory(config: dict[str, Any]) -> S3Backend:
25
+ """Factory function for creating S3Backend instances."""
26
+ return S3Backend(
27
+ bucket=config["bucket"],
28
+ key=config.get("key", "terraform.tfstate"),
29
+ region=config.get("region"), # Let S3Backend decide default
30
+ dynamodb_table=config.get("dynamodb_table"),
31
+ encrypt=config.get("encrypt", True),
32
+ hybrid_mode=True,
33
+ )
34
+
35
+
36
+ _register_core_components()
37
+
38
+
39
+ def register_backends() -> None:
40
+ """Register AWS backends. Called by entry points."""
41
+ _register_core_components()
42
+ BackendRegistry.register_backend_factory(
43
+ "s3",
44
+ _s3_backend_factory,
45
+ "netherframe.backends.aws",
46
+ )