Template Overview
Thetemplate.yaml file defines the following resources:
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
PolicyStoreId | String | ID of your AVP policy store | Yes |
AnthropicApiKey | String (NoEcho) | API key for Anthropic Claude | Yes* |
*If you don’t plan to use the AI agent feature (
avp-agent.html), you can enter placeholder for the AnthropicApiKey. The main lab (index.html) does not require the Anthropic API.Resources Deployed
API Gateway
- Stage:
prod - CORS: Enabled for local development (allows requests from
localhost:8000) - Endpoints:
/check-access,/users,/agent
Lambda: Check Access
- Purpose: Calls AVP’s
IsAuthorizedAPI to check if a user can perform an action on a resource - Endpoint:
POST /check-access - Source:
lambda/app.py:lambda_handler
Lambda: Get Users
- Purpose: Returns hardcoded demo users and documents for the UI
- Endpoint:
GET /users - Source:
lambda/users.py:lambda_handler
Lambda: AI Agent
- Purpose: Secure proxy to Anthropic API — AI agent that queries AVP using natural language
- Endpoint:
POST /agent - Source:
lambda/agent.py:lambda_handler - Timeout: 60 seconds (longer than other functions to handle AI processing)
Outputs
After deployment, SAM outputs the following values:ApiUrl to configure the frontend in the next step.
Build and Deploy
Build the SAM application
- Validates the
template.yamlsyntax - Installs Python dependencies from
lambda/requirements.txt - Packages Lambda function code
- Creates a
.aws-sam/directory with build artifacts
Answer deployment prompts
SAM will ask a series of questions. Use the following answers:
| Prompt | Answer | Notes |
|---|---|---|
| Stack Name | avp-demo | CloudFormation stack name |
| AWS Region | us-west-2 | Or your preferred region where AVP is available |
| Parameter PolicyStoreId | PS1a2b3c4d5e6f7g8h9i0 | Paste your actual Policy Store ID |
| Parameter AnthropicApiKey | sk-ant-... or placeholder | Your Anthropic API key, or placeholder if not using AI agent |
| Confirm changes before deploy | y | Review changes before applying |
| Allow SAM CLI to create IAM roles | y | Required for Lambda execution roles |
| Disable rollback | n | Keep rollback enabled for safety |
| CheckAccessFunction has no authentication. Is this okay? | y | Intentional for demo purposes |
| GetUsersFunction has no authentication. Is this okay? | y | Intentional for demo purposes |
| AgentFunction has no authentication. Is this okay? | y | Intentional for demo purposes |
| Save arguments to configuration file | y | Saves settings to samconfig.toml for future deploys |
| SAM configuration file | (press ENTER) | Uses default samconfig.toml |
| SAM configuration environment | (press ENTER) | Uses default environment |
Review and confirm deployment
SAM will show a changeset preview:When prompted:Type
y and press ENTER to proceed.Wait for deployment to complete
SAM will create the CloudFormation stack and deploy all resources. This takes 2-3 minutes.You’ll see progress updates:
Verify Deployment
You can verify your deployment in several ways:AWS Console
-
CloudFormation: Check the stack status at https://console.aws.amazon.com/cloudformation
- Stack should show
CREATE_COMPLETEstatus - Verify all resources were created successfully
- Stack should show
-
Lambda: Check your functions at https://console.aws.amazon.com/lambda
- You should see three functions:
avp-check-access,avp-get-users,avp-agent
- You should see three functions:
-
API Gateway: Check your API at https://console.aws.amazon.com/apigateway
- You should see
avp-demo-apiwith theprodstage deployed
- You should see
CLI Commands
/users endpoint should return JSON with demo users and documents.
Redeploying Changes
If you make changes to the Lambda code ortemplate.yaml, redeploy with:
samconfig.toml from your initial deployment.
Troubleshooting
Build Failures
Error:Build Failed: PythonPipBuilder:ResolveDependencies
- Solution: Ensure Python 3.11+ is installed:
python3 --version - Check that
lambda/requirements.txtexists and dependencies are available
Deployment Failures
Error:Unable to upload artifact... Access Denied
- Solution: Ensure your AWS credentials have permissions to create S3 buckets, Lambda functions, and IAM roles
Policy Store ID is invalid
- Solution: Verify you copied the correct Policy Store ID from the AVP console. It should start with
PS.
Runtime Errors
Error:User: arn:aws:iam::... is not authorized to perform: verifiedpermissions:IsAuthorized
- Solution: The Lambda execution role should have been created automatically. Check the IAM role permissions in the AWS console.
Next Steps
With your backend deployed, configure the frontend to connect to your API:Configure Frontend
Update HTML files with your API Gateway URL