Skip to content

Commit

Permalink
fix: workshop (#51)
Browse files Browse the repository at this point in the history
* fix: workshop SCP for listing bedrock models
* fix: too few X's for temporary directory
* fix: allow a variable to set the container platform
* feat: bump versions for modules

---------

Signed-off-by: Scott Schreckengaust <[email protected]>
  • Loading branch information
scottschreckengaust authored Dec 11, 2024
1 parent 4b52e73 commit 1d591ae
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 32 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

<!-- markdownlint-disable MD024 -->
## [1.0.1]

### Added

- Bedrock Guardrails sample

<!-- markdownlint-disable MD024 -->
## [1.0.0]

### Added
Expand Down
28 changes: 14 additions & 14 deletions samples/bedrock-agent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,26 +165,26 @@ Do not forget to delete the resources to avoid unexpected charges.
1. First make sure to remove all data from the Amazon Simple Storage Service (Amazon S3) Bucket.
```shell
aws s3 rb <DocBucket> --force
```
```shell
aws s3 rb <DocBucket> --force
```
2. Next, set the data source to retain to allow Terraform to destroy all the resources.
- open the console to the Bedrock Knowledge base
- click the name of the knowledge base and verify the page shows the knowlege base id as output above <KBID>
- click the data source and verify the data source id is the <DataSourceID> as above
- click the edit button and expand "Advanced settings"
- Change the data deletion policy from "Delete" to "Retain"
- Click the submit button
- open the console to the Bedrock Knowledge base
- click the name of the knowledge base and verify the page shows the knowlege base id as output above <KBID>
- click the data source and verify the data source id is the <DataSourceID> as above
- click the edit button and expand "Advanced settings"
- Change the data deletion policy from "Delete" to "Retain"
- Click the submit button
3. Last remove all the resources.
```shell
$ terraform destroy
```
```shell
terraform destroy
```
Delete all the associated logs created by the different services in Amazon CloudWatch logs
# Content Security Legal Disclaimer
## Content Security Legal Disclaimer
The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.
3 changes: 2 additions & 1 deletion samples/bedrock-agent/data.tf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
data "aws_bedrock_foundation_models" "test" {}
# https://docs.aws.amazon.com/bedrock/latest/userguide/models-supported.html
# data "aws_bedrock_foundation_models" "test" {}
3 changes: 2 additions & 1 deletion samples/bedrock-agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ provider "opensearch" {
module "bedrock" {
#checkov:skip=CKV_TF_1:Terraform registry has no ability to use a commit hash
source = "aws-ia/bedrock/aws"
version = "0.0.4"
version = "0.0.5"
create_kb = true
create_default_kb = true
create_agent = true
Expand All @@ -26,6 +26,7 @@ module "bedrock" {
action_group_state = "ENABLED"
lambda_action_group_executor = module.lambda.lambda_function_arn
api_schema_payload = file("${path.module}/lambda/action-group.yaml")
kb_embedding_model_arn = "arn:aws:bedrock:${var.region}::foundation-model/amazon.titan-embed-text-v1"
}

module "lambda" {
Expand Down
2 changes: 1 addition & 1 deletion samples/bedrock-agent/scripts/load-kb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BOOKS_LIST=("https://www.gutenberg.org/ebooks/84.txt.utf-8"
"https://www.gutenberg.org/ebooks/1513.txt.utf-8")

# make a temporary directory to download the books
BOOKS_DIR=$(mktemp -d -t "books.$$")
BOOKS_DIR=$(mktemp -d -t "books.$$.XXXXXX")

pushd "$BOOKS_DIR"

Expand Down
8 changes: 4 additions & 4 deletions samples/bedrock-agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ variable "foundation_model" {
description = "The foundation model to use for the agent"
nullable = false
default = "anthropic.claude-3-haiku-20240307-v1:0"
validation {
condition = contains(data.aws_bedrock_foundation_models.test.model_summaries[*].model_id, var.foundation_model)
error_message = "The foundational model is not found"
}
# validation {
# condition = contains(data.aws_bedrock_foundation_models.test.model_summaries[*].model_id, var.foundation_model)
# error_message = "The foundational model is not found"
# }
}
2 changes: 1 addition & 1 deletion samples/bedrock-guardrails/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This example shows how to deploy a basic Bedrock agent with guardrails, leaving
## Overview

The AWS Terraform [bedrock](https://registry.terraform.io/modules/aws-ia/bedrock/aws/latest) module
abstracts the complexity of orchestrating AWS services like for Bedrock's guardrails. This
abstracts the complexity of orchestrating AWS services like for Bedrock's guardrails.

## Folder Structure

Expand Down
2 changes: 1 addition & 1 deletion samples/bedrock-guardrails/data.tf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
data "aws_bedrock_foundation_models" "test" {}
# data "aws_bedrock_foundation_models" "test" {}
4 changes: 2 additions & 2 deletions samples/bedrock-guardrails/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module "bedrock_withoutguardrail" {
#checkov:skip=CKV_TF_1:Terraform registry has no ability to use a commit hash
source = "aws-ia/bedrock/aws"
version = "0.0.4"
version = "0.0.5"
create_kb = false
create_default_kb = false
create_s3_data_source = false
Expand All @@ -17,7 +17,7 @@ module "bedrock_withoutguardrail" {
module "bedrock_withguardrail" {
#checkov:skip=CKV_TF_1:Terraform registry has no ability to use a commit hash
source = "aws-ia/bedrock/aws"
version = "0.0.4"
version = "0.0.5"
create_kb = false
create_default_kb = false
create_s3_data_source = false
Expand Down
8 changes: 4 additions & 4 deletions samples/bedrock-guardrails/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ variable "foundation_model" {
description = "The foundation model to use for the agent"
nullable = false
default = "anthropic.claude-3-haiku-20240307-v1:0"
validation {
condition = contains(data.aws_bedrock_foundation_models.test.model_summaries[*].model_id, var.foundation_model)
error_message = "The foundational model is not found"
}
# validation {
# condition = contains(data.aws_bedrock_foundation_models.test.model_summaries[*].model_id, var.foundation_model)
# error_message = "The foundational model is not found"
# }
}

# These are guardrail variables available within the Bedrock module and duplicated below for reference
Expand Down
5 changes: 3 additions & 2 deletions samples/document-explorer/terraform-config-backend/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module "genai_doc_ingestion" {
#checkov:skip=CKV_TF_1:Terraform registry has no ability to use a commit hash
source = "aws-ia/genai-document-ingestion-rag/aws"
version = "1.0.0"
version = "1.0.1"

solution_prefix = "doc-explorer"
container_platform = "linux/amd64"
container_platform = var.container_platform
force_destroy = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "container_platform" {
description = "The container platform"
type = string
default = "linux/amd64"
}

0 comments on commit 1d591ae

Please sign in to comment.