Skip to content

Latest commit

 

History

History
 
 

aws-go-webserver

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Deploy

Web Server Using Amazon EC2 (in Go)

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. Restore your Go dependencies. This example currently uses Dep to do so:

    $ dep ensure
  2. Go is a compiled language, so you must first compile it:

    $ go build -o go-webserver
  3. Next, create a new Pulumi stack, which is an isolated deployment target for this example:

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

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

    $ pulumi up
  6. 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
  7. 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!
  8. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your VM.

  9. Afterwards, destroy your stack and remove it:

    $ pulumi destroy --yes
    $ pulumi stack rm --yes