Comprehensive deployment instructions for LogGuardian CloudFormation templates.
- AWS CLI v2 with configured credentials
- Go 1.24+ for Lambda function builds
- AWS Config enabled in target regions
- S3 bucket for deployment artifacts
# 1. Build and package
make build package
# 2. Upload Lambda code
aws s3 cp dist/logguardian-compliance.zip s3://your-deployment-bucket/
# 3. Deploy simple template
aws cloudformation deploy \
--template-file templates/00-logguardian-simple.yaml \
--stack-name logguardian-sandbox \
--parameter-overrides \
Environment=sandbox \
DeploymentBucket=your-deployment-bucket \
CreateKMSKey=true \
CreateConfigRules=true \
--capabilities CAPABILITY_NAMED_IAM# Create S3 bucket for deployment artifacts
aws s3 mb s3://logguardian-deployment-${AWS_ACCOUNT_ID}-${AWS_REGION}
# Set bucket policy for CloudFormation access
aws s3api put-bucket-policy \
--bucket logguardian-deployment-${AWS_ACCOUNT_ID}-${AWS_REGION} \
--policy file://bucket-policy.json# Build the Go Lambda function
make build
# Create deployment package
make package
# Verify package contents
unzip -l dist/logguardian-compliance.zip# Validate all CloudFormation templates
make validate-templates
# Or validate manually
cd templates
./90-validate-templates.sh# Upload Lambda code
aws s3 cp dist/logguardian-compliance.zip s3://${DEPLOYMENT_BUCKET}/
# Upload CloudFormation templates (for modular deployment)
make upload-templatesChoose your deployment method:
# Simple deployment (single region, basic features)
aws cloudformation deploy \
--template-file templates/00-logguardian-simple.yaml \
--stack-name logguardian-sandbox \
--parameter-overrides Environment=sandbox DeploymentBucket=${DEPLOYMENT_BUCKET} \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1
# Full deployment (modular template)
aws cloudformation deploy \
--template-file templates/01-logguardian-main.yaml \
--stack-name logguardian-staging \
--parameter-overrides Environment=staging DeploymentBucket=${DEPLOYMENT_BUCKET} \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1# Deploy with parameter file
aws cloudformation deploy \
--template-file templates/01-logguardian-main.yaml \
--stack-name logguardian-sandbox \
--parameter-overrides file://templates/parameters/sandbox-parameters.json \
--capabilities CAPABILITY_NAMED_IAM \
--region ${AWS_REGION}# Set environment variables
export DEPLOYMENT_BUCKET="your-bucket"
export AWS_REGION="ca-central-1"
# Deploy to sandbox
make deploy-sandboxUse Case: Development, testing, small production environments
Features:
- Single CloudFormation template
- Basic monitoring
- Essential IAM permissions
- Config rules for compliance
Command:
aws cloudformation deploy \
--template-file templates/00-logguardian-simple.yaml \
--stack-name logguardian-sandbox \
--parameter-overrides Environment=sandbox DeploymentBucket=my-bucket \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1Use Case: Production environments requiring comprehensive monitoring
Features:
- Modular CloudFormation templates
- Comprehensive monitoring dashboard
- Advanced error handling
- Multi-region support
- Detailed alerting
Command:
aws cloudformation deploy \
--template-file templates/01-logguardian-main.yaml \
--stack-name logguardian-staging \
--parameter-overrides Environment=staging DeploymentBucket=my-bucket \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1Use Case: Enterprise environments with log groups across multiple regions
# Deploy to multiple regions using AWS CLI
for region in ca-central-1 ca-west-1 eu-central-1; do
aws cloudformation deploy \
--template-file templates/01-logguardian-main.yaml \
--stack-name logguardian-sandbox-$region \
--parameter-overrides Environment=sandbox DeploymentBucket=my-bucket-$region \
--capabilities CAPABILITY_NAMED_IAM \
--region $region
doneUse Case: Organization-wide deployment across multiple AWS accounts
# Create StackSet in organization master account
aws cloudformation create-stack-set \
--stack-set-name logguardian-org \
--template-body file://templates/01-logguardian-main.yaml \
--parameters file://templates/parameters/sandbox-parameters.json \
--capabilities CAPABILITY_NAMED_IAM \
--operation-preferences RegionConcurrencyType=PARALLEL,MaxConcurrentPercentage=100
# Deploy to organizational units
aws cloudformation create-stack-instances \
--stack-set-name logguardian-org \
--deployment-targets OrganizationalUnitIds=ou-root-12345678 \
--regions ca-central-1 ca-west-1aws cloudformation deploy \
--template-file templates/00-logguardian-simple.yaml \
--stack-name logguardian-dev \
--parameter-overrides \
Environment=dev \
DeploymentBucket=dev-deployment-bucket \
DefaultRetentionDays=30 \
ScheduleExpression="rate(1 hour)" \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1aws cloudformation deploy \
--template-file templates/00-logguardian-simple.yaml \
--stack-name logguardian-sandbox \
--parameter-overrides \
Environment=sandbox \
DeploymentBucket=sandbox-deployment-bucket \
DefaultRetentionDays=90 \
ScheduleExpression="rate(12 hours)" \
--capabilities CAPABILITY_NAMED_IAM \
--region ca-central-1# Check stack status
aws cloudformation describe-stacks \
--stack-name logguardian-sandbox \
--query 'Stacks[0].StackStatus'
# List stack outputs
aws cloudformation describe-stacks \
--stack-name logguardian-sandbox \
--query 'Stacks[0].Outputs'# Get invocation command from stack outputs
INVOCATION_CMD=$(aws cloudformation describe-stacks \
--stack-name logguardian-sandbox \
--query 'Stacks[0].Outputs[?OutputKey==`InvocationCommand`].OutputValue' \
--output text)
# Execute the command
eval $INVOCATION_CMD
# Check response
cat response.json# Check Config rule status
aws configservice describe-config-rules \
--config-rule-names cloudwatch-log-group-encrypted cw-loggroup-retention-period-check
# Check compliance status
aws configservice get-compliance-details-by-config-rule \
--config-rule-name cloudwatch-log-group-encrypted \
--compliance-types NON_COMPLIANT# Get dashboard URL from stack outputs
DASHBOARD_URL=$(aws cloudformation describe-stacks \
--stack-name logguardian-sandbox \
--query 'Stacks[0].Outputs[?OutputKey==`CloudWatchDashboardURL`].OutputValue' \
--output text)
echo "Dashboard URL: $DASHBOARD_URL"Create custom parameter files for your environment:
{
"DeploymentBucket": "my-company-logguardian-sandbox",
"Environment": "sandbox",
"KMSKeyAlias": "alias/my-company-logs",
"DefaultRetentionDays": 90,
"ScheduleExpression": "rate(6 hours)",
"SupportedRegions": "ca-central-1,ca-west-1,eu-west-1"
}Configure region-specific KMS keys:
# Set region-specific environment variables in Lambda
KMS_KEY_ALIAS_ca_central_1=alias/logs-ca-central-1
KMS_KEY_ALIAS_ca_west_1=alias/logs-ca-west-1
KMS_KEY_ALIAS_eu_west_1=alias/logs-eu-west-1# Validate specific template
aws cloudformation validate-template \
--template-body file://templates/logguardian-main.yaml
# Check template syntax
make validate-templates# Check bucket exists
aws s3 ls s3://${DEPLOYMENT_BUCKET}
# Check bucket region
aws s3api get-bucket-location --bucket ${DEPLOYMENT_BUCKET}# Verify Lambda package exists
aws s3 ls s3://${DEPLOYMENT_BUCKET}/logguardian-compliance.zip
# Re-upload if missing
make package
aws s3 cp dist/logguardian-compliance.zip s3://${DEPLOYMENT_BUCKET}/# Check Config status
aws configservice describe-configuration-recorders
# Enable Config if needed
aws configservice put-configuration-recorder \
--configuration-recorder name=default,roleARN=arn:aws:iam::ACCOUNT:role/config-role# Check Lambda logs
aws logs tail /aws/lambda/logguardian-compliance-sandbox --follow
# Check Lambda function configuration
aws lambda get-function --function-name logguardian-compliance-sandbox
# Test Lambda function
aws lambda invoke \
--function-name logguardian-compliance-sandbox \
--payload '{"type":"config-rule-evaluation","configRuleName":"cloudwatch-log-group-encrypted","region":"ca-central-1","batchSize":5}' \
test-output.json# Create change set for safe updates
aws cloudformation create-change-set \
--stack-name logguardian-prod \
--template-body file://templates/logguardian-main.yaml \
--change-set-name update-$(date +%Y%m%d) \
--capabilities CAPABILITY_NAMED_IAM
# Review changes before applying
aws cloudformation describe-change-set \
--change-set-name update-$(date +%Y%m%d) \
--stack-name logguardian-prod# Verify KMS key policy allows CloudWatch Logs
aws kms get-key-policy \
--key-id alias/cloudwatch-logs-compliance \
--policy-name default
# Test KMS key access
aws kms describe-key --key-id alias/cloudwatch-logs-compliance# Test Lambda execution role permissions
aws sts assume-role \
--role-arn arn:aws:iam::ACCOUNT:role/LogGuardian-LambdaExecutionRole-prod \
--role-session-name test-session
# Validate Config permissions
aws configservice describe-config-rules \
--profile logguardian-test# Check Lambda function health
aws lambda get-function --function-name logguardian-compliance-sandbox
# Check EventBridge rule status
aws events describe-rule --name logguardian-schedule-sandbox
# Check Config rule compliance
aws configservice get-compliance-summary-by-config-rule# Update Lambda code
make build package
aws s3 cp dist/logguardian-compliance.zip s3://${DEPLOYMENT_BUCKET}/
aws cloudformation update-stack \
--stack-name logguardian-prod \
--use-previous-template \
--capabilities CAPABILITY_NAMED_IAM
# Update templates
make validate-templates upload-templates
aws cloudformation update-stack \
--stack-name logguardian-sandbox \
--template-url https://${DEPLOYMENT_BUCKET}.s3.amazonaws.com/templates/01-logguardian-main.yaml \
--capabilities CAPABILITY_NAMED_IAM# Check Lambda costs
aws ce get-cost-and-usage \
--time-period Start=2024-01-01,End=2024-02-01 \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Optimize Lambda memory
aws lambda put-function-configuration \
--function-name logguardian-compliance-sandbox \
--memory-size 256# Delete stack when no longer needed
aws cloudformation delete-stack --stack-name logguardian-sandbox
# Clean up S3 artifacts
aws s3 rm s3://${DEPLOYMENT_BUCKET}/ --recursive
aws s3 rb s3://${DEPLOYMENT_BUCKET}For additional support:
- Documentation: GitHub Repository
- Issues: Open an issue on GitHub
- Community: Join discussions in GitHub Discussions
Next Steps: After successful deployment, review the monitoring guide and operational procedures.