-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OPS-6304 Add basic configuration (#1)
* OPS-6304 Add basic configuration * OPS-6304 Fix dynamic blocks
- Loading branch information
Showing
10 changed files
with
309 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "aws_bedrock_foundation_model" "this" { | ||
model_id = var.foundation_model_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Example | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.73 | | ||
|
||
## Providers | ||
|
||
No providers. | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_model"></a> [model](#module\_model) | ../../ | n/a | | ||
|
||
## Resources | ||
|
||
No resources. | ||
|
||
## Inputs | ||
|
||
No inputs. | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_custom_model_arn"></a> [custom\_model\_arn](#output\_custom\_model\_arn) | The ARN of the output model. | | ||
| <a name="output_job_arn"></a> [job\_arn](#output\_job\_arn) | The ARN of the customization job. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module "model" { | ||
source = "../../" | ||
|
||
name = "titan" | ||
job_name = "titan-job-1" | ||
foundation_model_id = "amazon.titan-text-express-v1" | ||
model_role_arn = "arn:aws:iam::123456789101:role/TitanModelRole" | ||
|
||
model_hyperparameters = { | ||
"epochCount" = "1" | ||
"batchSize" = "1" | ||
"learningRate" = "0.005" | ||
"learningRateWarmupSteps" = "0" | ||
} | ||
|
||
output_data_s3_uri = "s3://titan-output-data/data/" | ||
training_data_s3_uri = "s3://titan-training-data/data/train.jsonl" | ||
} | ||
|
||
output "custom_model_arn" { | ||
description = "The ARN of the output model." | ||
value = module.model.custom_model_arn | ||
} | ||
|
||
output "job_arn" { | ||
description = "The ARN of the customization job." | ||
value = module.model.job_arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_version = ">= 1.3" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.73" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
resource "aws_bedrock_custom_model" "this" { | ||
custom_model_name = var.name | ||
job_name = var.job_name | ||
|
||
base_model_identifier = data.aws_bedrock_foundation_model.this.model_arn | ||
custom_model_kms_key_id = var.model_kms_key_id | ||
customization_type = var.model_customization_type | ||
hyperparameters = var.model_hyperparameters | ||
role_arn = var.model_role_arn | ||
|
||
output_data_config { | ||
s3_uri = var.output_data_s3_uri | ||
} | ||
|
||
training_data_config { | ||
s3_uri = var.training_data_s3_uri | ||
} | ||
|
||
dynamic "validation_data_config" { | ||
for_each = var.validation_data_s3_uri != null ? ["this"] : [] | ||
content { | ||
validator { | ||
s3_uri = var.validation_data_s3_uri | ||
} | ||
} | ||
} | ||
|
||
dynamic "vpc_config" { | ||
for_each = var.vpc_config != null ? ["this"] : [] | ||
content { | ||
security_group_ids = var.vpc_config["security_group_ids"] | ||
subnet_ids = var.vpc_config["subnet_ids"] | ||
} | ||
} | ||
|
||
tags = var.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "custom_model_arn" { | ||
description = "The ARN of the output model." | ||
value = aws_bedrock_custom_model.this.custom_model_arn | ||
} | ||
|
||
output "job_arn" { | ||
description = "The ARN of the customization job." | ||
value = aws_bedrock_custom_model.this.job_arn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
variable "name" { | ||
description = "Name for the custom model." | ||
type = string | ||
} | ||
|
||
variable "job_name" { | ||
description = "A name for the customization job." | ||
type = string | ||
} | ||
|
||
variable "foundation_model_id" { | ||
description = "Model identifier." | ||
type = string | ||
default = "amazon.titan-text-express-v1" | ||
} | ||
|
||
variable "model_kms_key_id" { | ||
description = "The custom model is encrypted at rest using this key. Specify the key ARN." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "model_customization_type" { | ||
description = "The customization type. Valid values: `FINE_TUNING`, `CONTINUED_PRE_TRAINING`." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "model_hyperparameters" { | ||
description = "Parameters related to tuning the model." | ||
type = map(string) | ||
default = {} | ||
} | ||
|
||
variable "model_role_arn" { | ||
description = "The Amazon Resource Name (ARN) of an IAM role that Bedrock can assume to perform tasks on your behalf." | ||
type = string | ||
} | ||
|
||
variable "output_data_s3_uri" { | ||
description = "The S3 URI where the output data is stored." | ||
type = string | ||
} | ||
|
||
variable "training_data_s3_uri" { | ||
description = "The S3 URI where the training data is stored." | ||
type = string | ||
} | ||
|
||
variable "validation_data_s3_uri" { | ||
description = "The S3 URI where the validation data is stored." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "vpc_config" { | ||
description = "Configuration parameters for the private Virtual Private Cloud (VPC) that contains the resources you are using for this job." | ||
type = object({ | ||
security_group_ids = list(string) | ||
subnet_ids = list(string) | ||
}) | ||
default = null | ||
} | ||
|
||
variable "tags" { | ||
description = "A map of tags to assign to the customization job and custom model." | ||
type = map(string) | ||
default = {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
terraform { | ||
required_version = "~> 1.3" | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.73" | ||
} | ||
} | ||
} |