Skip to content

New serverless pattern - appconfig-ai-model-lambda-bedrock-typescript-cdk - #3561

Open
NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-appconfig-ai-model-lambda-bedrock-cdk
Open

NithinChandranR-AWS wants to merge 1 commit into
aws-samples:mainfrom
NithinChandranR-AWS:NithinChandranR-AWS-feature-appconfig-ai-model-lambda-bedrock-cdk

Conversation

@NithinChandranR-AWS

Copy link
Copy Markdown
Contributor

Description

Roll out Amazon Bedrock model settings with AWS AppConfig and AWS Lambda. The model ID, inference parameters and system prompt live in an AWS AppConfig AI model invocation configuration profile (AWS.AppConfig.AIModelInvocation); a Lambda function reads them through the AWS AppConfig Agent Lambda extension and maps them onto a Bedrock Converse call, and a CloudWatch alarm on the function's errors makes AWS AppConfig roll a bad model or prompt change back. Claim issue: #3560.

Key Innovation

First AWS AppConfig AI model invocation profile pattern in the repo, and the first AppConfig environment monitor with alarm-driven rollback. A model or prompt change becomes a gradual configuration deployment instead of a code deployment.

Architecture

AWS AppConfig (AI model invocation profile, linear strategy, environment monitor) -> AWS Lambda (AWS AppConfig Agent extension) -> Amazon Bedrock Converse; Amazon CloudWatch alarm on Lambda errors -> AWS AppConfig rollback

Deployed and Tested

Stack deploys in us-west-2 (~100 s) and eu-central-1, 14 CloudFormation resources. README Testing run as written in zsh and in bash 3.2 on fresh stacks:

  • Model switch: version 2 (Amazon Nova 2 Lite to Amazon Nova Micro) rolled out 50 percent, then 100 percent, baked and reached COMPLETE in 9 minutes; the answers show the new model.
  • Rollback: version 3 names a model the role may not invoke; errors started at 50 percent and the deployment ended ROLLED_BACK (ROLLBACK_COMPLETED CLOUDWATCH_ALARM) about 4 minutes after the start; the next call was served by version 2 again.
  • Schema validation: topP 2 is rejected at version creation with BadRequestException.
  • Cleanup deletes the extra versions and the stack; nothing is left.

Checklist

  • IAM least-privilege (two Amazon Nova inference profiles and their destination Region models only; AppConfig read scoped to the one configuration; monitor role trusts AWS AppConfig with aws:SourceAccount)
  • CDK synth passes (14 resources)
  • Deployed and tested end-to-end in us-west-2 and eu-central-1
  • validate.js passes, including the admin IAM check
  • No duplicate patterns in repo

The 12-digit numbers in lib/appconfig-ai-model-lambda-bedrock-stack.ts are the AWS-owned accounts that publish the AWS AppConfig Agent Lambda extension layers, copied from the extension versions page.

…Amazon Bedrock model settings with AWS AppConfig and AWS Lambda

- AWS AppConfig AI model invocation profile (L1, type AWS.AppConfig.AIModelInvocation) with version 1 deployed at stack creation
- Linear rollout strategy and an environment monitor on a CloudWatch alarm for the function's errors, for automatic rollback
- Monitor role trusts appconfig.amazonaws.com only with aws:SourceAccount set to the stack account
- AWS Lambda function (Node.js, arm64) reads the configuration through the AWS AppConfig Agent Lambda extension and maps it onto Bedrock Converse
- IAM allows two Amazon Nova models only (geo inference profile plus destination Region model ARNs)
- README Testing covers a model switch rollout, schema validation and an alarm-driven rollback

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants