1. Packages
  2. AWS
  3. How-to Guides
  4. AWS StackReference Architecture
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

AWS StackReference Architecture

aws logo
AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi

    View Code

    This will deploy a Data VPC and an application VPC that is peered. It will deploy an RDS Instance into the Data VPC and it will run a sample application in ECS that is fronted with an ALB.

    The system has the following layers and need to be deployed in the following order to allow the correct data to be used between the system:

    1. Networking
    2. Database
    3. Application

    Pre-Requisites

    1. Install Pulumi.
    2. Install Node.js.
    3. Install a package manager for Node.js, such as NPM or Yarn.
    4. Configure AWS Credentials.

    Network

    1. Change to the networking project

      cd networking
      
    2. Install the dependencies.

      npm install
      
    3. Create a new Pulumi stack named dev.

      pulumi stack init dev
      
    4. Set the Pulumi configuration variables for the project.

      pulumi config set aws:region us-west-2
      

      If you wish to control the number of availability zones that the VPC will be created within, you can do this by setting:

      pulumi config set azCount 3
      
    5. Deploy the networking stack

      pulumi up
      

    Database

    1. Change to the database project

      cd database
      
    2. Install the dependencies.

      npm install
      
    3. Create a new Pulumi stack named dev.

      pulumi stack init dev
      
    4. Set the Pulumi configuration variables for the project:

      pulumi config set aws:region us-west-2
      pulumi config set dbUsername MyRootUser
      pulumi config set dbPassword --secret MyPassword1234!
      

      You need to set a stack reference to the networking stack so that the RDS Instance can be deployed into the correct VPC that was created in the networking stack. The stack needs to be in the form <organization_or_user>/<projectName>/<stackName> e.g. myUsername/multicloud/dev:

      pulumi config set networkingStack stack72/networking-layer/dev
      

      If you wish to specify an initial database name in the RDS Instance, then you can do so by setting the following:

      pulumi config set dbName myDatbaseName
      
    5. Deploy the database stack

      pulumi up
      

    Application

    1. Change to the application project

      cd application
      
    2. Install the dependencies.

      npm install
      
    3. Create a new Pulumi stack named dev.

      pulumi stack init dev
      
    4. Set the Pulumi configuration variables for the project:

      pulumi config set aws:region us-west-2
      

      You need to set a stack reference to the networking stack so that the RDS Instance can be deployed into the correct VPC that was created in the networking stack. The stack needs to be in the form <organization_or_user>/<projectName>/<stackName>:

      pulumi config set networkingStack stack72/networking-layer/dev
      

      You need to set a stack reference to the database stack so that the Application Instance can get the correct credentials and database information for application startup. The stack needs to be in the form <organization_or_user>/<projectName>/<stackName>:

      pulumi config set application-layer:databaseStack stack72/database-layer/dev
      
    5. Deploy the application stack

      pulumi up
      

    You can then take the output albAddress and hit it with curl or in the browser to see the application running.

    Clean Up

    In each of the directories, run the following command to tear down the resources that are part of our stack.

    1. Run pulumi destroy to tear down all resources. You’ll be prompted to make sure you really want to delete these resources.

      pulumi destroy
      
    2. To delete the stack, run the following command.

      pulumi stack rm
      

      Note: This command deletes all deployment history from the Pulumi Console and cannot be undone.

    aws logo
    AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi