From 4e71c2d7514e63b1c238f40da3074391d19149ca Mon Sep 17 00:00:00 2001 From: Ronny Panknin Date: Mon, 9 Dec 2024 09:48:11 +0100 Subject: [PATCH] OPS-6384 add module --- README.md | 80 +++++++++++++++++++++++++++++------- data.tf | 7 ++++ examples/simple/README.md | 41 ++++++++++++++++++ examples/simple/main.tf | 5 +++ examples/simple/outputs.tf | 4 ++ examples/simple/variables.tf | 28 +++++++++++++ examples/simple/versions.tf | 9 ++++ main.tf | 53 ++++++++++++++++++++++++ outputs.tf | 24 +++++++++++ variables.tf | 34 +++++++++++++++ 10 files changed, 271 insertions(+), 14 deletions(-) create mode 100644 data.tf create mode 100644 examples/simple/README.md create mode 100644 examples/simple/main.tf create mode 100644 examples/simple/outputs.tf create mode 100644 examples/simple/variables.tf create mode 100644 examples/simple/versions.tf create mode 100644 main.tf create mode 100644 outputs.tf create mode 100644 variables.tf diff --git a/README.md b/README.md index da64134..43c03cb 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ -# terraform-module-template -Template for Terraform modules - - +# terraform-aws-bedrock-model-invocation-logging + +Terraform module for Amazon Bedrock Agent resources + +[![lint](https://github.com/flaconi/terraform-aws-bedrock-model-invocation-logging/workflows/lint/badge.svg)](https://github.com/flaconi/terraform-aws-bedrock-model-invocation-logging/actions?query=workflow%3Alint) +[![test](https://github.com/flaconi/terraform-aws-bedrock-model-invocation-logging/workflows/test/badge.svg)](https://github.com/flaconi/terraform-aws-bedrock-model-invocation-logging/actions?query=workflow%3Atest) +[![Tag](https://img.shields.io/github/tag/flaconi/terraform-aws-bedrock-model-invocation-logging.svg)](https://github.com/flaconi/terraform-aws-bedrock-model-invocation-logging/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) @@ -18,7 +16,9 @@ For requirements regarding module structure: [style-guide-terraform.md](https:// ## Providers -No providers. +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | @@ -34,18 +34,70 @@ No providers. ## Required Inputs -No required inputs. +The following input variables are required: + +### [bucket](#input\_bucket) + +Description: The name of the S3 bucket to be created. + +Type: `string` ## Optional Inputs -No optional inputs. +The following input variables are optional (have default values): + +### [embedding\_data\_delivery\_enabled](#input\_embedding\_data\_delivery\_enabled) + +Description: Indicates whether embedding data delivery is enabled. + +Type: `bool` + +Default: `false` + +### [image\_data\_delivery\_enabled](#input\_image\_data\_delivery\_enabled) + +Description: Indicates whether image data delivery is enabled. + +Type: `bool` + +Default: `false` + +### [text\_data\_delivery\_enabled](#input\_text\_data\_delivery\_enabled) + +Description: Indicates whether text data delivery is enabled. + +Type: `bool` + +Default: `false` + +### [key\_prefix](#input\_key\_prefix) + +Description: The key prefix for logging configuration in S3. + +Type: `string` + +Default: `""` + +### [tags](#input\_tags) + +Description: A map of tags to assign to the customization job and custom model. + +Type: `map(string)` + +Default: `{}` ## Outputs -No outputs. +| Name | Description | +|------|-------------| +| [bucket\_arn](#output\_bucket\_arn) | The ARN of the created S3 bucket. | +| [bucket\_name](#output\_bucket\_name) | The name of the created S3 bucket. | +| [bucket\_policy\_id](#output\_bucket\_policy\_id) | The ID of the S3 bucket policy. | +| [key\_prefix](#output\_key\_prefix) | The key prefix used for the Bedrock logging configuration. | +| [logging\_bucket\_name](#output\_logging\_bucket\_name) | The name of the S3 bucket used for Bedrock model invocation logging. | @@ -53,4 +105,4 @@ No outputs. **[MIT License](LICENSE)** -Copyright (c) 2023 **[Flaconi GmbH](https://github.com/flaconi)** +Copyright (c) 2024 **[Flaconi GmbH](https://github.com/flaconi)** diff --git a/data.tf b/data.tf new file mode 100644 index 0000000..4fb6017 --- /dev/null +++ b/data.tf @@ -0,0 +1,7 @@ +data "aws_caller_identity" "this" {} + +data "aws_region" "this" {} + +data "aws_iam_session_context" "this" { + arn = data.aws_caller_identity.this.arn +} diff --git a/examples/simple/README.md b/examples/simple/README.md new file mode 100644 index 0000000..9bc7e3c --- /dev/null +++ b/examples/simple/README.md @@ -0,0 +1,41 @@ +# Example + + +## Requirements + +| Name | Version | +|------|---------| +| [terraform](#requirement\_terraform) | >= 1.3 | +| [aws](#requirement\_aws) | ~> 5.73 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [logging](#module\_logging) | ../../ | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [bucket](#input\_bucket) | The name of the S3 bucket to be created. | `string` | n/a | yes | +| [embedding\_data\_delivery\_enabled](#input\_embedding\_data\_delivery\_enabled) | Indicates whether embedding data delivery is enabled. | `bool` | `false` | no | +| [image\_data\_delivery\_enabled](#input\_image\_data\_delivery\_enabled) | Indicates whether image data delivery is enabled. | `bool` | `false` | no | +| [text\_data\_delivery\_enabled](#input\_text\_data\_delivery\_enabled) | Indicates whether text data delivery is enabled. | `bool` | `false` | no | +| [key\_prefix](#input\_key\_prefix) | The key prefix for logging configuration in S3. | `string` | `""` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [resources](#output\_resources) | Information about created resources | + + diff --git a/examples/simple/main.tf b/examples/simple/main.tf new file mode 100644 index 0000000..4b81aac --- /dev/null +++ b/examples/simple/main.tf @@ -0,0 +1,5 @@ +module "logging" { + source = "../../" + bucket = "my-example-bucket" + +} diff --git a/examples/simple/outputs.tf b/examples/simple/outputs.tf new file mode 100644 index 0000000..1b5b097 --- /dev/null +++ b/examples/simple/outputs.tf @@ -0,0 +1,4 @@ +output "resources" { + description = "Information about created resources" + value = module.logging +} diff --git a/examples/simple/variables.tf b/examples/simple/variables.tf new file mode 100644 index 0000000..61dbd65 --- /dev/null +++ b/examples/simple/variables.tf @@ -0,0 +1,28 @@ +variable "bucket" { + description = "The name of the S3 bucket to be created." + type = string +} + +variable "embedding_data_delivery_enabled" { + description = "Indicates whether embedding data delivery is enabled." + type = bool + default = false +} + +variable "image_data_delivery_enabled" { + description = "Indicates whether image data delivery is enabled." + type = bool + default = false +} + +variable "text_data_delivery_enabled" { + description = "Indicates whether text data delivery is enabled." + type = bool + default = false +} + +variable "key_prefix" { + description = "The key prefix for logging configuration in S3." + type = string + default = "" +} diff --git a/examples/simple/versions.tf b/examples/simple/versions.tf new file mode 100644 index 0000000..74007d0 --- /dev/null +++ b/examples/simple/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.3" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.73" + } + } +} diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..62c45ab --- /dev/null +++ b/main.tf @@ -0,0 +1,53 @@ +resource "aws_s3_bucket" "this" { + bucket = var.bucket + force_destroy = true + tags = var.tags +} + +resource "aws_s3_bucket_policy" "this" { + bucket = aws_s3_bucket.this.bucket + + policy = <