LazyStack

Building the PetStore Solution

In this lesson step we will build the initial PetStore solution using the .NET LazyStack tool configured as a Visual Studio Tool.

This tutorial assumes you are using the Windows Visual Studio IDE.

1.1 Create PetStore solution

  1. Configure your developer workstation with Visual Studio IDE for Mac.
  2. Create a LazyStackTutorial Folder. We will be creating the PetStoreMac solution under this folder.
  3. Launch Visual Studio.
  4. Click on New project. The "Choose a template for your new project" dialog appears.
  5. Click on "Web and Console → App.
  6. Select API under the ASP.NET Core and click the Next button. The first "Configure your new API" page appears.
  7. Select .NET 5.0 for the target framework and click the Next button. The next "Configure your new API" page appears.
  8. Enter "PetStoreMac" as the Project Name.
  9. Keep "PetStoreMac" as the Solution Name.
  10. Edit the Location to point to the LazyStackTutorial folder.
  11. Leave the "Create a project directory within the solution directory" Checked.
  12. Click on the Create button. A solution with your PetStoreMac WebApi project is created.
  13. Download Startup.cs and place it into the PetStoreMac project folder.
  14. Download ConfigureSvcs.cs and place it into the PetStoreMac project folder.
  15. Select Visual Studio menuitem Build → Rebuild All. The solution compiles successfully.

1.2 Download PetStore.yaml and run LazyStack Generator

  1. Click to Download PetStoreMac.yaml file
  2. Move PetStoreMac.yaml from your Downloads folder to the PetStoreMac Solution root folder.
  3. Select Visual Studio "Tools → LazyStack - Generate Projects". The following folders and projects are are created.
    • Controllers folder
      • OrderController project
      • OrderSecureController project
      • PetController project
      • PetSecureController project
    • Lambdas folder
      • Order project
      • OrderSecure project
      • Pet project
      • PetSecure project
    • PetStoreClientSDK project
    • PetStoreSchema project
    • The following files are placed in the solution's root directory
      • LazyStack.yaml
      • LocalApis.json
      • SAM_Review.yaml
    • A serverless.template file is placed in a Stacks/Dev directory
      • Stacks folder
        • Dev folder
          • serverless.template
  4. Add files in solution directory to Solution Items folder
    1. Right Click "PetStoreMac" in solution explorer. The context menu appears.
    2. Select Add → Existing Files. The file picker dialog appears.
    3. In the PetStoreMac solution directory, select newly added files:
      • PetstoreMac.yaml
      • LazyStack.yaml
      • LocalApis.json
      • SAM_Review.yaml
    4. Click the Open button. A new solution explorer "Solution Items" folder is created containing the selected files.
  5. Add the serverless.template file and solution folders
    1. Right Click "PetStoreMac" in the solution explorer. The context menu appears.
    2. Select "Add → Solution Folder". A folder called "New Folder" is inserted into the solution explorer.
    3. Edit the name of folder to "Stacks".
    4. Right Click on the "Stacks" folder. The context menu appears.
    5. Select "Add → Solution folder". A new folder called "New Folder" is inserted under the Stacks folder.
    6. Edit the name of the folder to "Dev"
    7. Right Click on the "Dev" folder. The context menu appears.
    8. Select "Add → Existing Files. The file picker window appears,.
    9. Select the "LazyStackTutorial/PetStoreMac/Stacks/Dev/serverless.template" file.

1.3 Edit the LazyStack.yaml file

The Generate Projects command created a default LazyStack.yaml file in your solution's root folder. The file is now visible in the "Solution Items" folder in the solution explorer. We need to update it with your AWS profile and AWS region. Your initial LazyStack.yaml file should look like this:

# LazyStack Version 1.0.0
Stacks:
    Dev:
    ProfileName: default
    RegionName: us-east-1
    StackName: PetStoreMacDev 
    Stage: Dev
    UriCodeTarget: Debug/netcoreapp3.1
    ...
  1. Open the Solution Items\LazyStack.yaml file.
  2. Edit the ProfileName.

    You may modify the ProfileName if you are not using the profile "default" - Note: the profile "default" is created by the AWS CLI install unless you specify some other named profile.

  3. Edit the RegionName.
  4. Save the file.

1.4 Review the SAM_Review.yaml

The SAM_Review.yaml file was generated in the solution folder. This file contains the stack configuration without stack environment specific content inserted. Stack environments might include Dev, Test and Prod. Fully constituted templates are placed in the serverless.template files placed in the stack environment folder. For instance, the Stacks\Dev\serverless.template file is the template you will later use to publish the PetStoreDev stack to AWS.

You never edit the SAM_Review.yaml file directly.

  1. Open the Solution Items\SAM_Review.yaml file.
  2. Review contents. No need to understand all this content now.

The SAM_Review.yaml file will be updated with new content as we add and configure AWS stack resources during the tutorial. This file is regenerated each time you execute LazyStack -- Generate Projects.

1.5 Review serverless.template file

LazyStack Generate Projects process generates one serverless.template file for each environment. In this case, we have one Stacks Environment called "Dev" so a serverless.template file is generated in the Stacks\Dev folder.

You want to review the SAM template we will later publish to AWS. You never edit this file directly.

  1. Open the Stacks\Dev\serverless.template file.
  2. Review contents. No need to understand all this content now.

The serverless.template file will be updated with new content as we add and configure AWS stack resources during the tutorial. This file is regenerated each time you execute LazyStack -- Generate Projects.

Step Summary

In this lesson step we created a PetStore solution using the ASP.NET API project template, downloaded a OpenApi Specification called PetStoreMac.yaml and then used the Tools → LazyStack - Generate Projects to generate projects and configuration files for our stack. We added solution folders to surface these configuration files in the Visual Studio solution explorer. We then updated the LazyStack.yaml file AWS ProfileName and RegionName.