hi, I'm a complete pulumi noob. my initial goal is...
# getting-started
b
hi, I'm a complete pulumi noob. my initial goal is to create just a vpc using a specific aws profile from my aws credentials file. I have so far: - created a new directory - run 'pulumi new' , and chosen aws-python - taken the following code from the 'setting up a new vpc' part of the pulumi getting started section of their website: import pulumi import pulumi_awsx as awsx vpc = awsx.ec2.Vpc("custom") pulumi.export("vpcId", vpc.vpc_id) pulumi.export("publicSubnetIds", vpc.public_subnet_ids) pulumi.export("privateSubnetIds", vpc.private_subnet_ids) - replaced the default code in the '__main__.py' file with the above code - added the following line to Pulumi.<stackname>.yaml: awsprofile dev-account When I try to run: 'pulumi up' I'm getting the error: ModuleNotFoundError: No module named 'pulumi_awsx' I then executed: 'pip install pulumi_awsx' This installed the module. When I tried to run 'pulumi up' again I experienced the same error What am I missing? (doing this on a windows machine btw)
in the end I found an article recommending to add it to the requirements.txt file and run: - python -m venv venv - venv\Scripts\pip install -r requirements.txt
s
@brash-restaurant-84207 Do you mind if I asked you where you found the article?
We also have some self-guided workshops for Python and AWS here: https://pulumi.awsworkshop.io/20_cloud_engineering_python.html
b
I think I noticed in this github issue: https://github.com/pulumi/pulumi/issues/3311 - the line:
Copy code
master_user_data = """#!/bin/bash -e
I'm not sure what is so special about the way I'm using Pulumi (from a windows machine - with code written in Python) that I seem to be running into these 'seemingly rare' scenarios... but when I do it sometimes feels like banging my head against a brick wall trying to find a solution.... so much of the google searches point back to the Pulumi website documentation which doesn't always provide clear path to resolving the issue... not to mention that for some reason many of the solutions seem to be for Typescript and not Python....
s
Using venv with Pulumi in Python is definitely not an edge case. If you're not getting good guidance from the docs, that's something we should address.
b
Sorry actually I got mixed up with another thread that I posted (https://pulumi-community.slack.com/archives/C84L4E3N1/p1664481771461259) I'm curious at to why all the documentation I found on the Pulumi and AWS websites, the format for user data was" user_data=""" #!/bin/bash echo "Hello, World!" > index.html nohup python -m SimpleHTTPServer 80 & """ and when I tried this and then looked in the file: '/var/lib/cloud/instances/<instance_id>/scripts/part-001' which is the uploaded user_data section, the first line was blank and only on the second line did '#!/bin/bash' appear, which caused the script not to work. It was only when I changed the user_data section to: 'user_data="""#!/bin/bash' that the first line of the uploaded script was '#!/bin/bash'
s
Can you post a link to where you found that user data example in Python?
b
q
@stocky-restaurant-98004 I also encountered the same issue following this tutorial - https://pulumi.awsworkshop.io/20_cloud_engineering_python/30_deploying_webservers/10_provision_ec2.html
If I recall correctly, the AMI filter on that page also did not work.