1. Packages
  2. AWS Classic
  3. How-to Guides
  4. Web Server Using Amazon EC2 (in Go)

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

Web Server Using Amazon EC2 (in Go)

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

    View Code Deploy

    This example deploys a simple AWS EC2 virtual machine running a Python web server. It uses Go as its infrastructure as code language.

    Deploying the App

    To deploy your infrastructure, follow the below steps.

    Prerequisites

    1. Install Go
    2. Install Pulumi
    3. Configure AWS Credentials

    Steps

    After cloning this repo, from this working directory, run these commands:

    1. Next, create a new Pulumi stack, which is an isolated deployment target for this example:

      $ pulumi stack init
      
    2. Set the required configuration variables for this program:

      $ pulumi config set aws:region us-east-1
      
    3. Stand up the VM, which will also boot up your Python web server on port 80:

      $ pulumi up
      
    4. After a couple minutes, your VM will be ready, and two stack outputs are printed:

      $ pulumi stack output
      Current stack outputs (2):
      OUTPUT          VALUE
      publicIp        53.40.227.82
      
    5. Thanks to the security group making port 80 accessible to the 0.0.0.0/0 CIDR block, we can curl it:

      $ curl $(pulumi stack output publicIp)
      Hello, World!
      
    6. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your VM.

    7. Afterwards, destroy your stack and remove it:

      $ pulumi destroy --yes
      $ pulumi stack rm --yes
      
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi