Web Server Using Amazon EC2
Basic example of an AWS web server accessible over HTTP (in Python!)
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-py-webservercd pulumi-examples/aws-py-webserverAn example based on the Amazon sample at: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/deploying.applications.html. The example deploys an EC2 instance and opens port 80.
Prerequisites#
Deploying and running the program#
-
Create a new stack:
Terminal window pulumi stack init python-webserver-testing -
Set the AWS region:
Terminal window pulumi config set aws:region us-west-2 -
Run
pulumi upto preview and deploy changes:Terminal window pulumi upPreviewing stack 'python-webserver-testing'Previewing changes:...Do you want to proceed? yesUpdating stack 'python-webserver-testing'Performing changes:#: Resource Type Name Status Extra Info1: pulumi:pulumi:Stack webserver-py-python-webserver-testing + created2: aws:ec2:SecurityGroup web-secgrp + created3: aws:ec2:Instance web-server-www + createdinfo: 3 changes performed:+ 3 resources createdUpdate duration: 26.470339302sPermalink: https://pulumi.com/lindydonna/examples/webserver-py/python-webserver-testing/updates/1 -
View the host name and IP address of the instance via
stack output:Terminal window pulumi stack outputCurrent stack outputs (2):OUTPUT VALUEpublic_dns ec2-34-217-176-141.us-west-2.compute.amazonaws.compublic_ip 34.217.176.141 -
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.
