sparse-intern-71089
01/03/2024, 10:44 PMminiature-musician-31262
01/03/2024, 10:55 PMimport json
from pulumi_aws import s3
with open("buckets.json") as bucket_data:
buckets = json.load(bucket_data)
for bucket in buckets:
s3.Bucket(bucket)
... where buckets.json
just contains a JSON array of strings:
[
"one",
"two",
"three"
]
miniature-musician-31262
01/03/2024, 10:55 PMminiature-musician-31262
01/03/2024, 10:57 PMos.getcwd()
. But based on what you've described, I don't think you'll need it.miniature-musician-31262
01/03/2024, 11:02 PMimport json
import pulumi
from pulumi_aws import s3
config = pulumi.Config()
bucket_list = config.get("bucket_path")
with open(bucket_list) as bucket_data:
buckets = json.load(bucket_data)
for bucket in buckets:
s3.Bucket(bucket)
with a config file like:
config:
aws:region: us-west-2
python-json:bucket_path: ./buckets.json
miniature-musician-31262
01/03/2024, 11:10 PMswift-king-1490
01/03/2024, 11:26 PMos.getcwd()
but unfortunately, pulumi changes the current directory to the program directory so it does not give an accurate value š Using the project structure below, if I am inside the configs/dev
directory when I run pulumi up
, if I add print(os.getcwd())
inside the __main__.py
, it returns the path to the src
folder and not the configs folder
⢠Your example works because the Pulumi.yaml
and the python program are in the same folder. I guess that's on me for not being more detailed š
This is my project structure:
āāā configs
ā āāā dev
ā ā āāā Pulumi.main.yaml
ā ā āāā Pulumi.yaml
ā ā āāā auth0-users.yaml
āāā requirements.txt
āāā src
āāā __init__.py
āāā __main__.py
āāā __pycache__
āāā auth0_database.py
and the Pulumi.yaml
file has main: ../../src
attributeminiature-musician-31262
01/03/2024, 11:33 PMminiature-musician-31262
01/03/2024, 11:36 PMminiature-musician-31262
01/03/2024, 11:37 PMminiature-musician-31262
01/03/2024, 11:41 PMminiature-musician-31262
01/03/2024, 11:50 PMminiature-musician-31262
01/03/2024, 11:56 PMswift-king-1490
01/03/2024, 11:56 PMos.getcwd()
inside __main__.py
and manually compute the path back to the configs folder like: ../configs/dev
where dev
would be stored in a variable so I can dynamically adjust the pathswift-king-1490
01/03/2024, 11:57 PMminiature-musician-31262
01/03/2024, 11:59 PMconfigs
folder, it's running in the src
folder, so this makes sense, relative to where the program code isswift-king-1490
01/03/2024, 11:59 PMFileAsset
resource) but does not expose it anywhere š
Maybe I could open a feature request for thisswift-king-1490
01/04/2024, 12:00 AMminiature-musician-31262
01/04/2024, 12:03 AM