Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


AWS Web Server example in Python

An example based on the Amazon sample at: The example deploys an EC2 instance and opens port 80.


  1. Install Pulumi
  2. Configure Pulumi for AWS
  3. Configure Pulumi for Python

Deploying and running the program

  1. Install dependencies (a virtualenv is recommended - see Pulumi Python docs):

    $ pip install -r requirements.txt
  2. Create a new stack:

    $ pulumi stack init python-webserver-testing
  3. Set the AWS region:

    $ pulumi config set aws:region us-west-2
  4. Run pulumi up to preview and deploy changes:

    $ pulumi up
    Previewing stack 'python-webserver-testing'
    Previewing changes:
    Do you want to proceed? yes
    Updating stack 'python-webserver-testing'
    Performing changes:
    #: Resource Type          Name                                   Status     Extra Info
    1: pulumi:pulumi:Stack    webserver-py-python-webserver-testing  + created  
    2: aws:ec2:SecurityGroup  web-secgrp                             + created  
    3: aws:ec2:Instance       web-server-www                         + created  
    info: 3 changes performed:
        + 3 resources created
    Update duration: 26.470339302s
  5. View the host name and IP address of the instance via stack output:

    $ pulumi stack output
    Current stack outputs (2):
        OUTPUT                                           VALUE
  6. Verify that the EC2 instance exists, by either using the AWS Console or running aws ec2 describe-instances.

Clean up

To clean up resources, run pulumi destroy and answer the confirmation question at the prompt.

You can’t perform that action at this time.