LzAws PowerShell Module: A comprehensive PowerShell module for deploying and managing multi-tenant SaaS applications on AWS. Provides cmdlets for infrastructure deployment, tenant management, authentication, web applications, and static assets using AWS SAM/CloudFormation templates.
LzAws is a PowerShell module designed for deploying and managing multi-tenant SaaS applications on AWS. It provides a comprehensive set of cmdlets for managing AWS infrastructure, including system resources, tenant configurations, authentication systems, web applications, and static assets.
.\Install-LzAws.ps1 -Scope CurrentUser
.\Install-LzAws.ps1 -Scope AllUsers
For development or testing without installation:
.\Import-LzAws.ps1
LzAws requires a systemconfig.yaml
file in your project hierarchy. The module will search up the directory tree to find this file.
SystemKey: myapp
SystemSuffix: prod
AwsProfile: myapp-prod
Region: us-east-1
Tenants:
- TenantKey: tenant1
Domain: tenant1.example.com
CertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/...
- TenantKey: tenant2
Domain: tenant2.example.com
CertificateArn: arn:aws:acm:us-east-1:123456789012:certificate/...
Services:
- ServiceKey: api
Template: Templates/sam.service.api.yaml
- ServiceKey: auth
Template: Templates/sam.service.auth.yaml
Deploys the core AWS infrastructure for your system.
Deploy-SystemAws
This cmdlet:
Deploys infrastructure for a specific tenant.
Deploy-TenantAws -TenantKey "tenant1"
Deploys infrastructure for all tenants defined in configuration.
Deploy-TenantsAws
This cmdlet:
Generates tenant configuration JSON file.
Get-TenantConfigAws -TenantKey "tenant1"
This cmdlet:
Deploys Lambda functions and API services.
Deploy-ServiceAws -ServiceKey "api"
This cmdlet:
Deploys Cognito user pools and authentication configurations.
Deploy-AuthsAws
This cmdlet:
Sets admin status for a user in Cognito.
Set-Admin -TenantKey "tenant1" -Email "admin@example.com" -IsAdmin $true
Deploys frontend web applications.
Deploy-WebappAws
This cmdlet:
Deploys static assets to S3 buckets.
Deploy-AssetsAws
This cmdlet:
Lists assets in tenant S3 buckets.
Get-AssetsAws -TenantKey "tenant1"
This cmdlet:
Deploys CloudFront and caching policies.
Deploy-PoliciesAws
This cmdlet:
Deploys permission policies to AWS.
Deploy-PermsAws
This cmdlet:
Lists all available LzAws commands.
Get-AwsCommands
Provides detailed help for any LzAws command.
Get-LzAwsHelp -CommandName "Deploy-TenantAws"
Gets the current version of the LzAws module.
Get-VersionAws
Retrieves CloudFront CDN logs.
Get-CDNLogAws -TenantKey "tenant1" -StartDate "2024-01-01" -EndDate "2024-01-31"
This cmdlet:
Gets entries from the key-value store.
Get-KvsEntries
This cmdlet:
Tests error handling functionality.
Deploy-TestError
The typical deployment sequence for a new system:
System Infrastructure
Deploy-SystemAws
Policies
Deploy-PoliciesAws
Deploy-PermsAws
Authentication
Deploy-AuthsAws
Services and APIs
Deploy-ServiceAws
Web Application
Deploy-WebappAws
Static Assets
Deploy-AssetsAws
Tenant Resources
Deploy-TenantsAws
# or for a specific tenant
Deploy-TenantAws -TenantKey "tenant1"
# Login to AWS SSO
aws sso login --profile myapp-dev
# The module will use the profile specified in systemconfig.yaml
Deploy-SystemAws
Ensure your AWS credentials are configured:
aws configure --profile myapp-dev
Enable verbose logging to see detailed operation information:
$LzAwsVerbosePreference = "Continue"
Deploy-SystemAws
LzAws provides detailed error messages with troubleshooting hints:
Error: Can't find systemconfig.yaml
Function: Get-SystemConfig
Hints:
- Are you running this from the root of a solution?
- Do you have a systemconfig.yaml file in a folder above?
- Check that the file name is exactly 'systemconfig.yaml'
Solution:
aws sso login --profile <profile-name>
aws configure list-profiles
Solution: This is normal when the infrastructure is already up-to-date. No action needed.
Solution:
Solution:
This module is licensed under the MIT License. See LICENSE file for details.