AgentcoreMemory class

Manages an AWS Bedrock AgentCore Memory. Memory provides persistent storage for AI agent interactions, allowing agents to retain context across conversations and sessions.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const assumeRole = aws.iam.getPolicyDocument({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["bedrock-agentcore.amazonaws.com"],
        }],
        effect: "Allow",
        actions: ["sts:AssumeRole"],
    }],
});
const example = new aws.iam.Role("example", {
    name: "bedrock-agentcore-memory-role",
    assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
});
const exampleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("example", {
    role: example.name,
    policyArn: "arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy",
});
const exampleAgentcoreMemory = new aws.bedrock.AgentcoreMemory("example", {
    name: "example_memory",
    eventExpiryDuration: 30,
});
import pulumi
import pulumi_aws as aws

assume_role = aws.iam.get_policy_document(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["bedrock-agentcore.amazonaws.com"],
    }],
    "effect": "Allow",
    "actions": ["sts:AssumeRole"],
}])
example = aws.iam.Role("example",
    name="bedrock-agentcore-memory-role",
    assume_role_policy=assume_role.json)
example_role_policy_attachment = aws.iam.RolePolicyAttachment("example",
    role=example.name,
    policy_arn="arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy")
example_agentcore_memory = aws.bedrock.AgentcoreMemory("example",
    name="example_memory",
    event_expiry_duration=30)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "bedrock-agentcore.amazonaws.com",
                        },
                    },
                },
                Effect = "Allow",
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var example = new Aws.Iam.Role("example", new()
    {
        Name = "bedrock-agentcore-memory-role",
        AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var exampleRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("example", new()
    {
        Role = example.Name,
        PolicyArn = "arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy",
    });

    var exampleAgentcoreMemory = new Aws.Bedrock.AgentcoreMemory("example", new()
    {
        Name = "example_memory",
        EventExpiryDuration = 30,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"bedrock-agentcore.amazonaws.com",
							},
						},
					},
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		example, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
			Name:             pulumi.String("bedrock-agentcore-memory-role"),
			AssumeRolePolicy: pulumi.String(assumeRole.Json),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "example", &iam.RolePolicyAttachmentArgs{
			Role:      example.Name,
			PolicyArn: pulumi.String("arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy"),
		})
		if err != nil {
			return err
		}
		_, err = bedrock.NewAgentcoreMemory(ctx, "example", &bedrock.AgentcoreMemoryArgs{
			Name:                pulumi.String("example_memory"),
			EventExpiryDuration: pulumi.Int(30),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "assumeRole" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["bedrock-agentcore.amazonaws.com"]
    }
    effect  = "Allow"
    actions = ["sts:AssumeRole"]
  }
}

resource "aws_iam_role" "example" {
  name               = "bedrock-agentcore-memory-role"
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRole.json
}
resource "aws_iam_rolepolicyattachment" "example" {
  role       = aws_iam_role.example.name
  policy_arn = "arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy"
}
resource "aws_bedrock_agentcorememory" "example" {
  name                  = "example_memory"
  event_expiry_duration = 30
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import com.pulumi.aws.bedrock.AgentcoreMemory;
import com.pulumi.aws.bedrock.AgentcoreMemoryArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("bedrock-agentcore.amazonaws.com")
                    .build())
                .effect("Allow")
                .actions("sts:AssumeRole")
                .build())
            .build());

        var example = new Role("example", RoleArgs.builder()
            .name("bedrock-agentcore-memory-role")
            .assumeRolePolicy(assumeRole.json())
            .build());

        var exampleRolePolicyAttachment = new RolePolicyAttachment("exampleRolePolicyAttachment", RolePolicyAttachmentArgs.builder()
            .role(example.name())
            .policyArn("arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy")
            .build());

        var exampleAgentcoreMemory = new AgentcoreMemory("exampleAgentcoreMemory", AgentcoreMemoryArgs.builder()
            .name("example_memory")
            .eventExpiryDuration(30)
            .build());

    }
}
resources:
  example:
    type: aws:iam:Role
    properties:
      name: bedrock-agentcore-memory-role
      assumeRolePolicy: ${assumeRole.json}
  exampleRolePolicyAttachment:
    type: aws:iam:RolePolicyAttachment
    name: example
    properties:
      role: ${example.name}
      policyArn: arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy
  exampleAgentcoreMemory:
    type: aws:bedrock:AgentcoreMemory
    name: example
    properties:
      name: example_memory
      eventExpiryDuration: 30
variables:
  assumeRole:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - bedrock-agentcore.amazonaws.com
            effect: Allow
            actions:
              - sts:AssumeRole

Memory with Custom Encryption and Role

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.kms.Key("example", {description: "KMS key for Bedrock AgentCore Memory"});
const exampleAgentcoreMemory = new aws.bedrock.AgentcoreMemory("example", {
    name: "example_memory",
    description: "Memory for customer service agent",
    eventExpiryDuration: 60,
    encryptionKeyArn: example.arn,
    memoryExecutionRoleArn: exampleAwsIamRole.arn,
    clientToken: "unique-client-token",
});
import pulumi
import pulumi_aws as aws

