Skip to content

Updating an Agent to a new version when executing on Bedrock Agentcore Runtime

1 minute read
Content level: Intermediate
0

Updating Bedrock Agentcore Runtime Agents with python code example

Getting started without the starter toolkit explains how to deploy an Agent on Bedrock Agentcore Runtime. It is also easy to update an Agent already running on Agentcore Runtime. The following code snippet shows how this can be achieve. .

import boto3

client = boto3.client('bedrock-agentcore-control', region_name='<AWS-REGION>')

response = client.update_agent_runtime(
    agentRuntimeId='<AGENTRUNTIME-ID>',
    agentRuntimeArtifact={
        'containerConfiguration': {
            'containerUri': '<AWS-ACCOUNT-ID>.dkr.ecr.<AWS-REGION>.amazonaws.com/<AGENT-NAME>:latest'
        }
    },
    networkConfiguration={"networkMode": "PUBLIC"},
    roleArn='arn:aws:iam::<ACCOUNT-ID>:role/<AGENT-ROLE>'
)

print(f"Agent Runtime created successfully!")
print(f"Agent Runtime ARN: {response['agentRuntimeArn']}")
print(f"Status: {response['status']}")

AWS-REGION is the region you have deployed.

AWS-ACCOUNT-ID is the AWS account where Agentcore is provisioned.

AGENT-NAME is the name of the agent given at creation time.

AGENTRUNTIME-ID is the agent runtimeID created at Agent creation. It is in the format of AGENT-NAME-suffix e.g. strands_agent-4JPYGNC7qT

AGENT-ROLE to run an agent in AgentCore Runtime you need an AWS Identity and Access Management execution role. The steps to create this are Permissions for AgentCore Runtime

AWS
EXPERT
published 10 months ago1K views