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.
- Multi-tenant Architecture Support: Deploy and manage isolated resources for multiple tenants
- Infrastructure as Code: Uses AWS SAM/CloudFormation templates for consistent deployments
- Comprehensive Resource Management: Covers system infrastructure, services, authentication, policies, and assets
- AWS SSO Integration: Supports AWS SSO profiles and standard AWS credentials
- Error Handling: Clear, actionable error messages with troubleshooting hints
- Modular Design: Organized public cmdlets with internal helper functions
- PowerShell 5.1 or higher
- AWS SAM CLI installed and configured
- Valid AWS credentials (IAM user or SSO profile)
- AWS PowerShell modules (automatically managed by LzAws)
.\Install-LzAws.ps1 -Scope CurrentUser.\Install-LzAws.ps1 -Scope AllUsersFor development or testing without installation:
.\Import-LzAws.ps1LzAws 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.yamlDeploys the core AWS infrastructure for your system.
Deploy-SystemAwsThis cmdlet:
- Must be run from the Service/AwsTemplates folder
- Deploys system-wide resources (S3 buckets, DynamoDB tables)
- Creates the system stack with key-value store
- Must be run before tenant deployments
Deploys infrastructure for a specific tenant.
Deploy-TenantAws -TenantKey "tenant1"Deploys infrastructure for all tenants defined in configuration.
Deploy-TenantsAwsThis cmdlet:
- Must be run from the Service/AwsTemplates folder
Generates tenant configuration JSON file.
Get-TenantConfigAws -TenantKey "tenant1"This cmdlet:
- Must be run from the Service/AwsTemplates folder
Deploys Lambda functions and API services.
Deploy-ServiceAws -ServiceKey "api"This cmdlet:
- Must be run from the Service/AwsTemplates folder
Deploys Cognito user pools and authentication configurations.
Deploy-AuthsAwsThis cmdlet:
- Must be run from the Service/AwsTemplates folder
Sets admin status for a user in Cognito.
Set-Admin -TenantKey "tenant1" -Email "admin@example.com" -IsAdmin $trueDeploys frontend web applications.
Deploy-WebappAwsThis cmdlet:
- Must be run from the App's solution folder
Deploys static assets to S3 buckets.
Deploy-AssetsAwsThis cmdlet:
- Must be run from the Tenancies solution folder.
Lists assets in tenant S3 buckets.
Get-AssetsAws -TenantKey "tenant1"This cmdlet:
- Must be run from the Tenancies solution folder.
Deploys CloudFront and caching policies.
Deploy-PoliciesAwsThis cmdlet:
- Must be run from the Service/AwsTemplates folder
Deploys permission policies to AWS.
Deploy-PermsAwsThis cmdlet:
- Must be run from the Service/AwsTemplates folder
Lists all available LzAws commands.
Get-AwsCommandsProvides detailed help for any LzAws command.
Get-LzAwsHelp -CommandName "Deploy-TenantAws"Gets the current version of the LzAws module.
Get-VersionAwsRetrieves CloudFront CDN logs.
Get-CDNLogAws -TenantKey "tenant1" -StartDate "2024-01-01" -EndDate "2024-01-31"This cmdlet:
- Must be run from the Service/AwsTemplates folder
Gets entries from the key-value store.
Get-KvsEntriesThis cmdlet:
- Must be run from the Service/AwsTemplates folder
Tests error handling functionality.
Deploy-TestErrorThe 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-SystemAwsEnsure your AWS credentials are configured:
aws configure --profile myapp-devEnable verbose logging to see detailed operation information:
$LzAwsVerbosePreference = "Continue"
Deploy-SystemAwsLzAws 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:
- Run
aws sso login --profile <profile-name> - Verify the profile exists:
aws configure list-profiles - Check AWS credentials are valid
Solution: This is normal when the infrastructure is already up-to-date. No action needed.
Solution:
- Ensure you're running from the AwsTemplates folder in your service solution
- Verify template files exist in the Templates directory
- Check template paths in systemconfig.yaml
Solution:
- Verify your AWS profile has necessary permissions
- Check IAM policies attached to your user/role
- Ensure you're using the correct AWS region
- Always deploy system resources first - Other resources depend on system infrastructure
- Use consistent naming - Follow the SystemKey and TenantKey naming conventions
- Test in non-production first - Use separate SystemSuffix for different environments
- Monitor deployments - Check AWS CloudFormation console for detailed status
- Keep configurations in version control - Track changes to systemconfig.yaml
- Use verbose mode for troubleshooting - Helps identify where issues occur
- Public/: User-facing cmdlets (Deploy-, Get-, Set-*)
- Private/: Internal helper functions
- Templates/: SAM/CloudFormation templates (not included in module)
- en-US/: Help documentation and localization
- Report issues: GitHub Issues
- Documentation: Check CLAUDE.md for detailed development guidelines
- Error handling: See ErrorHandling.md for error handling patterns
This module is licensed under the MIT License. See LICENSE file for details.