LazyStack

Configure LazyStack Projects and DynamoDB

In this step we make some additions to the LazyStack.yaml file to support the use of DynamoDB and configure the Lambda and WebApi projects to reference the new PetStoreRepo project. Before we look at the LazyStack.yaml configuration directives in detail, here is a high-level summary of what we need to do:

  • Use ApiTagMap directive to map API endpoints to two ApiGateways.
  • Use ProjectOptions directive to configure these project options
  • Use AwsResources directive to define AWS::DynamoDB::Table resource for our stack.

As mentioned before, executing LazyStack - Generate Projects, creates/updates the following projects:

  • Controller projects
  • Lambda projects
  • PetStoreClientSDK project
  • PetStoreSchema project

These generated projects should not be edited as your changes would be lost when you run the generator again.

In addition to the generated projects, portions of the WebApi project "PetStore" are updated with each execution of LazyStack - Generate Projects.

LazyStack - Generate Projects does not update or modify any other projects in your solution.

5.1 Update LazyStack.yaml and Generate Projects

  1. Download this LazyStack.yaml file and move it into the solution's root folder.
  2. Open the LazyStack.yaml file and edit the ProfileName and RegionName values if necessary.
  3. Save the LazyStack.yaml file.
  4. Select Tools → LazyStack - Generate Projects.

    The LazyStack.log tab opens and logs are produced as Projects and generated files are updated.

  5. Rebuild Solution. All projects in the solution are compiled successfully.

5.2 Update WebApi project (PetStore) launchSettings.json file

  1. Open the PetStore\Properties\launchSettings.json file.
  2. Add the "TABLE_NAME" environmental variable as shown below on line 25.
  3. 
    {
        "iisSettings": {
          "windowsAuthentication": false, +
          "anonymousAuthentication": true, 
          "iisExpress": {
            "applicationUrl": "http://localhost:62817",
            "sslPort": 44399
          }
        },
        "profiles": {
          "IIS Express": {
            "commandName": "IISExpress",
            "launchBrowser": true,
            "environmentVariables": {
              "ASPNETCORE_ENVIRONMENT": "Development"
            }
          },
          "PetStore": {
            "commandName": "Project",
            "launchBrowser": true,
            "applicationUrl": "https://localhost:5001;http://localhost:5000",
            "environmentVariables": {
              "ASPNETCORE_ENVIRONMENT": "Development",
              "TABLE_NAME": "PetStoreDev-DB"
            }
          }
        }
      }
    
  4. Save the file.

Step Summary

In this step we updated the LazyStack.yaml file to create a DynamoDB resource and configure the WebApi (PetStore) project and Lambdas projects to reference the PetStoreRepo project. We also inserted an environment variable "TABLE_NAME" in the WebApi project's launchSettings.json file to reference a table called "PetStoreDev-DB" in the DynamoDb resource.