Python Pulumi: Difference between revisions
Jump to navigation
Jump to search
(→AWS) |
|||
Line 39: | Line 39: | ||
└─ pyvenv.cfg | └─ pyvenv.cfg | ||
</font> | </font> | ||
Also see | Also see: {{Internal|Pulumi_Concepts#Project_Layout|Pulumi Concepts | Project Layout}} | ||
==<tt>__main__.py</tt>== | ==<tt>__main__.py</tt>== | ||
<code>__main__.py</code> is the Pulumi Python [[Pulumi_Concepts#Program|program]] that defines the stack resources. | <code>__main__.py</code> is the Pulumi Python [[Pulumi_Concepts#Program|program]] that defines the stack resources. |
Revision as of 00:06, 12 January 2022
External
Internal
Pulumi Python SDK
The SDK is available as a pip package.
Python Pulumi and Virtual Environments
A new Python project created with pulumi new
will have a virtual environment created in a venv
directory with required dependencies from requirements.txt
installed in it. This behavior is controlled by the virtualenv
runtime
option in Pulumi.yaml:
runtime:
name: python
options:
virtualenv: venv
virtualenv
is the path, relative to the project directory, to the virtual environment to use.
Pulumi Python Packges
Adding a New Dependency
To install a new dependency in the virtual environment, add the entry to requirements.txt
and run in the project directory:
venv/bin/pip install -r requirements.txt
Project Layout
my-project │ ├─ README.md ├─ Pulumi.yaml ├─ Pulumi.my-stack.yaml ├─ __main__.py ├─ requirements.txt └─ venv ├─ bin │ ├─ pip │ └─ python ├─ include ├─ lib └─ pyvenv.cfg
Also see:
__main__.py
__main__.py
is the Pulumi Python program that defines the stack resources.
import pulumi
from pulumi_aws import ssm
parameter = ssm.Parameter("/test/a", type="String", value="1234")
pulumi.export("parameter_name", parameter.id)