example = aws.kms.Key("example", description="KMS key for Bedrock AgentCore Memory")
example_agentcore_memory = aws.bedrock.AgentcoreMemory("example",
    name="example_memory",
    description="Memory for customer service agent",
    event_expiry_duration=60,
    encryption_key_arn=example.arn,
    memory_execution_role_arn=example_aws_iam_role["arn"],
    client_token="unique-client-token")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Kms.Key("example", new()
    {
        Description = "KMS key for Bedrock AgentCore Memory",
    });

    var exampleAgentcoreMemory = new Aws.Bedrock.AgentcoreMemory("example", new()
    {
        Name = "example_memory",
        Description = "Memory for customer service agent",
        EventExpiryDuration = 60,
        EncryptionKeyArn = example.Arn,
        MemoryExecutionRoleArn = exampleAwsIamRole.Arn,
        ClientToken = "unique-client-token",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/bedrock"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/kms"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := kms.NewKey(ctx, "example", &kms.KeyArgs{
			Description: pulumi.String("KMS key for Bedrock AgentCore Memory"),
		})
		if err != nil {
			return err
		}
		_, err = bedrock.NewAgentcoreMemory(ctx, "example", &bedrock.AgentcoreMemoryArgs{
			Name:                   pulumi.String("example_memory"),
			Description:            pulumi.String("Memory for customer service agent"),
			EventExpiryDuration:    pulumi.Int(60),
			EncryptionKeyArn:       example.Arn,
			MemoryExecutionRoleArn: pulumi.Any(exampleAwsIamRole.Arn),
			ClientToken:            "unique-client-token",
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_kms_key" "example" {
  description = "KMS key for Bedrock AgentCore Memory"
}
resource "aws_bedrock_agentcorememory" "example" {
  name                      = "example_memory"
  description               = "Memory for customer service agent"
  event_expiry_duration     = 60
  encryption_key_arn        = aws_kms_key.example.arn
  memory_execution_role_arn = exampleAwsIamRole.arn
  client_token              = "unique-client-token"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.bedrock.AgentcoreMemory;
import com.pulumi.aws.bedrock.AgentcoreMemoryArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new Key("example", KeyArgs.builder()
            .description("KMS key for Bedrock AgentCore Memory")
            .build());

        var exampleAgentcoreMemory = new AgentcoreMemory("exampleAgentcoreMemory", AgentcoreMemoryArgs.builder()
            .name("example_memory")
            .description("Memory for customer service agent")
            .eventExpiryDuration(60)
            .encryptionKeyArn(example.arn())
            .memoryExecutionRoleArn(exampleAwsIamRole.arn())
            .clientToken("unique-client-token")
            .build());

    }
}
resources:
  example:
    type: aws:kms:Key
    properties:
      description: KMS key for Bedrock AgentCore Memory
  exampleAgentcoreMemory:
    type: aws:bedrock:AgentcoreMemory
    name: example
    properties:
      name: example_memory
      description: Memory for customer service agent
      eventExpiryDuration: 60
      encryptionKeyArn: ${example.arn}
      memoryExecutionRoleArn: ${exampleAwsIamRole.arn}
      clientToken: unique-client-token

Import

Identity Schema

Required

  • id (String) Memory ID.

Optional

  • accountId (String) Account ID where this resource is managed.
  • region (String) Region where this resource is managed.

Using pulumi import, import memories using id. For example:

$ pulumi import aws:bedrock/agentcoreMemory:AgentcoreMemory example example_memory-5xKsqQHSWW

Constructors

AgentcoreMemory(String name, {AgentcoreMemoryArgs? args, CustomResourceOptions? options})
Creates a new AgentcoreMemory. name The Pulumi resource name. args Arguments used to configure this AgentcoreMemory. The set of arguments for AgentcoreMemory. options Resource options controlling this resource's behavior.
AgentcoreMemory.reference(String urn)
Creates a typed reference to an existing AgentcoreMemory resource.

Properties

arn ↔ Output<String>
ARN of the Memory.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
description ↔ Output<String?>
Description of the memory.
latefinal
encryptionKeyArn ↔ Output<String?>
ARN of the KMS key used to encrypt the memory. If not provided, AWS managed encryption is used.
latefinal
eventExpiryDuration ↔ Output<int>
Number of days after which memory events expire. Must be a positive integer in the range of 7 to 365.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
indexedKeys ↔ Output<List<AgentcoreMemoryIndexedKey>?>
Metadata keys to index for filtering. Up to 10 entries. Additional keys can be added in place; removing or changing an existing key forces a new resource to be created, because previously indexed keys cannot be removed. See indexedKey Block below.
latefinal
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
memoryExecutionRoleArn ↔ Output<String?>
ARN of the IAM role that the memory service assumes to perform operations. Required when using custom memory strategies with model processing.
latefinal
name ↔ Output<String>
Name of the memory.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
streamDeliveryResources ↔ Output<AgentcoreMemoryStreamDeliveryResources?>
Configuration for streaming memory record data to external resources. See streamDeliveryResources Block below.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value map of resource tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
timeouts ↔ Output<AgentcoreMemoryTimeouts?>
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {AgentcoreMemoryState? state, CustomResourceOptions? options}) → AgentcoreMemory
Gets an existing AgentcoreMemory resource's state with the given name and id.