forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
46 lines (40 loc) · 1.7 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright 2017, Pulumi Corporation. All rights reserved.
import * as pulumi from "@pulumi/pulumi";
import * as cloud from "@pulumi/cloud";
// Get the password to use for Redis from config.
let config = new pulumi.Config();
let redisPassword = config.require("redisPassword");
let redisPort = 6379;
// The data layer for the application
// Use the 'image' property to point to a pre-built Docker image.
let redisCache = new cloud.Service("voting-app-cache", {
containers: {
redis: {
image: "redis:alpine",
memory: 512,
ports: [{ port: redisPort }],
command: ["redis-server", "--requirepass", redisPassword],
},
},
});
let redisEndpoint = redisCache.endpoints.apply(endpoints => endpoints.redis[redisPort]);
// A custom container for the frontend, which is a Python Flask app
// Use the 'build' property to specify a folder that contains a Dockerfile.
// Pulumi builds the container for you and pushes to an ECR registry
let frontend = new cloud.Service("voting-app-frontend", {
containers: {
votingAppFrontend: {
build: "./frontend", // path to the folder containing the Dockerfile
memory: 512,
ports: [{ port: 80 }],
environment: {
// pass the Redis container info in environment variables
"REDIS": redisEndpoint.apply(e => e.hostname),
"REDIS_PORT": redisEndpoint.apply(e => e.port.toString()),
"REDIS_PWD": redisPassword
}
},
},
});
// Export a variable that will be displayed during 'pulumi up'
export let frontendURL = frontend.endpoints.apply(e => e["votingAppFrontend"][80].hostname);