pulumi-provider-boilerplate 0.1.0a1749159636__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.
Potentially problematic release.
This version of pulumi-provider-boilerplate might be problematic. Click here for more details.
- pulumi_provider_boilerplate-0.1.0a1749159636/PKG-INFO +123 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/README.md +113 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/__init__.py +44 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/_utilities.py +331 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/config/__init__.py +9 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/config/__init__.pyi +19 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/config/vars.py +27 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/provider.py +92 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/pulumi-plugin.json +5 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/py.typed +0 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/random.py +124 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate/random_component.py +107 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/PKG-INFO +123 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/SOURCES.txt +17 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/dependency_links.txt +1 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/requires.txt +6 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/top_level.txt +1 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/pyproject.toml +15 -0
- pulumi_provider_boilerplate-0.1.0a1749159636/setup.cfg +4 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pulumi_provider_boilerplate
|
|
3
|
+
Version: 0.1.0a1749159636
|
|
4
|
+
Requires-Python: >=3.9
|
|
5
|
+
Description-Content-Type: text/markdown
|
|
6
|
+
Requires-Dist: parver>=0.2.1
|
|
7
|
+
Requires-Dist: pulumi<4.0.0,>=3.165.0
|
|
8
|
+
Requires-Dist: semver>=2.8.1
|
|
9
|
+
Requires-Dist: typing-extensions<5,>=4.11; python_version < "3.11"
|
|
10
|
+
|
|
11
|
+
# Pulumi Native Provider Boilerplate
|
|
12
|
+
|
|
13
|
+
This repository is a boilerplate showing how to create and locally test a native Pulumi provider (with examples of both CustomResource and ComponentResource [resource types](https://www.pulumi.com/docs/iac/concepts/resources/)).
|
|
14
|
+
|
|
15
|
+
## Authoring a Pulumi Native Provider
|
|
16
|
+
|
|
17
|
+
This boilerplate creates a working Pulumi-owned provider named `provider-boilerplate`.
|
|
18
|
+
It implements a random number generator that you can [build and test out for yourself](#test-against-the-example) and then replace the Random code with code specific to your provider.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
|
|
23
|
+
You will need to ensure the following tools are installed and present in your `$PATH`:
|
|
24
|
+
|
|
25
|
+
* [`pulumictl`](https://github.com/pulumi/pulumictl#installation)
|
|
26
|
+
* [Go 1.21](https://golang.org/dl/) or 1.latest
|
|
27
|
+
* [NodeJS](https://nodejs.org/en/) 14.x. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS installations.
|
|
28
|
+
* [Yarn](https://yarnpkg.com/)
|
|
29
|
+
* [TypeScript](https://www.typescriptlang.org/)
|
|
30
|
+
* [Python](https://www.python.org/downloads/) (called as `python3`). For recent versions of MacOS, the system-installed version is fine.
|
|
31
|
+
* [.NET](https://dotnet.microsoft.com/download)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Build & test the boilerplate provider
|
|
35
|
+
|
|
36
|
+
1. Run `make build install` to build and install the provider.
|
|
37
|
+
1. Run `make gen_examples` to generate the example programs in `examples/` off of the source `examples/yaml` example program.
|
|
38
|
+
1. Run `make up` to run the example program in `examples/yaml`.
|
|
39
|
+
1. Run `make down` to tear down the example program.
|
|
40
|
+
|
|
41
|
+
### Creating a new provider repository
|
|
42
|
+
|
|
43
|
+
Pulumi offers this repository as a [GitHub template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for convenience. From this repository:
|
|
44
|
+
|
|
45
|
+
1. Click "Use this template".
|
|
46
|
+
1. Set the following options:
|
|
47
|
+
* Owner: pulumi
|
|
48
|
+
* Repository name: pulumi-provider-boilerplate (replace "provider-boilerplate" with the name of your provider)
|
|
49
|
+
* Description: Pulumi provider for xyz
|
|
50
|
+
* Repository type: Public
|
|
51
|
+
1. Clone the generated repository.
|
|
52
|
+
|
|
53
|
+
From the templated repository:
|
|
54
|
+
|
|
55
|
+
1. Run the following command to update files to use the name of your provider (third-party: use your GitHub organization/username):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
make prepare NAME=foo ORG=myorg REPOSITORY=github.com/myorg/pulumi-foo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This will do the following:
|
|
62
|
+
- rename folders in `provider/cmd` to `pulumi-resource-{NAME}`
|
|
63
|
+
- replace dependencies in `provider/go.mod` to reflect your repository name
|
|
64
|
+
- find and replace all instances of `provider-boilerplate` with the `NAME` of your provider.
|
|
65
|
+
- find and replace all instances of the boilerplate `abc` with the `ORG` of your provider.
|
|
66
|
+
- replace all instances of the `github.com/pulumi/pulumi-provider-boilerplate` repository with the `REPOSITORY` location
|
|
67
|
+
|
|
68
|
+
#### Build the provider and install the plugin
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
$ make build install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This will:
|
|
75
|
+
|
|
76
|
+
1. Create the SDK codegen binary and place it in a `./bin` folder (gitignored)
|
|
77
|
+
2. Create the provider binary and place it in the `./bin` folder (gitignored)
|
|
78
|
+
3. Generate the dotnet, Go, Node, and Python SDKs and place them in the `./sdk` folder
|
|
79
|
+
4. Install the provider on your machine.
|
|
80
|
+
|
|
81
|
+
#### Test against the example
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
$ cd examples/simple
|
|
85
|
+
$ yarn link @pulumi/provider-boilerplate
|
|
86
|
+
$ yarn install
|
|
87
|
+
$ pulumi stack init test
|
|
88
|
+
$ pulumi up
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Now that you have completed all of the above steps, you have a working provider that generates a random string for you.
|
|
92
|
+
|
|
93
|
+
#### A brief repository overview
|
|
94
|
+
|
|
95
|
+
You now have:
|
|
96
|
+
|
|
97
|
+
1. A `provider/` folder containing the building and implementation logic.
|
|
98
|
+
1. `cmd/pulumi-resource-provider-boilerplate/main.go` - holds the provider's sample implementation logic.
|
|
99
|
+
2. `Makefile` - targets to help with building and publishing the provider. Run `make ci-mgmt` to regenerate CI workflows.
|
|
100
|
+
3. `sdk` - holds the generated code libraries created by `pulumi gen-sdk`.
|
|
101
|
+
4. `examples` a folder of Pulumi programs to try locally and/or use in CI.
|
|
102
|
+
5. A `Makefile` and this `README`.
|
|
103
|
+
|
|
104
|
+
#### Additional Details
|
|
105
|
+
|
|
106
|
+
This repository depends on the pulumi-go-provider library. For more details on building providers, please check
|
|
107
|
+
the [Pulumi Go Provider docs](https://github.com/pulumi/pulumi-go-provider).
|
|
108
|
+
|
|
109
|
+
### Build Examples
|
|
110
|
+
|
|
111
|
+
Create an example program using the resources defined in your provider, and place it in the `examples/` folder.
|
|
112
|
+
|
|
113
|
+
You can now repeat the steps for [build, install, and test](#test-against-the-example).
|
|
114
|
+
|
|
115
|
+
## Configuring CI and releases
|
|
116
|
+
|
|
117
|
+
1. Follow the instructions laid out in the [deployment templates](./deployment-templates/README-DEPLOYMENT.md).
|
|
118
|
+
|
|
119
|
+
## References
|
|
120
|
+
|
|
121
|
+
Other resources/examples for implementing providers:
|
|
122
|
+
* [Pulumi Command provider](https://github.com/pulumi/pulumi-command/blob/master/provider/pkg/provider/provider.go)
|
|
123
|
+
* [Pulumi Go Provider repository](https://github.com/pulumi/pulumi-go-provider)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Pulumi Native Provider Boilerplate
|
|
2
|
+
|
|
3
|
+
This repository is a boilerplate showing how to create and locally test a native Pulumi provider (with examples of both CustomResource and ComponentResource [resource types](https://www.pulumi.com/docs/iac/concepts/resources/)).
|
|
4
|
+
|
|
5
|
+
## Authoring a Pulumi Native Provider
|
|
6
|
+
|
|
7
|
+
This boilerplate creates a working Pulumi-owned provider named `provider-boilerplate`.
|
|
8
|
+
It implements a random number generator that you can [build and test out for yourself](#test-against-the-example) and then replace the Random code with code specific to your provider.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Prerequisites
|
|
12
|
+
|
|
13
|
+
You will need to ensure the following tools are installed and present in your `$PATH`:
|
|
14
|
+
|
|
15
|
+
* [`pulumictl`](https://github.com/pulumi/pulumictl#installation)
|
|
16
|
+
* [Go 1.21](https://golang.org/dl/) or 1.latest
|
|
17
|
+
* [NodeJS](https://nodejs.org/en/) 14.x. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS installations.
|
|
18
|
+
* [Yarn](https://yarnpkg.com/)
|
|
19
|
+
* [TypeScript](https://www.typescriptlang.org/)
|
|
20
|
+
* [Python](https://www.python.org/downloads/) (called as `python3`). For recent versions of MacOS, the system-installed version is fine.
|
|
21
|
+
* [.NET](https://dotnet.microsoft.com/download)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Build & test the boilerplate provider
|
|
25
|
+
|
|
26
|
+
1. Run `make build install` to build and install the provider.
|
|
27
|
+
1. Run `make gen_examples` to generate the example programs in `examples/` off of the source `examples/yaml` example program.
|
|
28
|
+
1. Run `make up` to run the example program in `examples/yaml`.
|
|
29
|
+
1. Run `make down` to tear down the example program.
|
|
30
|
+
|
|
31
|
+
### Creating a new provider repository
|
|
32
|
+
|
|
33
|
+
Pulumi offers this repository as a [GitHub template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for convenience. From this repository:
|
|
34
|
+
|
|
35
|
+
1. Click "Use this template".
|
|
36
|
+
1. Set the following options:
|
|
37
|
+
* Owner: pulumi
|
|
38
|
+
* Repository name: pulumi-provider-boilerplate (replace "provider-boilerplate" with the name of your provider)
|
|
39
|
+
* Description: Pulumi provider for xyz
|
|
40
|
+
* Repository type: Public
|
|
41
|
+
1. Clone the generated repository.
|
|
42
|
+
|
|
43
|
+
From the templated repository:
|
|
44
|
+
|
|
45
|
+
1. Run the following command to update files to use the name of your provider (third-party: use your GitHub organization/username):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
make prepare NAME=foo ORG=myorg REPOSITORY=github.com/myorg/pulumi-foo
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This will do the following:
|
|
52
|
+
- rename folders in `provider/cmd` to `pulumi-resource-{NAME}`
|
|
53
|
+
- replace dependencies in `provider/go.mod` to reflect your repository name
|
|
54
|
+
- find and replace all instances of `provider-boilerplate` with the `NAME` of your provider.
|
|
55
|
+
- find and replace all instances of the boilerplate `abc` with the `ORG` of your provider.
|
|
56
|
+
- replace all instances of the `github.com/pulumi/pulumi-provider-boilerplate` repository with the `REPOSITORY` location
|
|
57
|
+
|
|
58
|
+
#### Build the provider and install the plugin
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
$ make build install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This will:
|
|
65
|
+
|
|
66
|
+
1. Create the SDK codegen binary and place it in a `./bin` folder (gitignored)
|
|
67
|
+
2. Create the provider binary and place it in the `./bin` folder (gitignored)
|
|
68
|
+
3. Generate the dotnet, Go, Node, and Python SDKs and place them in the `./sdk` folder
|
|
69
|
+
4. Install the provider on your machine.
|
|
70
|
+
|
|
71
|
+
#### Test against the example
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
$ cd examples/simple
|
|
75
|
+
$ yarn link @pulumi/provider-boilerplate
|
|
76
|
+
$ yarn install
|
|
77
|
+
$ pulumi stack init test
|
|
78
|
+
$ pulumi up
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Now that you have completed all of the above steps, you have a working provider that generates a random string for you.
|
|
82
|
+
|
|
83
|
+
#### A brief repository overview
|
|
84
|
+
|
|
85
|
+
You now have:
|
|
86
|
+
|
|
87
|
+
1. A `provider/` folder containing the building and implementation logic.
|
|
88
|
+
1. `cmd/pulumi-resource-provider-boilerplate/main.go` - holds the provider's sample implementation logic.
|
|
89
|
+
2. `Makefile` - targets to help with building and publishing the provider. Run `make ci-mgmt` to regenerate CI workflows.
|
|
90
|
+
3. `sdk` - holds the generated code libraries created by `pulumi gen-sdk`.
|
|
91
|
+
4. `examples` a folder of Pulumi programs to try locally and/or use in CI.
|
|
92
|
+
5. A `Makefile` and this `README`.
|
|
93
|
+
|
|
94
|
+
#### Additional Details
|
|
95
|
+
|
|
96
|
+
This repository depends on the pulumi-go-provider library. For more details on building providers, please check
|
|
97
|
+
the [Pulumi Go Provider docs](https://github.com/pulumi/pulumi-go-provider).
|
|
98
|
+
|
|
99
|
+
### Build Examples
|
|
100
|
+
|
|
101
|
+
Create an example program using the resources defined in your provider, and place it in the `examples/` folder.
|
|
102
|
+
|
|
103
|
+
You can now repeat the steps for [build, install, and test](#test-against-the-example).
|
|
104
|
+
|
|
105
|
+
## Configuring CI and releases
|
|
106
|
+
|
|
107
|
+
1. Follow the instructions laid out in the [deployment templates](./deployment-templates/README-DEPLOYMENT.md).
|
|
108
|
+
|
|
109
|
+
## References
|
|
110
|
+
|
|
111
|
+
Other resources/examples for implementing providers:
|
|
112
|
+
* [Pulumi Command provider](https://github.com/pulumi/pulumi-command/blob/master/provider/pkg/provider/provider.go)
|
|
113
|
+
* [Pulumi Go Provider repository](https://github.com/pulumi/pulumi-go-provider)
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
|
6
|
+
from . import _utilities
|
|
7
|
+
import typing
|
|
8
|
+
# Export this package's modules as members:
|
|
9
|
+
from .provider import *
|
|
10
|
+
from .random import *
|
|
11
|
+
from .random_component import *
|
|
12
|
+
|
|
13
|
+
# Make subpackages available:
|
|
14
|
+
if typing.TYPE_CHECKING:
|
|
15
|
+
import pulumi_provider_boilerplate.config as __config
|
|
16
|
+
config = __config
|
|
17
|
+
else:
|
|
18
|
+
config = _utilities.lazy_import('pulumi_provider_boilerplate.config')
|
|
19
|
+
|
|
20
|
+
_utilities.register(
|
|
21
|
+
resource_modules="""
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
"pkg": "provider-boilerplate",
|
|
25
|
+
"mod": "index",
|
|
26
|
+
"fqn": "pulumi_provider_boilerplate",
|
|
27
|
+
"classes": {
|
|
28
|
+
"provider-boilerplate:index:Random": "Random",
|
|
29
|
+
"provider-boilerplate:index:RandomComponent": "RandomComponent"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
""",
|
|
34
|
+
resource_packages="""
|
|
35
|
+
[
|
|
36
|
+
{
|
|
37
|
+
"pkg": "provider-boilerplate",
|
|
38
|
+
"token": "pulumi:providers:provider-boilerplate",
|
|
39
|
+
"fqn": "pulumi_provider_boilerplate",
|
|
40
|
+
"class": "Provider"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
"""
|
|
44
|
+
)
|
|
@@ -0,0 +1,331 @@
|
|
|
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
|
+
# pkg_resources uses setuptools to inspect the set of installed packages. We use it here to ask
|
|
75
|
+
# for the currently installed version of the root package (i.e. us) and get its version.
|
|
76
|
+
|
|
77
|
+
# Unfortunately, PEP440 and semver differ slightly in incompatible ways. The Pulumi engine expects
|
|
78
|
+
# to receive a valid semver string when receiving requests from the language host, so it's our
|
|
79
|
+
# responsibility as the library to convert our own PEP440 version into a valid semver string.
|
|
80
|
+
|
|
81
|
+
pep440_version_string = importlib.metadata.version(root_package)
|
|
82
|
+
pep440_version = PEP440Version.parse(pep440_version_string)
|
|
83
|
+
(major, minor, patch) = pep440_version.release
|
|
84
|
+
prerelease = None
|
|
85
|
+
if pep440_version.pre_tag == 'a':
|
|
86
|
+
prerelease = f"alpha.{pep440_version.pre}"
|
|
87
|
+
elif pep440_version.pre_tag == 'b':
|
|
88
|
+
prerelease = f"beta.{pep440_version.pre}"
|
|
89
|
+
elif pep440_version.pre_tag == 'rc':
|
|
90
|
+
prerelease = f"rc.{pep440_version.pre}"
|
|
91
|
+
elif pep440_version.dev is not None:
|
|
92
|
+
# PEP440 has explicit support for dev builds, while semver encodes them as "prerelease" versions. To bridge
|
|
93
|
+
# between the two, we convert our dev build version into a prerelease tag. This matches what all of our other
|
|
94
|
+
# packages do when constructing their own semver string.
|
|
95
|
+
prerelease = f"dev.{pep440_version.dev}"
|
|
96
|
+
elif pep440_version.local is not None:
|
|
97
|
+
# PEP440 only allows a small set of prerelease tags, so when converting an arbitrary prerelease,
|
|
98
|
+
# PypiVersion in /pkg/codegen/python/utilities.go converts it to a local version. Therefore, we need to
|
|
99
|
+
# do the reverse conversion here and set the local version as the prerelease tag.
|
|
100
|
+
prerelease = pep440_version.local
|
|
101
|
+
|
|
102
|
+
return SemverVersion(major=major, minor=minor, patch=patch, prerelease=prerelease)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
# Determine the version once and cache the value, which measurably improves program performance.
|
|
106
|
+
_version = _get_semver_version()
|
|
107
|
+
_version_str = str(_version)
|
|
108
|
+
|
|
109
|
+
def get_resource_opts_defaults() -> pulumi.ResourceOptions:
|
|
110
|
+
return pulumi.ResourceOptions(
|
|
111
|
+
version=get_version(),
|
|
112
|
+
plugin_download_url=get_plugin_download_url(),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
def get_invoke_opts_defaults() -> pulumi.InvokeOptions:
|
|
116
|
+
return pulumi.InvokeOptions(
|
|
117
|
+
version=get_version(),
|
|
118
|
+
plugin_download_url=get_plugin_download_url(),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
def get_resource_args_opts(resource_args_type, resource_options_type, *args, **kwargs):
|
|
122
|
+
"""
|
|
123
|
+
Return the resource args and options given the *args and **kwargs of a resource's
|
|
124
|
+
__init__ method.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
resource_args, opts = None, None
|
|
128
|
+
|
|
129
|
+
# If the first item is the resource args type, save it and remove it from the args list.
|
|
130
|
+
if args and isinstance(args[0], resource_args_type):
|
|
131
|
+
resource_args, args = args[0], args[1:]
|
|
132
|
+
|
|
133
|
+
# Now look at the first item in the args list again.
|
|
134
|
+
# If the first item is the resource options class, save it.
|
|
135
|
+
if args and isinstance(args[0], resource_options_type):
|
|
136
|
+
opts = args[0]
|
|
137
|
+
|
|
138
|
+
# If resource_args is None, see if "args" is in kwargs, and, if so, if it's typed as the
|
|
139
|
+
# the resource args type.
|
|
140
|
+
if resource_args is None:
|
|
141
|
+
a = kwargs.get("args")
|
|
142
|
+
if isinstance(a, resource_args_type):
|
|
143
|
+
resource_args = a
|
|
144
|
+
|
|
145
|
+
# If opts is None, look it up in kwargs.
|
|
146
|
+
if opts is None:
|
|
147
|
+
opts = kwargs.get("opts")
|
|
148
|
+
|
|
149
|
+
return resource_args, opts
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# Temporary: just use pulumi._utils.lazy_import once everyone upgrades.
|
|
153
|
+
def lazy_import(fullname):
|
|
154
|
+
|
|
155
|
+
import pulumi._utils as u
|
|
156
|
+
f = getattr(u, 'lazy_import', None)
|
|
157
|
+
if f is None:
|
|
158
|
+
f = _lazy_import_temp
|
|
159
|
+
|
|
160
|
+
return f(fullname)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# Copied from pulumi._utils.lazy_import, see comments there.
|
|
164
|
+
def _lazy_import_temp(fullname):
|
|
165
|
+
m = sys.modules.get(fullname, None)
|
|
166
|
+
if m is not None:
|
|
167
|
+
return m
|
|
168
|
+
|
|
169
|
+
spec = importlib.util.find_spec(fullname)
|
|
170
|
+
|
|
171
|
+
m = sys.modules.get(fullname, None)
|
|
172
|
+
if m is not None:
|
|
173
|
+
return m
|
|
174
|
+
|
|
175
|
+
loader = importlib.util.LazyLoader(spec.loader)
|
|
176
|
+
spec.loader = loader
|
|
177
|
+
module = importlib.util.module_from_spec(spec)
|
|
178
|
+
|
|
179
|
+
m = sys.modules.get(fullname, None)
|
|
180
|
+
if m is not None:
|
|
181
|
+
return m
|
|
182
|
+
|
|
183
|
+
sys.modules[fullname] = module
|
|
184
|
+
loader.exec_module(module)
|
|
185
|
+
return module
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class Package(pulumi.runtime.ResourcePackage):
|
|
189
|
+
def __init__(self, pkg_info):
|
|
190
|
+
super().__init__()
|
|
191
|
+
self.pkg_info = pkg_info
|
|
192
|
+
|
|
193
|
+
def version(self):
|
|
194
|
+
return _version
|
|
195
|
+
|
|
196
|
+
def construct_provider(self, name: str, typ: str, urn: str) -> pulumi.ProviderResource:
|
|
197
|
+
if typ != self.pkg_info['token']:
|
|
198
|
+
raise Exception(f"unknown provider type {typ}")
|
|
199
|
+
Provider = getattr(lazy_import(self.pkg_info['fqn']), self.pkg_info['class'])
|
|
200
|
+
return Provider(name, pulumi.ResourceOptions(urn=urn))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
class Module(pulumi.runtime.ResourceModule):
|
|
204
|
+
def __init__(self, mod_info):
|
|
205
|
+
super().__init__()
|
|
206
|
+
self.mod_info = mod_info
|
|
207
|
+
|
|
208
|
+
def version(self):
|
|
209
|
+
return _version
|
|
210
|
+
|
|
211
|
+
def construct(self, name: str, typ: str, urn: str) -> pulumi.Resource:
|
|
212
|
+
class_name = self.mod_info['classes'].get(typ, None)
|
|
213
|
+
|
|
214
|
+
if class_name is None:
|
|
215
|
+
raise Exception(f"unknown resource type {typ}")
|
|
216
|
+
|
|
217
|
+
TheClass = getattr(lazy_import(self.mod_info['fqn']), class_name)
|
|
218
|
+
return TheClass(name, pulumi.ResourceOptions(urn=urn))
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def register(resource_modules, resource_packages):
|
|
222
|
+
resource_modules = json.loads(resource_modules)
|
|
223
|
+
resource_packages = json.loads(resource_packages)
|
|
224
|
+
|
|
225
|
+
for pkg_info in resource_packages:
|
|
226
|
+
pulumi.runtime.register_resource_package(pkg_info['pkg'], Package(pkg_info))
|
|
227
|
+
|
|
228
|
+
for mod_info in resource_modules:
|
|
229
|
+
pulumi.runtime.register_resource_module(
|
|
230
|
+
mod_info['pkg'],
|
|
231
|
+
mod_info['mod'],
|
|
232
|
+
Module(mod_info))
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
_F = typing.TypeVar('_F', bound=typing.Callable[..., typing.Any])
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def lift_output_func(func: typing.Any) -> typing.Callable[[_F], _F]:
|
|
239
|
+
"""Decorator internally used on {fn}_output lifted function versions
|
|
240
|
+
to implement them automatically from the un-lifted function."""
|
|
241
|
+
|
|
242
|
+
func_sig = inspect.signature(func)
|
|
243
|
+
|
|
244
|
+
def lifted_func(*args, opts=None, **kwargs):
|
|
245
|
+
bound_args = func_sig.bind(*args, **kwargs)
|
|
246
|
+
# Convert tuple to list, see pulumi/pulumi#8172
|
|
247
|
+
args_list = list(bound_args.args)
|
|
248
|
+
return pulumi.Output.from_input({
|
|
249
|
+
'args': args_list,
|
|
250
|
+
'kwargs': bound_args.kwargs
|
|
251
|
+
}).apply(lambda resolved_args: func(*resolved_args['args'],
|
|
252
|
+
opts=opts,
|
|
253
|
+
**resolved_args['kwargs']))
|
|
254
|
+
|
|
255
|
+
return (lambda _: lifted_func)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def call_plain(
|
|
259
|
+
tok: str,
|
|
260
|
+
props: pulumi.Inputs,
|
|
261
|
+
res: typing.Optional[pulumi.Resource] = None,
|
|
262
|
+
typ: typing.Optional[type] = None,
|
|
263
|
+
) -> typing.Any:
|
|
264
|
+
"""
|
|
265
|
+
Wraps pulumi.runtime.plain to force the output and return it plainly.
|
|
266
|
+
"""
|
|
267
|
+
|
|
268
|
+
output = pulumi.runtime.call(tok, props, res, typ)
|
|
269
|
+
|
|
270
|
+
# Ingoring deps silently. They are typically non-empty, r.f() calls include r as a dependency.
|
|
271
|
+
result, known, secret, _ = _sync_await(asyncio.create_task(_await_output(output)))
|
|
272
|
+
|
|
273
|
+
problem = None
|
|
274
|
+
if not known:
|
|
275
|
+
problem = ' an unknown value'
|
|
276
|
+
elif secret:
|
|
277
|
+
problem = ' a secret value'
|
|
278
|
+
|
|
279
|
+
if problem:
|
|
280
|
+
raise AssertionError(
|
|
281
|
+
f"Plain resource method '{tok}' incorrectly returned {problem}. "
|
|
282
|
+
+ "This is an error in the provider, please report this to the provider developer."
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
return result
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
async def _await_output(o: pulumi.Output[typing.Any]) -> typing.Tuple[object, bool, bool, set]:
|
|
289
|
+
return (
|
|
290
|
+
await o._future,
|
|
291
|
+
await o._is_known,
|
|
292
|
+
await o._is_secret,
|
|
293
|
+
await o._resources,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
# This is included to provide an upgrade path for users who are using a version
|
|
298
|
+
# of the Pulumi SDK (<3.121.0) that does not include the `deprecated` decorator.
|
|
299
|
+
def deprecated(message: str) -> typing.Callable[[C], C]:
|
|
300
|
+
"""
|
|
301
|
+
Decorator to indicate a function is deprecated.
|
|
302
|
+
|
|
303
|
+
As well as inserting appropriate statements to indicate that the function is
|
|
304
|
+
deprecated, this decorator also tags the function with a special attribute
|
|
305
|
+
so that Pulumi code can detect that it is deprecated and react appropriately
|
|
306
|
+
in certain situations.
|
|
307
|
+
|
|
308
|
+
message is the deprecation message that should be printed if the function is called.
|
|
309
|
+
"""
|
|
310
|
+
|
|
311
|
+
def decorator(fn: C) -> C:
|
|
312
|
+
if not callable(fn):
|
|
313
|
+
raise TypeError("Expected fn to be callable")
|
|
314
|
+
|
|
315
|
+
@functools.wraps(fn)
|
|
316
|
+
def deprecated_fn(*args, **kwargs):
|
|
317
|
+
warnings.warn(message)
|
|
318
|
+
pulumi.warn(f"{fn.__name__} is deprecated: {message}")
|
|
319
|
+
|
|
320
|
+
return fn(*args, **kwargs)
|
|
321
|
+
|
|
322
|
+
deprecated_fn.__dict__["_pulumi_deprecated_callable"] = fn
|
|
323
|
+
return typing.cast(C, deprecated_fn)
|
|
324
|
+
|
|
325
|
+
return decorator
|
|
326
|
+
|
|
327
|
+
def get_plugin_download_url():
|
|
328
|
+
return None
|
|
329
|
+
|
|
330
|
+
def get_version():
|
|
331
|
+
return _version_str
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
|
6
|
+
import sys
|
|
7
|
+
from .vars import _ExportableConfig
|
|
8
|
+
|
|
9
|
+
sys.modules[__name__].__class__ = _ExportableConfig
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
6
|
+
import copy
|
|
7
|
+
import warnings
|
|
8
|
+
import sys
|
|
9
|
+
import pulumi
|
|
10
|
+
import pulumi.runtime
|
|
11
|
+
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
16
|
+
from .. import _utilities
|
|
17
|
+
|
|
18
|
+
itsasecret: Optional[bool]
|
|
19
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
6
|
+
import copy
|
|
7
|
+
import warnings
|
|
8
|
+
import sys
|
|
9
|
+
import pulumi
|
|
10
|
+
import pulumi.runtime
|
|
11
|
+
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
16
|
+
from .. import _utilities
|
|
17
|
+
|
|
18
|
+
import types
|
|
19
|
+
|
|
20
|
+
__config__ = pulumi.Config('provider-boilerplate')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _ExportableConfig(types.ModuleType):
|
|
24
|
+
@property
|
|
25
|
+
def itsasecret(self) -> Optional[bool]:
|
|
26
|
+
return __config__.get_bool('itsasecret')
|
|
27
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
|
6
|
+
import copy
|
|
7
|
+
import warnings
|
|
8
|
+
import sys
|
|
9
|
+
import pulumi
|
|
10
|
+
import pulumi.runtime
|
|
11
|
+
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
16
|
+
from . import _utilities
|
|
17
|
+
|
|
18
|
+
__all__ = ['ProviderArgs', 'Provider']
|
|
19
|
+
|
|
20
|
+
@pulumi.input_type
|
|
21
|
+
class ProviderArgs:
|
|
22
|
+
def __init__(__self__, *,
|
|
23
|
+
itsasecret: Optional[pulumi.Input[builtins.bool]] = None):
|
|
24
|
+
"""
|
|
25
|
+
The set of arguments for constructing a Provider resource.
|
|
26
|
+
"""
|
|
27
|
+
if itsasecret is not None:
|
|
28
|
+
pulumi.set(__self__, "itsasecret", itsasecret)
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
@pulumi.getter
|
|
32
|
+
def itsasecret(self) -> Optional[pulumi.Input[builtins.bool]]:
|
|
33
|
+
return pulumi.get(self, "itsasecret")
|
|
34
|
+
|
|
35
|
+
@itsasecret.setter
|
|
36
|
+
def itsasecret(self, value: Optional[pulumi.Input[builtins.bool]]):
|
|
37
|
+
pulumi.set(self, "itsasecret", value)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pulumi.type_token("pulumi:providers:provider-boilerplate")
|
|
41
|
+
class Provider(pulumi.ProviderResource):
|
|
42
|
+
@overload
|
|
43
|
+
def __init__(__self__,
|
|
44
|
+
resource_name: str,
|
|
45
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
46
|
+
itsasecret: Optional[pulumi.Input[builtins.bool]] = None,
|
|
47
|
+
__props__=None):
|
|
48
|
+
"""
|
|
49
|
+
Create a Provider-boilerplate resource with the given unique name, props, and options.
|
|
50
|
+
:param str resource_name: The name of the resource.
|
|
51
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
52
|
+
"""
|
|
53
|
+
...
|
|
54
|
+
@overload
|
|
55
|
+
def __init__(__self__,
|
|
56
|
+
resource_name: str,
|
|
57
|
+
args: Optional[ProviderArgs] = None,
|
|
58
|
+
opts: Optional[pulumi.ResourceOptions] = None):
|
|
59
|
+
"""
|
|
60
|
+
Create a Provider-boilerplate resource with the given unique name, props, and options.
|
|
61
|
+
:param str resource_name: The name of the resource.
|
|
62
|
+
:param ProviderArgs args: The arguments to use to populate this resource's properties.
|
|
63
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
64
|
+
"""
|
|
65
|
+
...
|
|
66
|
+
def __init__(__self__, resource_name: str, *args, **kwargs):
|
|
67
|
+
resource_args, opts = _utilities.get_resource_args_opts(ProviderArgs, pulumi.ResourceOptions, *args, **kwargs)
|
|
68
|
+
if resource_args is not None:
|
|
69
|
+
__self__._internal_init(resource_name, opts, **resource_args.__dict__)
|
|
70
|
+
else:
|
|
71
|
+
__self__._internal_init(resource_name, *args, **kwargs)
|
|
72
|
+
|
|
73
|
+
def _internal_init(__self__,
|
|
74
|
+
resource_name: str,
|
|
75
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
76
|
+
itsasecret: Optional[pulumi.Input[builtins.bool]] = None,
|
|
77
|
+
__props__=None):
|
|
78
|
+
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
|
79
|
+
if not isinstance(opts, pulumi.ResourceOptions):
|
|
80
|
+
raise TypeError('Expected resource options to be a ResourceOptions instance')
|
|
81
|
+
if opts.id is None:
|
|
82
|
+
if __props__ is not None:
|
|
83
|
+
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
|
84
|
+
__props__ = ProviderArgs.__new__(ProviderArgs)
|
|
85
|
+
|
|
86
|
+
__props__.__dict__["itsasecret"] = pulumi.Output.from_input(itsasecret).apply(pulumi.runtime.to_json) if itsasecret is not None else None
|
|
87
|
+
super(Provider, __self__).__init__(
|
|
88
|
+
'provider-boilerplate',
|
|
89
|
+
resource_name,
|
|
90
|
+
__props__,
|
|
91
|
+
opts)
|
|
92
|
+
|
|
File without changes
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
|
6
|
+
import copy
|
|
7
|
+
import warnings
|
|
8
|
+
import sys
|
|
9
|
+
import pulumi
|
|
10
|
+
import pulumi.runtime
|
|
11
|
+
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
16
|
+
from . import _utilities
|
|
17
|
+
|
|
18
|
+
__all__ = ['RandomArgs', 'Random']
|
|
19
|
+
|
|
20
|
+
@pulumi.input_type
|
|
21
|
+
class RandomArgs:
|
|
22
|
+
def __init__(__self__, *,
|
|
23
|
+
length: pulumi.Input[builtins.int]):
|
|
24
|
+
"""
|
|
25
|
+
The set of arguments for constructing a Random resource.
|
|
26
|
+
"""
|
|
27
|
+
pulumi.set(__self__, "length", length)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
@pulumi.getter
|
|
31
|
+
def length(self) -> pulumi.Input[builtins.int]:
|
|
32
|
+
return pulumi.get(self, "length")
|
|
33
|
+
|
|
34
|
+
@length.setter
|
|
35
|
+
def length(self, value: pulumi.Input[builtins.int]):
|
|
36
|
+
pulumi.set(self, "length", value)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@pulumi.type_token("provider-boilerplate:index:Random")
|
|
40
|
+
class Random(pulumi.CustomResource):
|
|
41
|
+
@overload
|
|
42
|
+
def __init__(__self__,
|
|
43
|
+
resource_name: str,
|
|
44
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
45
|
+
length: Optional[pulumi.Input[builtins.int]] = None,
|
|
46
|
+
__props__=None):
|
|
47
|
+
"""
|
|
48
|
+
Create a Random resource with the given unique name, props, and options.
|
|
49
|
+
:param str resource_name: The name of the resource.
|
|
50
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
51
|
+
"""
|
|
52
|
+
...
|
|
53
|
+
@overload
|
|
54
|
+
def __init__(__self__,
|
|
55
|
+
resource_name: str,
|
|
56
|
+
args: RandomArgs,
|
|
57
|
+
opts: Optional[pulumi.ResourceOptions] = None):
|
|
58
|
+
"""
|
|
59
|
+
Create a Random resource with the given unique name, props, and options.
|
|
60
|
+
:param str resource_name: The name of the resource.
|
|
61
|
+
:param RandomArgs args: The arguments to use to populate this resource's properties.
|
|
62
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
def __init__(__self__, resource_name: str, *args, **kwargs):
|
|
66
|
+
resource_args, opts = _utilities.get_resource_args_opts(RandomArgs, pulumi.ResourceOptions, *args, **kwargs)
|
|
67
|
+
if resource_args is not None:
|
|
68
|
+
__self__._internal_init(resource_name, opts, **resource_args.__dict__)
|
|
69
|
+
else:
|
|
70
|
+
__self__._internal_init(resource_name, *args, **kwargs)
|
|
71
|
+
|
|
72
|
+
def _internal_init(__self__,
|
|
73
|
+
resource_name: str,
|
|
74
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
75
|
+
length: Optional[pulumi.Input[builtins.int]] = None,
|
|
76
|
+
__props__=None):
|
|
77
|
+
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
|
78
|
+
if not isinstance(opts, pulumi.ResourceOptions):
|
|
79
|
+
raise TypeError('Expected resource options to be a ResourceOptions instance')
|
|
80
|
+
if opts.id is None:
|
|
81
|
+
if __props__ is not None:
|
|
82
|
+
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
|
83
|
+
__props__ = RandomArgs.__new__(RandomArgs)
|
|
84
|
+
|
|
85
|
+
if length is None and not opts.urn:
|
|
86
|
+
raise TypeError("Missing required property 'length'")
|
|
87
|
+
__props__.__dict__["length"] = length
|
|
88
|
+
__props__.__dict__["result"] = None
|
|
89
|
+
super(Random, __self__).__init__(
|
|
90
|
+
'provider-boilerplate:index:Random',
|
|
91
|
+
resource_name,
|
|
92
|
+
__props__,
|
|
93
|
+
opts)
|
|
94
|
+
|
|
95
|
+
@staticmethod
|
|
96
|
+
def get(resource_name: str,
|
|
97
|
+
id: pulumi.Input[str],
|
|
98
|
+
opts: Optional[pulumi.ResourceOptions] = None) -> 'Random':
|
|
99
|
+
"""
|
|
100
|
+
Get an existing Random resource's state with the given name, id, and optional extra
|
|
101
|
+
properties used to qualify the lookup.
|
|
102
|
+
|
|
103
|
+
:param str resource_name: The unique name of the resulting resource.
|
|
104
|
+
:param pulumi.Input[str] id: The unique provider ID of the resource to lookup.
|
|
105
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
106
|
+
"""
|
|
107
|
+
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
|
|
108
|
+
|
|
109
|
+
__props__ = RandomArgs.__new__(RandomArgs)
|
|
110
|
+
|
|
111
|
+
__props__.__dict__["length"] = None
|
|
112
|
+
__props__.__dict__["result"] = None
|
|
113
|
+
return Random(resource_name, opts=opts, __props__=__props__)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
@pulumi.getter
|
|
117
|
+
def length(self) -> pulumi.Output[builtins.int]:
|
|
118
|
+
return pulumi.get(self, "length")
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
@pulumi.getter
|
|
122
|
+
def result(self) -> pulumi.Output[builtins.str]:
|
|
123
|
+
return pulumi.get(self, "result")
|
|
124
|
+
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
|
6
|
+
import copy
|
|
7
|
+
import warnings
|
|
8
|
+
import sys
|
|
9
|
+
import pulumi
|
|
10
|
+
import pulumi.runtime
|
|
11
|
+
from typing import Any, Mapping, Optional, Sequence, Union, overload
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import NotRequired, TypedDict, TypeAlias
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import NotRequired, TypedDict, TypeAlias
|
|
16
|
+
from . import _utilities
|
|
17
|
+
|
|
18
|
+
__all__ = ['RandomComponentArgs', 'RandomComponent']
|
|
19
|
+
|
|
20
|
+
@pulumi.input_type
|
|
21
|
+
class RandomComponentArgs:
|
|
22
|
+
def __init__(__self__, *,
|
|
23
|
+
length: pulumi.Input[builtins.int]):
|
|
24
|
+
"""
|
|
25
|
+
The set of arguments for constructing a RandomComponent resource.
|
|
26
|
+
"""
|
|
27
|
+
pulumi.set(__self__, "length", length)
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
@pulumi.getter
|
|
31
|
+
def length(self) -> pulumi.Input[builtins.int]:
|
|
32
|
+
return pulumi.get(self, "length")
|
|
33
|
+
|
|
34
|
+
@length.setter
|
|
35
|
+
def length(self, value: pulumi.Input[builtins.int]):
|
|
36
|
+
pulumi.set(self, "length", value)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@pulumi.type_token("provider-boilerplate:index:RandomComponent")
|
|
40
|
+
class RandomComponent(pulumi.ComponentResource):
|
|
41
|
+
@overload
|
|
42
|
+
def __init__(__self__,
|
|
43
|
+
resource_name: str,
|
|
44
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
45
|
+
length: Optional[pulumi.Input[builtins.int]] = None,
|
|
46
|
+
__props__=None):
|
|
47
|
+
"""
|
|
48
|
+
Create a RandomComponent resource with the given unique name, props, and options.
|
|
49
|
+
:param str resource_name: The name of the resource.
|
|
50
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
51
|
+
"""
|
|
52
|
+
...
|
|
53
|
+
@overload
|
|
54
|
+
def __init__(__self__,
|
|
55
|
+
resource_name: str,
|
|
56
|
+
args: RandomComponentArgs,
|
|
57
|
+
opts: Optional[pulumi.ResourceOptions] = None):
|
|
58
|
+
"""
|
|
59
|
+
Create a RandomComponent resource with the given unique name, props, and options.
|
|
60
|
+
:param str resource_name: The name of the resource.
|
|
61
|
+
:param RandomComponentArgs args: The arguments to use to populate this resource's properties.
|
|
62
|
+
:param pulumi.ResourceOptions opts: Options for the resource.
|
|
63
|
+
"""
|
|
64
|
+
...
|
|
65
|
+
def __init__(__self__, resource_name: str, *args, **kwargs):
|
|
66
|
+
resource_args, opts = _utilities.get_resource_args_opts(RandomComponentArgs, pulumi.ResourceOptions, *args, **kwargs)
|
|
67
|
+
if resource_args is not None:
|
|
68
|
+
__self__._internal_init(resource_name, opts, **resource_args.__dict__)
|
|
69
|
+
else:
|
|
70
|
+
__self__._internal_init(resource_name, *args, **kwargs)
|
|
71
|
+
|
|
72
|
+
def _internal_init(__self__,
|
|
73
|
+
resource_name: str,
|
|
74
|
+
opts: Optional[pulumi.ResourceOptions] = None,
|
|
75
|
+
length: Optional[pulumi.Input[builtins.int]] = None,
|
|
76
|
+
__props__=None):
|
|
77
|
+
opts = pulumi.ResourceOptions.merge(_utilities.get_resource_opts_defaults(), opts)
|
|
78
|
+
if not isinstance(opts, pulumi.ResourceOptions):
|
|
79
|
+
raise TypeError('Expected resource options to be a ResourceOptions instance')
|
|
80
|
+
if opts.id is not None:
|
|
81
|
+
raise ValueError('ComponentResource classes do not support opts.id')
|
|
82
|
+
else:
|
|
83
|
+
if __props__ is not None:
|
|
84
|
+
raise TypeError('__props__ is only valid when passed in combination with a valid opts.id to get an existing resource')
|
|
85
|
+
__props__ = RandomComponentArgs.__new__(RandomComponentArgs)
|
|
86
|
+
|
|
87
|
+
if length is None and not opts.urn:
|
|
88
|
+
raise TypeError("Missing required property 'length'")
|
|
89
|
+
__props__.__dict__["length"] = length
|
|
90
|
+
__props__.__dict__["password"] = None
|
|
91
|
+
super(RandomComponent, __self__).__init__(
|
|
92
|
+
'provider-boilerplate:index:RandomComponent',
|
|
93
|
+
resource_name,
|
|
94
|
+
__props__,
|
|
95
|
+
opts,
|
|
96
|
+
remote=True)
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
@pulumi.getter
|
|
100
|
+
def length(self) -> pulumi.Output[builtins.int]:
|
|
101
|
+
return pulumi.get(self, "length")
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
@pulumi.getter
|
|
105
|
+
def password(self) -> pulumi.Output[builtins.str]:
|
|
106
|
+
return pulumi.get(self, "password")
|
|
107
|
+
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pulumi_provider_boilerplate
|
|
3
|
+
Version: 0.1.0a1749159636
|
|
4
|
+
Requires-Python: >=3.9
|
|
5
|
+
Description-Content-Type: text/markdown
|
|
6
|
+
Requires-Dist: parver>=0.2.1
|
|
7
|
+
Requires-Dist: pulumi<4.0.0,>=3.165.0
|
|
8
|
+
Requires-Dist: semver>=2.8.1
|
|
9
|
+
Requires-Dist: typing-extensions<5,>=4.11; python_version < "3.11"
|
|
10
|
+
|
|
11
|
+
# Pulumi Native Provider Boilerplate
|
|
12
|
+
|
|
13
|
+
This repository is a boilerplate showing how to create and locally test a native Pulumi provider (with examples of both CustomResource and ComponentResource [resource types](https://www.pulumi.com/docs/iac/concepts/resources/)).
|
|
14
|
+
|
|
15
|
+
## Authoring a Pulumi Native Provider
|
|
16
|
+
|
|
17
|
+
This boilerplate creates a working Pulumi-owned provider named `provider-boilerplate`.
|
|
18
|
+
It implements a random number generator that you can [build and test out for yourself](#test-against-the-example) and then replace the Random code with code specific to your provider.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Prerequisites
|
|
22
|
+
|
|
23
|
+
You will need to ensure the following tools are installed and present in your `$PATH`:
|
|
24
|
+
|
|
25
|
+
* [`pulumictl`](https://github.com/pulumi/pulumictl#installation)
|
|
26
|
+
* [Go 1.21](https://golang.org/dl/) or 1.latest
|
|
27
|
+
* [NodeJS](https://nodejs.org/en/) 14.x. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS installations.
|
|
28
|
+
* [Yarn](https://yarnpkg.com/)
|
|
29
|
+
* [TypeScript](https://www.typescriptlang.org/)
|
|
30
|
+
* [Python](https://www.python.org/downloads/) (called as `python3`). For recent versions of MacOS, the system-installed version is fine.
|
|
31
|
+
* [.NET](https://dotnet.microsoft.com/download)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Build & test the boilerplate provider
|
|
35
|
+
|
|
36
|
+
1. Run `make build install` to build and install the provider.
|
|
37
|
+
1. Run `make gen_examples` to generate the example programs in `examples/` off of the source `examples/yaml` example program.
|
|
38
|
+
1. Run `make up` to run the example program in `examples/yaml`.
|
|
39
|
+
1. Run `make down` to tear down the example program.
|
|
40
|
+
|
|
41
|
+
### Creating a new provider repository
|
|
42
|
+
|
|
43
|
+
Pulumi offers this repository as a [GitHub template repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for convenience. From this repository:
|
|
44
|
+
|
|
45
|
+
1. Click "Use this template".
|
|
46
|
+
1. Set the following options:
|
|
47
|
+
* Owner: pulumi
|
|
48
|
+
* Repository name: pulumi-provider-boilerplate (replace "provider-boilerplate" with the name of your provider)
|
|
49
|
+
* Description: Pulumi provider for xyz
|
|
50
|
+
* Repository type: Public
|
|
51
|
+
1. Clone the generated repository.
|
|
52
|
+
|
|
53
|
+
From the templated repository:
|
|
54
|
+
|
|
55
|
+
1. Run the following command to update files to use the name of your provider (third-party: use your GitHub organization/username):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
make prepare NAME=foo ORG=myorg REPOSITORY=github.com/myorg/pulumi-foo
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This will do the following:
|
|
62
|
+
- rename folders in `provider/cmd` to `pulumi-resource-{NAME}`
|
|
63
|
+
- replace dependencies in `provider/go.mod` to reflect your repository name
|
|
64
|
+
- find and replace all instances of `provider-boilerplate` with the `NAME` of your provider.
|
|
65
|
+
- find and replace all instances of the boilerplate `abc` with the `ORG` of your provider.
|
|
66
|
+
- replace all instances of the `github.com/pulumi/pulumi-provider-boilerplate` repository with the `REPOSITORY` location
|
|
67
|
+
|
|
68
|
+
#### Build the provider and install the plugin
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
$ make build install
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This will:
|
|
75
|
+
|
|
76
|
+
1. Create the SDK codegen binary and place it in a `./bin` folder (gitignored)
|
|
77
|
+
2. Create the provider binary and place it in the `./bin` folder (gitignored)
|
|
78
|
+
3. Generate the dotnet, Go, Node, and Python SDKs and place them in the `./sdk` folder
|
|
79
|
+
4. Install the provider on your machine.
|
|
80
|
+
|
|
81
|
+
#### Test against the example
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
$ cd examples/simple
|
|
85
|
+
$ yarn link @pulumi/provider-boilerplate
|
|
86
|
+
$ yarn install
|
|
87
|
+
$ pulumi stack init test
|
|
88
|
+
$ pulumi up
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Now that you have completed all of the above steps, you have a working provider that generates a random string for you.
|
|
92
|
+
|
|
93
|
+
#### A brief repository overview
|
|
94
|
+
|
|
95
|
+
You now have:
|
|
96
|
+
|
|
97
|
+
1. A `provider/` folder containing the building and implementation logic.
|
|
98
|
+
1. `cmd/pulumi-resource-provider-boilerplate/main.go` - holds the provider's sample implementation logic.
|
|
99
|
+
2. `Makefile` - targets to help with building and publishing the provider. Run `make ci-mgmt` to regenerate CI workflows.
|
|
100
|
+
3. `sdk` - holds the generated code libraries created by `pulumi gen-sdk`.
|
|
101
|
+
4. `examples` a folder of Pulumi programs to try locally and/or use in CI.
|
|
102
|
+
5. A `Makefile` and this `README`.
|
|
103
|
+
|
|
104
|
+
#### Additional Details
|
|
105
|
+
|
|
106
|
+
This repository depends on the pulumi-go-provider library. For more details on building providers, please check
|
|
107
|
+
the [Pulumi Go Provider docs](https://github.com/pulumi/pulumi-go-provider).
|
|
108
|
+
|
|
109
|
+
### Build Examples
|
|
110
|
+
|
|
111
|
+
Create an example program using the resources defined in your provider, and place it in the `examples/` folder.
|
|
112
|
+
|
|
113
|
+
You can now repeat the steps for [build, install, and test](#test-against-the-example).
|
|
114
|
+
|
|
115
|
+
## Configuring CI and releases
|
|
116
|
+
|
|
117
|
+
1. Follow the instructions laid out in the [deployment templates](./deployment-templates/README-DEPLOYMENT.md).
|
|
118
|
+
|
|
119
|
+
## References
|
|
120
|
+
|
|
121
|
+
Other resources/examples for implementing providers:
|
|
122
|
+
* [Pulumi Command provider](https://github.com/pulumi/pulumi-command/blob/master/provider/pkg/provider/provider.go)
|
|
123
|
+
* [Pulumi Go Provider repository](https://github.com/pulumi/pulumi-go-provider)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
pulumi_provider_boilerplate/__init__.py
|
|
4
|
+
pulumi_provider_boilerplate/_utilities.py
|
|
5
|
+
pulumi_provider_boilerplate/provider.py
|
|
6
|
+
pulumi_provider_boilerplate/pulumi-plugin.json
|
|
7
|
+
pulumi_provider_boilerplate/py.typed
|
|
8
|
+
pulumi_provider_boilerplate/random.py
|
|
9
|
+
pulumi_provider_boilerplate/random_component.py
|
|
10
|
+
pulumi_provider_boilerplate.egg-info/PKG-INFO
|
|
11
|
+
pulumi_provider_boilerplate.egg-info/SOURCES.txt
|
|
12
|
+
pulumi_provider_boilerplate.egg-info/dependency_links.txt
|
|
13
|
+
pulumi_provider_boilerplate.egg-info/requires.txt
|
|
14
|
+
pulumi_provider_boilerplate.egg-info/top_level.txt
|
|
15
|
+
pulumi_provider_boilerplate/config/__init__.py
|
|
16
|
+
pulumi_provider_boilerplate/config/__init__.pyi
|
|
17
|
+
pulumi_provider_boilerplate/config/vars.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
pulumi_provider_boilerplate-0.1.0a1749159636/pulumi_provider_boilerplate.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pulumi_provider_boilerplate
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pulumi_provider_boilerplate"
|
|
3
|
+
dependencies = ["parver>=0.2.1", "pulumi>=3.165.0,<4.0.0", "semver>=2.8.1", "typing-extensions>=4.11,<5; python_version < \"3.11\""]
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
requires-python = ">=3.9"
|
|
6
|
+
version = "0.1.0a1749159636"
|
|
7
|
+
|
|
8
|
+
[build-system]
|
|
9
|
+
requires = ["setuptools>=61.0"]
|
|
10
|
+
build-backend = "setuptools.build_meta"
|
|
11
|
+
|
|
12
|
+
[tool]
|
|
13
|
+
[tool.setuptools]
|
|
14
|
+
[tool.setuptools.package-data]
|
|
15
|
+
pulumi_provider_boilerplate = ["py.typed", "pulumi-plugin.json"]
|