1. Packages
  2. AWS Classic
  3. How-to Guides
  4. ECS Fargate Containers

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

ECS Fargate Containers

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    View Code Deploy this example with Pulumi

    Companion to the tutorial Provision containers on AWS.

    Prerequisites

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

    Deploy the App

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

    Step 1: Create a new stack

    ```
    $ pulumi stack init containers-dev
    ```
    

    Step 2: Configure AWS region for Pulumi

    For this example, you need to set an AWS region that supports Fargate. Refer to the AWS Region Table for product availability.

    ```
    $ pulumi config set aws:region us-west-2
    ```
    

    Step 3: Restore NPM modules

    You can do this via npm install or yarn install.

    Step 4:. Preview and deploy the app

    Run the following command:

    ```
    $ pulumi up
    ```
    

    The preview will take a few minutes, as it builds a Docker container. A total of 19 resources are created.

    Step 5: View the endpoint URL

    Run pulumi stack output to view your stack’s output properties, and then curl the command to view the resulting page. $(pulumi stack output url) evaluates to the load balancer’s URL.

    ```bash
    $ pulumi stack output
    Current stack outputs (1)
        OUTPUT                  VALUE
        hostname                http://***.elb.us-west-2.amazonaws.com
    
    $ curl $(pulumi stack output hostname)
    <html>
        <head><meta charset="UTF-8">
        <title>Hello, Pulumi!</title></head>
    <body>
        <p>Hello, S3!</p>
        <p>Made with ❤️ with <a href="https://pulumi.com">Pulumi</a></p>
    </body></html>
    ```
    

    Step 6: View 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 aws-js-containers-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 to avoid incurring any costs. Select yes on the confirmation prompt so Pulumi will remove all of the resources that you’ve created. To delete the stack itself, run pulumi stack rm. Note that this command deletes all deployment history from the Pulumi console, unless you’ve explicitly chosen a different backend for storing your infrastructure state.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi