AWS Classic

v5.21.1 published on Thursday, Nov 17, 2022 by Pulumi

Easy container example

View Code Deploy

Companion to the tutorial Provision containers on AWS.


To run this example, make sure Docker is installed and running.

Running the App

Note: some values in this example will be different from run to run. These values are indicated with ***.

  1. Create a new stack:

    $ pulumi stack init containers-dev
  2. Configure Pulumi to use an AWS region that supports Fargate. This is currently only available in us-east-1, us-east-2, us-west-2, and eu-west-1:

    $ pulumi config set aws:region us-west-2
  3. Restore NPM modules via npm install or yarn install.

  4. Preview and deploy the app via pulumi up. The preview will take a few minutes, as it builds a Docker container. A total of 19 resources are created.

    $ pulumi up
  5. View the endpoint URL, and run curl:

    $ pulumi stack output
    Current stack outputs (1)
        OUTPUT                  VALUE
        hostname                http://***
    $ curl $(pulumi stack output hostname)
        <head><meta charset="UTF-8">
        <title>Hello, Pulumi!</title></head>
        <p>Hello, S3!</p>
        <p>Made with ❤️ with <a href="">Pulumi</a></p>
  6. 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] - - [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.