--- subcategory: "Bedrock AgentCore" layout: "aws" page_title: "AWS: aws_bedrockagentcore_memory" description: |- Manages an AWS Bedrock AgentCore Memory. --- # Resource: aws_bedrockagentcore_memory 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 ```terraform data "aws_iam_policy_document" "assume_role" { statement { effect = "Allow" actions = ["sts:AssumeRole"] principals { type = "Service" identifiers = ["bedrock-agentcore.amazonaws.com"] } } } resource "aws_iam_role" "example" { name = "bedrock-agentcore-memory-role" assume_role_policy = data.aws_iam_policy_document.assume_role.json } resource "aws_iam_role_policy_attachment" "example" { role = aws_iam_role.example.name policy_arn = "arn:aws:iam::aws:policy/AmazonBedrockAgentCoreMemoryBedrockModelInferenceExecutionRolePolicy" } resource "aws_bedrockagentcore_memory" "example" { name = "example_memory" event_expiry_duration = 30 } ``` ### Memory with Custom Encryption and Role ```terraform resource "aws_kms_key" "example" { description = "KMS key for Bedrock AgentCore Memory" } resource "aws_bedrockagentcore_memory" "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 = aws_iam_role.example.arn } ``` ## Argument Reference The following arguments are required: * `event_expiry_duration` - (Required) Number of days after which memory events expire. Must be a positive integer in the range of 7 to 365. * `name` - (Required) Name of the memory. The following arguments are optional: * `description` - (Optional) Description of the memory. * `encryption_key_arn` - (Optional) ARN of the KMS key used to encrypt the memory. If not provided, AWS managed encryption is used. * `indexed_key` - (Optional) 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 [`indexed_key` Block](#indexed_key-block) below. * `memory_execution_role_arn` - (Optional) ARN of the IAM role that the memory service assumes to perform operations. Required when using custom memory strategies with model processing. * `region` - (Optional) Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#aws-configuration-reference). * `stream_delivery_resources` - (Optional) Configuration for streaming memory record data to external resources. See [`stream_delivery_resources` Block](#stream_delivery_resources-block) below. * `tags` - (Optional) Key-value map of resource tags. If configured with a provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. ### `indexed_key` Block The `indexed_key` configuration block supports the following arguments: * `key` - (Required) Metadata key name to index. * `type` - (Required) Data type of the indexed key. Valid values are `STRING`, `STRINGLIST`, and `NUMBER`. ### `stream_delivery_resources` Block The `stream_delivery_resources` configuration block supports the following arguments: * `resource` - (Required) List of stream delivery resource configurations. See [`resource` Block](#resource-block) below. ### `resource` Block The `resource` configuration block supports the following arguments: * `kinesis` - (Required) Kinesis Data Stream configuration. See [`kinesis` Block](#kinesis-block) below. ### `kinesis` Block The `kinesis` configuration block supports the following arguments: * `content_configuration` - (Required) Content configurations for stream delivery. See [`content_configuration` Block](#content_configuration-block) below. * `data_stream_arn` - (Required) ARN of the Kinesis Data Stream. ### `content_configuration` Block The `content_configuration` configuration block supports the following arguments: * `level` - (Optional) Level of detail for streamed content. Valid values are `METADATA_ONLY` and `FULL_CONTENT`. Defaults to `METADATA_ONLY`. * `type` - (Required) Type of content to stream. Valid value is `MEMORY_RECORDS`. ## Attribute Reference This resource exports the following attributes in addition to the arguments above: * `arn` - ARN of the Memory. * `id` - Unique identifier of the Memory. * `tags_all` - Map of tags assigned to the resource, including those inherited from the provider [`default_tags` configuration block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags-configuration-block). ## Timeouts [Configuration options](https://developer.hashicorp.com/terraform/language/resources/syntax#operation-timeouts): * `create` - (Default `30m`) * `update` - (Default `30m`) * `delete` - (Default `30m`) ## Import In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `identity` attribute. For example: ```terraform import { to = aws_bedrockagentcore_memory.example identity = { id = "example_memory-5xKsqQHSWW" } } resource "aws_bedrockagentcore_memory" "example" { ### Configuration omitted for brevity ### } ``` ### Identity Schema #### Required * `id` (String) Memory ID. #### Optional * `account_id` (String) AWS Account where this resource is managed. * `region` (String) Region where this resource is managed. In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import memories using `id`. For example: ```terraform import { to = aws_bedrockagentcore_memory.example id = "example_memory-5xKsqQHSWW" } ``` Using `terraform import`, import memories using `id`. For example: ```console % terraform import aws_bedrockagentcore_memory.example example_memory-5xKsqQHSWW ```