forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add our AWS EC2 instance example in Go (pulumi#512)
This translates our existing AWS EC2 instance examples that we already have in JavaScript and Python to Go.
- Loading branch information
Showing
5 changed files
with
790 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: go-webserver | ||
runtime: go | ||
description: Basic example of an AWS web server accessible over HTTP | ||
template: | ||
config: | ||
aws:region: | ||
description: The AWS region to deploy into | ||
default: us-east-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new) | ||
|
||
# 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](https://golang.org/doc/install) | ||
2. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) | ||
3. [Configure AWS Credentials](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/) | ||
|
||
### Steps | ||
|
||
After cloning this repo, from this working directory, run these commands: | ||
|
||
1. Go is a compiled language, so you must first compile it: | ||
|
||
```bash | ||
$ go build -o go-webserver | ||
``` | ||
|
||
2. Next, create a new Pulumi stack, which is an isolated deployment target for this example: | ||
|
||
```bash | ||
$ pulumi stack init | ||
``` | ||
|
||
3. Set the required configuration variables for this program: | ||
|
||
```bash | ||
$ pulumi config set aws:region us-east-1 | ||
``` | ||
|
||
4. Stand up the VM, which will also boot up your Python web server on port 80: | ||
|
||
```bash | ||
$ pulumi up | ||
``` | ||
|
||
5. After a couple minutes, your VM will be ready, and two stack outputs are printed: | ||
|
||
```bash | ||
$ pulumi stack output | ||
Current stack outputs (2): | ||
OUTPUT VALUE | ||
publicIp 53.40.227.82 | ||
``` | ||
|
||
6. Thanks to the security group making port 80 accessible to the 0.0.0.0/0 CIDR block, we can curl it: | ||
|
||
```bash | ||
$ curl $(pulumi stack output publicIp) | ||
Hello, World! | ||
``` | ||
|
||
7. From there, feel free to experiment. Simply making edits and running `pulumi up` will incrementally update your VM. | ||
|
||
8. Afterwards, destroy your stack and remove it: | ||
|
||
```bash | ||
$ pulumi destroy --yes | ||
$ pulumi stack rm --yes | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/pulumi/examples/aws-go-webserver | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/pulumi/pulumi v1.8.1 | ||
github.com/pulumi/pulumi-aws v1.17.0 | ||
) |
Oops, something went wrong.