anvil-cloud 0.0.3__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,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: anvil-cloud
3
+ Version: 0.0.3
4
+ Summary: Anvil — secure-by-default cloud infrastructure components
5
+ Author: Damien Pace
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/anvil-cloud/anvil
8
+ Project-URL: Repository, https://github.com/anvil-cloud/anvil
9
+ Project-URL: Documentation, https://github.com/anvil-cloud/anvil#readme
10
+ Keywords: pulumi,anvil,aws,gcp,cloud,infrastructure
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.8
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: pulumi<4.0.0,>=3.0.0
24
+ Requires-Dist: pulumi-aws<8.0.0,>=7.21.0
25
+ Requires-Dist: pulumi-gcp<10.0.0,>=9.0.0
26
+
27
+ # Anvil — Python SDK
28
+
29
+ Secure-by-default cloud infrastructure components for [Pulumi](https://www.pulumi.com/).
30
+
31
+ Anvil wraps raw cloud resources with opinionated, security-hardened defaults so you ship infrastructure that's secure from day one — without the boilerplate.
32
+
33
+ ## Install
34
+
35
+ ```bash
36
+ pip install anvil-cloud
37
+ ```
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ import pulumi
43
+ import pulumi_anvil as anvil
44
+
45
+ # Create an S3 bucket with encryption, versioning, and public access
46
+ # blocked by default — no 30-line config required.
47
+ bucket = anvil.aws.Bucket("my-data",
48
+ data_classification="sensitive",
49
+ lifecycle=90,
50
+ )
51
+
52
+ pulumi.export("bucket_name", bucket.bucket_name)
53
+ ```
54
+
55
+ ```python
56
+ # Deploy a Lambda function into a VPC
57
+ fn = anvil.aws.Lambda("my-api",
58
+ name="api-handler",
59
+ vpc="vpc-abc123",
60
+ )
61
+ ```
62
+
63
+ ```python
64
+ # GCP Cloud Storage with uniform bucket-level access
65
+ gcs = anvil.gcp.StorageBucket("analytics",
66
+ data_classification="internal",
67
+ location="US",
68
+ )
69
+ ```
70
+
71
+ ## What you get
72
+
73
+ | Component | Cloud | Secure defaults |
74
+ | ------------------------- | ---------------------- | ------------------------------------------------------------------ |
75
+ | `anvil.aws.Bucket` | AWS S3 | Encryption, versioning (sensitive), public access block, lifecycle |
76
+ | `anvil.aws.Lambda` | AWS Lambda | VPC placement, least-privilege role |
77
+ | `anvil.gcp.StorageBucket` | GCP Cloud Storage | Uniform bucket-level access, encryption |
78
+ | `anvil.gcp.Function` | GCP Cloud Functions v2 | Secure defaults |
79
+
80
+ ## Overrides
81
+
82
+ Every component accepts a `transform` argument to override or extend the underlying resource configuration when the defaults don't fit:
83
+
84
+ ```python
85
+ bucket = anvil.aws.Bucket("custom",
86
+ data_classification="public",
87
+ transform=anvil.aws.BucketTransformArgs(
88
+ overrides=anvil.aws.BucketOverrides(
89
+ force_destroy=True,
90
+ tags={"env": "dev"},
91
+ ),
92
+ ),
93
+ )
94
+ ```
95
+
96
+ ## Requirements
97
+
98
+ - Python >= 3.8
99
+ - Pulumi >= 3.0.0
100
+ - The `pulumi-resource-anvil` provider binary (installed via `anvil` CLI or manually)
101
+
102
+ ## Links
103
+
104
+ - [GitHub](https://github.com/anvil-cloud/anvil)
105
+ - [npm (Node SDK)](https://www.npmjs.com/package/@anvil-cloud/sdk)
106
+ - [Go SDK](https://pkg.go.dev/github.com/DamienPace15/anvil/sdk/go/anvil)
107
+
108
+ ## License
109
+
110
+ Apache-2.0
@@ -0,0 +1,84 @@
1
+ # Anvil — Python SDK
2
+
3
+ Secure-by-default cloud infrastructure components for [Pulumi](https://www.pulumi.com/).
4
+
5
+ Anvil wraps raw cloud resources with opinionated, security-hardened defaults so you ship infrastructure that's secure from day one — without the boilerplate.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install anvil-cloud
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```python
16
+ import pulumi
17
+ import pulumi_anvil as anvil
18
+
19
+ # Create an S3 bucket with encryption, versioning, and public access
20
+ # blocked by default — no 30-line config required.
21
+ bucket = anvil.aws.Bucket("my-data",
22
+ data_classification="sensitive",
23
+ lifecycle=90,
24
+ )
25
+
26
+ pulumi.export("bucket_name", bucket.bucket_name)
27
+ ```
28
+
29
+ ```python
30
+ # Deploy a Lambda function into a VPC
31
+ fn = anvil.aws.Lambda("my-api",
32
+ name="api-handler",
33
+ vpc="vpc-abc123",
34
+ )
35
+ ```
36
+
37
+ ```python
38
+ # GCP Cloud Storage with uniform bucket-level access
39
+ gcs = anvil.gcp.StorageBucket("analytics",
40
+ data_classification="internal",
41
+ location="US",
42
+ )
43
+ ```
44
+
45
+ ## What you get
46
+
47
+ | Component | Cloud | Secure defaults |
48
+ | ------------------------- | ---------------------- | ------------------------------------------------------------------ |
49
+ | `anvil.aws.Bucket` | AWS S3 | Encryption, versioning (sensitive), public access block, lifecycle |
50
+ | `anvil.aws.Lambda` | AWS Lambda | VPC placement, least-privilege role |
51
+ | `anvil.gcp.StorageBucket` | GCP Cloud Storage | Uniform bucket-level access, encryption |
52
+ | `anvil.gcp.Function` | GCP Cloud Functions v2 | Secure defaults |
53
+
54
+ ## Overrides
55
+
56
+ Every component accepts a `transform` argument to override or extend the underlying resource configuration when the defaults don't fit:
57
+
58
+ ```python
59
+ bucket = anvil.aws.Bucket("custom",
60
+ data_classification="public",
61
+ transform=anvil.aws.BucketTransformArgs(
62
+ overrides=anvil.aws.BucketOverrides(
63
+ force_destroy=True,
64
+ tags={"env": "dev"},
65
+ ),
66
+ ),
67
+ )
68
+ ```
69
+
70
+ ## Requirements
71
+
72
+ - Python >= 3.8
73
+ - Pulumi >= 3.0.0
74
+ - The `pulumi-resource-anvil` provider binary (installed via `anvil` CLI or manually)
75
+
76
+ ## Links
77
+
78
+ - [GitHub](https://github.com/anvil-cloud/anvil)
79
+ - [npm (Node SDK)](https://www.npmjs.com/package/@anvil-cloud/sdk)
80
+ - [Go SDK](https://pkg.go.dev/github.com/DamienPace15/anvil/sdk/go/anvil)
81
+
82
+ ## License
83
+
84
+ Apache-2.0
@@ -0,0 +1,57 @@
1
+ # coding=utf-8
2
+ # *** WARNING: this file was generated by pulumi-language-python. ***
3
+ # *** Do not edit by hand unless you're certain you know what you are doing! ***
4
+
5
+ import builtins as _builtins
6
+ from . import _utilities
7
+ import typing
8
+ # Export this package's modules as members:
9
+ from .provider import *
10
+
11
+ # Make subpackages available:
12
+ if typing.TYPE_CHECKING:
13
+ import anvil_cloud.aws as __aws
14
+ aws = __aws
15
+ import anvil_cloud.gcp as __gcp
16
+ gcp = __gcp
17
+ else:
18
+ aws = _utilities.lazy_import('anvil_cloud.aws')
19
+ gcp = _utilities.lazy_import('anvil_cloud.gcp')
20
+
21
+ _utilities.register(
22
+ resource_modules="""
23
+ [
24
+ {
25
+ "pkg": "anvil",
26
+ "mod": "aws",
27
+ "fqn": "anvil_cloud.aws",
28
+ "classes": {
29
+ "anvil:aws:Bucket": "Bucket",
30
+ "anvil:aws:Lambda": "Lambda"
31
+ }
32
+ },
33
+ {
34
+ "pkg": "anvil",
35
+ "mod": "gcp",
36
+ "fqn": "anvil_cloud.gcp",
37
+ "classes": {
38
+ "anvil:gcp:Function": "Function",
39
+ "anvil:gcp:StorageBucket": "StorageBucket"
40
+ }
41
+ }
42
+ ]
43
+ """,
44
+ resource_packages="""
45
+ [
46
+ {
47
+ "pkg": "anvil",
48
+ "token": "pulumi:providers:anvil",
49
+ "fqn": "anvil_cloud",
50
+ "class": "Provider"
51
+ }
52
+ ]
53
+ """
54
+ )
55
+
56
+ # Re-export core Pulumi functions so users never need to import pulumi directly.
57
+ from pulumi import export
@@ -0,0 +1,328 @@
1
+ # coding=utf-8
2
+ # *** WARNING: this file was generated by pulumi-language-python. ***
3
+ # *** Do not edit by hand unless you're certain you know what you are doing! ***
4
+
5
+
6
+ import asyncio
7
+ import functools
8
+ import importlib.metadata
9
+ import importlib.util
10
+ import inspect
11
+ import json
12
+ import os
13
+ import sys
14
+ import typing
15
+ import warnings
16
+ import base64
17
+
18
+ import pulumi
19
+ import pulumi.runtime
20
+ from pulumi.runtime.sync_await import _sync_await
21
+ from pulumi.runtime.proto import resource_pb2
22
+
23
+ from semver import VersionInfo as SemverVersion
24
+ from parver import Version as PEP440Version
25
+
26
+ C = typing.TypeVar("C", bound=typing.Callable)
27
+
28
+
29
+ def get_env(*args):
30
+ for v in args:
31
+ value = os.getenv(v)
32
+ if value is not None:
33
+ return value
34
+ return None
35
+
36
+
37
+ def get_env_bool(*args):
38
+ str = get_env(*args)
39
+ if str is not None:
40
+ # NOTE: these values are taken from https://golang.org/src/strconv/atob.go?s=351:391#L1, which is what
41
+ # Terraform uses internally when parsing boolean values.
42
+ if str in ["1", "t", "T", "true", "TRUE", "True"]:
43
+ return True
44
+ if str in ["0", "f", "F", "false", "FALSE", "False"]:
45
+ return False
46
+ return None
47
+
48
+
49
+ def get_env_int(*args):
50
+ str = get_env(*args)
51
+ if str is not None:
52
+ try:
53
+ return int(str)
54
+ except:
55
+ return None
56
+ return None
57
+
58
+
59
+ def get_env_float(*args):
60
+ str = get_env(*args)
61
+ if str is not None:
62
+ try:
63
+ return float(str)
64
+ except:
65
+ return None
66
+ return None
67
+
68
+
69
+ def _get_semver_version():
70
+ # __name__ is set to the fully-qualified name of the current module, In our case, it will be
71
+ # <some module>._utilities. <some module> is the module we want to query the version for.
72
+ root_package, *rest = __name__.split('.')
73
+
74
+ # Unfortunately, PEP440 and semver differ slightly in incompatible ways. The Pulumi engine expects
75
+ # to receive a valid semver string when receiving requests from the language host, so it's our
76
+ # responsibility as the library to convert our own PEP440 version into a valid semver string.
77
+
78
+ pep440_version_string = importlib.metadata.version("anvil-cloud")
79
+ pep440_version = PEP440Version.parse(pep440_version_string)
80
+ (major, minor, patch) = pep440_version.release
81
+ prerelease = None
82
+ if pep440_version.pre_tag == 'a':
83
+ prerelease = f"alpha.{pep440_version.pre}"
84
+ elif pep440_version.pre_tag == 'b':
85
+ prerelease = f"beta.{pep440_version.pre}"
86
+ elif pep440_version.pre_tag == 'rc':
87
+ prerelease = f"rc.{pep440_version.pre}"
88
+ elif pep440_version.dev is not None:
89
+ # PEP440 has explicit support for dev builds, while semver encodes them as "prerelease" versions. To bridge
90
+ # between the two, we convert our dev build version into a prerelease tag. This matches what all of our other
91
+ # packages do when constructing their own semver string.
92
+ prerelease = f"dev.{pep440_version.dev}"
93
+ elif pep440_version.local is not None:
94
+ # PEP440 only allows a small set of prerelease tags, so when converting an arbitrary prerelease,
95
+ # PypiVersion in /pkg/codegen/python/utilities.go converts it to a local version. Therefore, we need to
96
+ # do the reverse conversion here and set the local version as the prerelease tag.
97
+ prerelease = pep440_version.local
98
+
99
+ return SemverVersion(major=major, minor=minor, patch=patch, prerelease=prerelease)
100
+
101
+
102
+ # Determine the version once and cache the value, which measurably improves program performance.
103
+ _version = _get_semver_version()
104
+ _version_str = str(_version)
105
+
106
+ def get_resource_opts_defaults() -> pulumi.ResourceOptions:
107
+ return pulumi.ResourceOptions(
108
+ version=get_version(),
109
+ plugin_download_url=get_plugin_download_url(),
110
+ )
111
+
112
+ def get_invoke_opts_defaults() -> pulumi.InvokeOptions:
113
+ return pulumi.InvokeOptions(
114
+ version=get_version(),
115
+ plugin_download_url=get_plugin_download_url(),
116
+ )
117
+
118
+ def get_resource_args_opts(resource_args_type, resource_options_type, *args, **kwargs):
119
+ """
120
+ Return the resource args and options given the *args and **kwargs of a resource's
121
+ __init__ method.
122
+ """
123
+
124
+ resource_args, opts = None, None
125
+
126
+ # If the first item is the resource args type, save it and remove it from the args list.
127
+ if args and isinstance(args[0], resource_args_type):
128
+ resource_args, args = args[0], args[1:]
129
+
130
+ # Now look at the first item in the args list again.
131
+ # If the first item is the resource options class, save it.
132
+ if args and isinstance(args[0], resource_options_type):
133
+ opts = args[0]
134
+
135
+ # If resource_args is None, see if "args" is in kwargs, and, if so, if it's typed as the
136
+ # the resource args type.
137
+ if resource_args is None:
138
+ a = kwargs.get("args")
139
+ if isinstance(a, resource_args_type):
140
+ resource_args = a
141
+
142
+ # If opts is None, look it up in kwargs.
143
+ if opts is None:
144
+ opts = kwargs.get("opts")
145
+
146
+ return resource_args, opts
147
+
148
+
149
+ # Temporary: just use pulumi._utils.lazy_import once everyone upgrades.
150
+ def lazy_import(fullname):
151
+
152
+ import pulumi._utils as u
153
+ f = getattr(u, 'lazy_import', None)
154
+ if f is None:
155
+ f = _lazy_import_temp
156
+
157
+ return f(fullname)
158
+
159
+
160
+ # Copied from pulumi._utils.lazy_import, see comments there.
161
+ def _lazy_import_temp(fullname):
162
+ m = sys.modules.get(fullname, None)
163
+ if m is not None:
164
+ return m
165
+
166
+ spec = importlib.util.find_spec(fullname)
167
+
168
+ m = sys.modules.get(fullname, None)
169
+ if m is not None:
170
+ return m
171
+
172
+ loader = importlib.util.LazyLoader(spec.loader)
173
+ spec.loader = loader
174
+ module = importlib.util.module_from_spec(spec)
175
+
176
+ m = sys.modules.get(fullname, None)
177
+ if m is not None:
178
+ return m
179
+
180
+ sys.modules[fullname] = module
181
+ loader.exec_module(module)
182
+ return module
183
+
184
+
185
+ class Package(pulumi.runtime.ResourcePackage):
186
+ def __init__(self, pkg_info):
187
+ super().__init__()
188
+ self.pkg_info = pkg_info
189
+
190
+ def version(self):
191
+ return _version
192
+
193
+ def construct_provider(self, name: str, typ: str, urn: str) -> pulumi.ProviderResource:
194
+ if typ != self.pkg_info['token']:
195
+ raise Exception(f"unknown provider type {typ}")
196
+ Provider = getattr(lazy_import(self.pkg_info['fqn']), self.pkg_info['class'])
197
+ return Provider(name, pulumi.ResourceOptions(urn=urn))
198
+
199
+
200
+ class Module(pulumi.runtime.ResourceModule):
201
+ def __init__(self, mod_info):
202
+ super().__init__()
203
+ self.mod_info = mod_info
204
+
205
+ def version(self):
206
+ return _version
207
+
208
+ def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
209
+ class_name = self.mod_info['classes'].get(typ, None)
210
+
211
+ if class_name is None:
212
+ raise Exception(f"unknown resource type {typ}")
213
+
214
+ TheClass = getattr(lazy_import(self.mod_info['fqn']), class_name)
215
+ return TheClass(name, pulumi.ResourceOptions(urn=urn))
216
+
217
+
218
+ def register(resource_modules, resource_packages):
219
+ resource_modules = json.loads(resource_modules)
220
+ resource_packages = json.loads(resource_packages)
221
+
222
+ for pkg_info in resource_packages:
223
+ pulumi.runtime.register_resource_package(pkg_info['pkg'], Package(pkg_info))
224
+
225
+ for mod_info in resource_modules:
226
+ pulumi.runtime.register_resource_module(
227
+ mod_info['pkg'],
228
+ mod_info['mod'],
229
+ Module(mod_info))
230
+
231
+
232
+ _F = typing.TypeVar('_F', bound=typing.Callable[..., typing.Any])
233
+
234
+
235
+ def lift_output_func(func: typing.Any) -> typing.Callable[[_F], _F]:
236
+ """Decorator internally used on {fn}_output lifted function versions
237
+ to implement them automatically from the un-lifted function."""
238
+
239
+ func_sig = inspect.signature(func)
240
+
241
+ def lifted_func(*args, opts=None, **kwargs):
242
+ bound_args = func_sig.bind(*args, **kwargs)
243
+ # Convert tuple to list, see pulumi/pulumi#8172
244
+ args_list = list(bound_args.args)
245
+ return pulumi.Output.from_input({
246
+ 'args': args_list,
247
+ 'kwargs': bound_args.kwargs
248
+ }).apply(lambda resolved_args: func(*resolved_args['args'],
249
+ opts=opts,
250
+ **resolved_args['kwargs']))
251
+
252
+ return (lambda _: lifted_func)
253
+
254
+
255
+ def call_plain(
256
+ tok: str,
257
+ props: pulumi.Inputs,
258
+ res: typing.Optional[pulumi.Resource] = None,
259
+ typ: typing.Optional[type] = None,
260
+ ) -> typing.Any:
261
+ """
262
+ Wraps pulumi.runtime.plain to force the output and return it plainly.
263
+ """
264
+
265
+ output = pulumi.runtime.call(tok, props, res, typ)
266
+
267
+ # Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency.
268
+ result, known, secret, _ = _sync_await(asyncio.create_task(_await_output(output)))
269
+
270
+ problem = None
271
+ if not known:
272
+ problem = ' an unknown value'
273
+ elif secret:
274
+ problem = ' a secret value'
275
+
276
+ if problem:
277
+ raise AssertionError(
278
+ f"Plain resource method '{tok}' incorrectly returned {problem}. "
279
+ + "This is an error in the provider, please report this to the provider developer."
280
+ )
281
+
282
+ return result
283
+
284
+
285
+ async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]:
286
+ return (
287
+ await o._future,
288
+ await o._is_known,
289
+ await o._is_secret,
290
+ await o._resources,
291
+ )
292
+
293
+
294
+ # This is included to provide an upgrade path for users who are using a version
295
+ # of the Pulumi SDK (<3.121.0) that does not include the `deprecated` decorator.
296
+ def deprecated(message: str) -> typing.Callable[[C], C]:
297
+ """
298
+ Decorator to indicate a function is deprecated.
299
+
300
+ As well as inserting appropriate statements to indicate that the function is
301
+ deprecated, this decorator also tags the function with a special attribute
302
+ so that Pulumi code can detect that it is deprecated and react appropriately
303
+ in certain situations.
304
+
305
+ message is the deprecation message that should be printed if the function is called.
306
+ """
307
+
308
+ def decorator(fn: C) -> C:
309
+ if not callable(fn):
310
+ raise TypeError("Expected fn to be callable")
311
+
312
+ @functools.wraps(fn)
313
+ def deprecated_fn(*args, **kwargs):
314
+ warnings.warn(message)
315
+ pulumi.warn(f"{fn.__name__} is deprecated: {message}")
316
+
317
+ return fn(*args, **kwargs)
318
+
319
+ deprecated_fn.__dict__["_pulumi_deprecated_callable"] = fn
320
+ return typing.cast(C, deprecated_fn)
321
+
322
+ return decorator
323
+
324
+ def get_plugin_download_url():
325
+ return None
326
+
327
+ def get_version():
328
+ return _version_str
@@ -0,0 +1,11 @@
1
+ # coding=utf-8
2
+ # *** WARNING: this file was generated by pulumi-language-python. ***
3
+ # *** Do not edit by hand unless you're certain you know what you are doing! ***
4
+
5
+ import builtins as _builtins
6
+ from .. import _utilities
7
+ import typing
8
+ # Export this package's modules as members:
9
+ from .bucket import *
10
+ from .lambda_ import *
11
+ from ._inputs import *