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.
Showing
8 changed files
with
115 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,3 @@ | ||
name: container-quickstart | ||
description: NGINX container example | ||
runtime: nodejs |
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,60 @@ | ||
# Easy container example | ||
|
||
Companion to the tutorial [Provision containers on AWS](https://docs.pulumi.com/quickstart/aws-containers.html). | ||
|
||
## Prerequisites | ||
|
||
To run this example, make sure [Docker](https://docs.docker.com/engine/installation/) is installed and running. | ||
|
||
## Running the App | ||
|
||
1. Create a new stack: | ||
|
||
``` | ||
$ pulumi stack init containers-dev | ||
``` | ||
|
||
1. Configure Pulumi to use AWS Fargate, which is currently only available in `us-east-1`, `us-west-2`, and `eu-west-1`: | ||
|
||
``` | ||
$ pulumi config set aws:region us-west-2 | ||
$ pulumi config set cloud-aws:useFargate true | ||
``` | ||
|
||
1. Restore NPM modules via `npm install`. | ||
|
||
1. Preview and deploy the app via `pulumi update`. The preview will take a few minutes, as it builds a Docker container. A total of 19 resources are created. | ||
|
||
``` | ||
$ pulumi update | ||
``` | ||
|
||
1. View the endpoint URL, and run curl or view in a browser. | ||
|
||
```bash | ||
$ pulumi stack output | ||
Current stack outputs (1) | ||
OUTPUT VALUE | ||
hostname https://42dc3ff4-ac65d11-86a100b6e1d7f210.elb.us-west-2.amazonaws.com | ||
|
||
$ curl $(pulumi stack output hostname) | ||
<html> | ||
<head> | ||
<title>Hello Pulumi</title><meta charset="UTF-8"> | ||
... | ||
``` | ||
|
||
![Screenshot of browser](./final-screenshot.png) | ||
|
||
1. To view the runtime logs from the container, use the `pulumi logs` command. To get a log stream, use `pulumi logs --follow`. | ||
|
||
``` | ||
$ pulumi logs --follow | ||
Collecting logs for stack container-quickstart-dev since 2018-05-22T14:25:46.000-07:00. | ||
2018-05-22T15:33:22.057-07:00[ pulumi-nginx] 172.31.13.248 - - [22/May/2018:22:33:22 +0000] "GET / HTTP/1.1" 200 189 "-" "curl/7.54.0" "-" | ||
``` | ||
|
||
## Clean up | ||
|
||
To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. | ||
|
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,2 @@ | ||
FROM nginx | ||
COPY content /usr/share/nginx/html |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<html> | ||
<head> | ||
<title>Hello Pulumi</title><meta charset="UTF-8"> | ||
<link rel="shortcut icon" href="favicon.png" type="image/png"> | ||
|
||
<style> | ||
body { background: linear-gradient( #7c4792, white); } | ||
p.main { font-size: 2.5em; } | ||
p.footer { font-size: 1em; } | ||
div { | ||
font-family: Helvetica, Segoe UI, Arial, sans-serif; | ||
margin: 20px; | ||
text-align: center; | ||
color: white; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div> | ||
<p class="main">Hello, containers!</p> | ||
<p class="footer">Made with ❤️ using <a href="https://pulumi.com">Pulumi</a></p> | ||
</div> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,15 @@ | ||
const cloud = require("@pulumi/cloud-aws"); | ||
|
||
let service = new cloud.Service("pulumi-nginx", { | ||
containers: { | ||
nginx: { | ||
build: "./app", | ||
memory: 128, | ||
ports: [{ port: 80 }], | ||
}, | ||
}, | ||
replicas: 2, | ||
}); | ||
|
||
// export just the hostname property of the container frontend | ||
exports.hostname = service.defaultEndpoint.apply(e => `https://${e.hostname}`); |
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,10 @@ | ||
{ | ||
"name": "container-quickstart", | ||
"main": "index.js", | ||
"dependencies": { | ||
"@pulumi/aws": "^0.13.0", | ||
"@pulumi/cloud": "^0.13.0", | ||
"@pulumi/cloud-aws": "^0.13.0", | ||
"@pulumi/pulumi": "^0.12.2" | ||
} | ||
} |