Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPS-6322 Add settings for S3-bucket #4

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Terraform module for Amazon Bedrock Agent resources
[![Tag](https://img.shields.io/github/tag/flaconi/terraform-aws-bedrock-agent.svg)](https://github.com/flaconi/terraform-aws-bedrock-agent/releases)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

For requirements regarding module structure: [style-guide-terraform.md](https://github.com/Flaconi/devops-docs/blob/master/doc/conventions/style-guide-terraform.md)

<!-- TFDOCS_HEADER_START -->

Expand All @@ -20,7 +19,7 @@ For requirements regarding module structure: [style-guide-terraform.md](https://
| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.73 |
| <a name="provider_opensearch"></a> [opensearch](#provider\_opensearch) | = 2.2.0 |
| <a name="provider_opensearch"></a> [opensearch](#provider\_opensearch) | ~> 2.2 |
| <a name="provider_time"></a> [time](#provider\_time) | ~> 0.12 |

<!-- TFDOCS_PROVIDER_END -->
Expand All @@ -32,7 +31,7 @@ For requirements regarding module structure: [style-guide-terraform.md](https://
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | ~> 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.73 |
| <a name="requirement_opensearch"></a> [opensearch](#requirement\_opensearch) | = 2.2.0 |
| <a name="requirement_opensearch"></a> [opensearch](#requirement\_opensearch) | ~> 2.2 |
| <a name="requirement_time"></a> [time](#requirement\_time) | ~> 0.12 |

<!-- TFDOCS_REQUIREMENTS_END -->
Expand Down Expand Up @@ -72,11 +71,19 @@ Description: Description for the knowledgebase.

Type: `string`

### <a name="input_s3_arn"></a> [s3\_arn](#input\_s3\_arn)
### <a name="input_s3_configuration"></a> [s3\_configuration](#input\_s3\_configuration)

Description: ARN of S3 bucket with data

Type: `string`
Type:

```hcl
object({
bucket_arn = string
bucket_owner_account_id = optional(string)
inclusion_prefixes = optional(set(string), [])
})
```

### <a name="input_oss_collection_name"></a> [oss\_collection\_name](#input\_oss\_collection\_name)

Expand Down
4 changes: 2 additions & 2 deletions data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ data "aws_iam_policy_document" "knowledgebase_permissions" {
statement {
actions = ["s3:ListBucket"]
resources = [
var.s3_arn
var.s3_configuration.bucket_arn
]
condition {
test = "StringEquals"
Expand All @@ -96,7 +96,7 @@ data "aws_iam_policy_document" "knowledgebase_permissions" {
statement {
actions = ["s3:GetObject"]
resources = [
"${var.s3_arn}/*"
"${var.s3_configuration.bucket_arn}/*"
]
condition {
test = "StringEquals"
Expand Down
3 changes: 1 addition & 2 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_s3_arn"></a> [s3\_arn](#input\_s3\_arn) | ARN of S3 bucket with data | `string` | n/a | yes |
| <a name="input_oss_collection_name"></a> [oss\_collection\_name](#input\_oss\_collection\_name) | Name of OpenSearch Serverless Collection. | `string` | n/a | yes |
| <a name="input_s3_configuration"></a> [s3\_configuration](#input\_s3\_configuration) | ARN of S3 bucket with data | <pre>object({<br> bucket_arn = string<br> bucket_owner_account_id = optional(string)<br> inclusion_prefixes = optional(set(string), [])<br> })</pre> | n/a | yes |
| <a name="input_oss_additional_roles_arns"></a> [oss\_additional\_roles\_arns](#input\_oss\_additional\_roles\_arns) | Additional ARNs of roles to access OpenSearch | `list(string)` | `[]` | no |

## Outputs
Expand Down
5 changes: 2 additions & 3 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ module "agent" {
knowledgebase_name = "my-knowledgebase"
knowledgebase_description = "Description for my knowledgebase"

s3_arn = var.s3_arn

oss_collection_name = var.oss_collection_name
s3_configuration = var.s3_configuration

oss_collection_name = "my-collection"
oss_additional_roles_arns = var.oss_additional_roles_arns

tags = {
Expand Down
13 changes: 6 additions & 7 deletions examples/simple/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
variable "s3_arn" {
variable "s3_configuration" {
description = "ARN of S3 bucket with data"
type = string
}

variable "oss_collection_name" {
description = "Name of OpenSearch Serverless Collection."
type = string
type = object({
bucket_arn = string
bucket_owner_account_id = optional(string)
inclusion_prefixes = optional(set(string), [])
})
}

variable "oss_additional_roles_arns" {
Expand Down
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ resource "aws_bedrockagent_data_source" "this" {
data_source_configuration {
type = "S3"
s3_configuration {
bucket_arn = var.s3_arn
bucket_arn = var.s3_configuration.bucket_arn
bucket_owner_account_id = var.s3_configuration.bucket_owner_account_id
inclusion_prefixes = var.s3_configuration.inclusion_prefixes
}
}
data_deletion_policy = var.knowledgebase_data_deletion_policy
Expand Down
8 changes: 6 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ variable "knowledgebase_data_deletion_policy" {
default = "RETAIN"
}

variable "s3_arn" {
variable "s3_configuration" {
description = "ARN of S3 bucket with data"
type = string
type = object({
bucket_arn = string
bucket_owner_account_id = optional(string)
inclusion_prefixes = optional(set(string), [])
})
}

variable "oss_collection_name" {
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
}
opensearch = {
source = "opensearch-project/opensearch"
version = "= 2.2.0"
version = "~> 2.2"
}
time = {
source = "hashicorp/time"
Expand Down