PERN stack voting app
Voting app that uses containers
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-ts-pern-voting-appcd pulumi-examples/aws-ts-pern-voting-appA simple voting app that uses React, Express, PostgreSQL, and NodeJS.
The example shows how easy it is to deploy containers into production and to connect them to one another. Since the example defines a custom container, Pulumi does the following:
- Builds the Docker image
- Provisions AWS Container Registry (ECR) instance
- Pushes the image to the ECR instance
- Creates a new ECS task definition, pointing to the ECR image definition
Prerequisites#
Deploying the example#
-
Create a new stack:
Terminal window pulumi stack init aws-ts-pern-voting-app -
Set the AWS region and the usernames and passwords for a set of accounts the project uses. The user names must be valid PostgreSQL identifiers, and the passwords must satisfy the RDS master password rules (8-128 printable ASCII characters, excluding
/,",@, and spaces).Terminal window pulumi config set aws:region us-west-2pulumi config set sql-admin-name <NAME>pulumi config set sql-admin-password <PASSWORD> --secretpulumi config set sql-user-name <NAME>pulumi config set sql-user-password <PASSWORD> --secret -
Install dependencies:
Terminal window npm install -
Deploy the stack:
Terminal window pulumi upUpdating (aws-ts-pern-voting-app):Type Name Status Info+ pulumi:pulumi:Stack voting-app-aws-ts-pern-voting-app created+ ├─ awsx:x:ecs:FargateTaskDefinition server-side-service created...+ └─ pulumi-nodejs:dynamic:Resource postgresql-votes-schema createdOutputs:URL: "client-side-listener-086d27d-bb5f264d141c31b7.elb.us-west-2.amazonaws.com"Resources:+ 63 createdDuration: 4m2s -
View the DNS address of the instance via
pulumi stack output:Terminal window pulumi stack outputCurrent stack outputs (1):OUTPUT VALUEURL client-side-listener-086d27d-bb5f264d141c31b7.elb.us-west-2.amazonaws.com -
Verify that the ECS instance exists by connecting to it in a browser window.
Cleaning up#
To clean up resources, run pulumi destroy and answer the confirmation question at the prompt, then remove the stack:
pulumi destroypulumi stack rm