Hello everyone! I was wondering, is there any way...
# general
r
Hello everyone! I was wondering, is there any way to initialize and use a Pulumi client from within my code? Meaning that instead of running
pulumi up
using the CLI, I'll have something like the following (python): main.py
Copy code
from pulumi import client
from pulumi_aws import s3

# Initialize the Pulumi client
pulumi_client = PulumiClient()

# Provision a S3 bucket
web_bucket = s3.Bucket('s3-example-bucket')

pulumi_client.up()
pulumi_client.destroy()
Now instead of running
pulumi up
followed by a
pulumi destroy
, running this piece of code can be done by running:
python main.py
This is a very raw example, so please tell me if there's anything else you'd like me to elaborate on. Thanks in advance! :)
🙌 1
b
You should check out our automation api - that'll do pretty much all you've described there
r
thanks, looks awesome! taking a look 🙏
b
there are some great Python examples here @rich-action-28775 - https://github.com/pulumi/automation-api-examples/tree/main/python
🙌 1
b
@rich-action-28775 i just put the finishing touches on this guided tour as well, so take a look here: https://github.com/jaxxstorm/pulumi-automationapi-workshop Feedback appreciated!
🙏 1