diff --git a/kms_key/README.md b/kms_key/README.md
index 6d323d1..473bae2 100644
--- a/kms_key/README.md
+++ b/kms_key/README.md
@@ -1,18 +1,48 @@
# About aws-s3 :: kms\_key
-This submodule allows you to create a KMS key for use with S3 buckets.
+This submodule allows you to create a KMS key for use with S3 buckets. You have to create the key first
+before trying to call it in a module. This is useful if you have a lot of buckets you wish to share the
+same key.
-# Usage
+## Usage: Create
```hcl
-module "mykey" {
- source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//kms_key"
- key_name = "mykeyname"
+module "simple-key" {
+ source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//kms_key"
+ key_name = "my-simple-key"
## optional
# kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
# kms_policy_document = data.aws_iam_policy_document.mypolicy.json
}
+
+output "simple-key-info" {
+ description = "KMS Key Info"
+ value = {
+ arn = module.simple-key.kms_key_arn
+ id = module.simple-key.kms_key_id
+ alias = module.simple-key.kms_key_alias
+ }
+}
+```
+
+## Usage: Reference
+```hcl
+module "my-bucket" {
+ source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard"
+
+ bucket_name = "my-normalbucket"
+ access_log_bucket = "my-logbucket"
+ kms_key_arn = module.simple-key.kms_key_arn
+}
+
+output "my-bucket-info" {
+ description = "S3 Standard Bucket Info"
+ value = {
+ arn = module.my-bucket.s3_bucket_arn
+ id = module.my-bucket.s3_bucket_id
+ }
+}
```
## Requirements
@@ -40,6 +70,7 @@ No modules.
| [aws_iam_policy_document.empty](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.key_admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.key_policy_combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
+| [aws_kms_key.incoming_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_key) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
## Inputs
@@ -59,6 +90,6 @@ No modules.
| Name | Description |
|------|-------------|
-| [kms\_key\_alias](#output\_kms\_key\_alias) | Created KMS Key Alias name |
-| [kms\_key\_arn](#output\_kms\_key\_arn) | Created KMS Key ARN |
-| [kms\_key\_id](#output\_kms\_key\_id) | Created KMS Key ID |
+| [kms\_key\_alias](#output\_kms\_key\_alias) | KMS Key Alias name. If a kms\_key\_arn passed in, this will be null. |
+| [kms\_key\_arn](#output\_kms\_key\_arn) | KMS Key ARN. This is the created key ARN or the key ARN of kms\_key\_arn |
+| [kms\_key\_id](#output\_kms\_key\_id) | KMS Key ID. This is the created key id or the key id of kms\_key\_arn |
diff --git a/kms_key/main.tf b/kms_key/main.tf
index 60dd993..067e762 100644
--- a/kms_key/main.tf
+++ b/kms_key/main.tf
@@ -1,19 +1,49 @@
/*
* # About aws-s3 :: kms_key
*
-* This submodule allows you to create a KMS key for use with S3 buckets.
+* This submodule allows you to create a KMS key for use with S3 buckets. You have to create the key first
+* before trying to call it in a module. This is useful if you have a lot of buckets you wish to share the
+* same key.
*
-* # Usage
+* ## Usage: Create
*
* ```hcl
-* module "mykey" {
-* source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//kms_key"
-* key_name = "mykeyname"
-*
+* module "simple-key" {
+* source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//kms_key"
+* key_name = "my-simple-key"
+*
* ## optional
* # kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
* # kms_policy_document = data.aws_iam_policy_document.mypolicy.json
* }
+*
+* output "simple-key-info" {
+* description = "KMS Key Info"
+* value = {
+* arn = module.simple-key.kms_key_arn
+* id = module.simple-key.kms_key_id
+* alias = module.simple-key.kms_key_alias
+* }
+* }
+* ```
+*
+* ## Usage: Reference
+* ```hcl
+* module "my-bucket" {
+* source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard"
+*
+* bucket_name = "my-normalbucket"
+* access_log_bucket = "my-logbucket"
+* kms_key_arn = module.simple-key.kms_key_arn
+* }
+*
+* output "my-bucket-info" {
+* description = "S3 Standard Bucket Info"
+* value = {
+* arn = module.my-bucket.s3_bucket_arn
+* id = module.my-bucket.s3_bucket_id
+* }
+* }
* ```
*/
@@ -22,3 +52,7 @@ locals {
name = var.key_name
enable_title26 = var.enable_title26 ? true : false
}
+
+
+
+
diff --git a/standard/README.md b/standard/README.md
index 0e39c1c..e6eb0f6 100644
--- a/standard/README.md
+++ b/standard/README.md
@@ -9,16 +9,24 @@ Other configurations such as versioning or data safegurad tagging (only on the b
# Usage
```hcl
-module "mybucket" {
+module "my-bucket" {
source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard"
- bucket_name = "mynormalbucket"
- access_log_bucket = "mylogbucket"
- kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
+ bucket_name = "my-normalbucket"
+ access_log_bucket = "my-logbucket"
+ # kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
## optional
- # kms_policy_document = data.aws_iam_policy_document.mypolicy.json
- # bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
+ # kms_policy_document = data.aws_iam_policy_document.my-policy.json
+ # bucket_policy_document = data.aws_iam_policy_document.my-bucketpolicy.json
+}
+
+output "my-bucket-info" {
+ description = "S3 Standard Bucket Info"
+ value = {
+ arn = module.my-bucket.s3_bucket_arn
+ id = module.my-bucket.s3_bucket_id
+ }
}
```
@@ -116,6 +124,7 @@ No modules.
| [aws_iam_policy_document.key_admin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.key_policy_combined](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
+| [aws_kms_key.incoming_key](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/kms_key) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
## Inputs
@@ -144,8 +153,8 @@ No modules.
| Name | Description |
|------|-------------|
-| [kms\_key\_alias](#output\_kms\_key\_alias) | Created KMS Key Alias name |
-| [kms\_key\_arn](#output\_kms\_key\_arn) | Created KMS Key ARN |
-| [kms\_key\_id](#output\_kms\_key\_id) | Created KMS Key ID |
+| [kms\_key\_alias](#output\_kms\_key\_alias) | KMS Key Alias name. If a kms\_key\_arn passed in, this will be null. |
+| [kms\_key\_arn](#output\_kms\_key\_arn) | KMS Key ARN. This is the created key ARN or the key ARN of kms\_key\_arn |
+| [kms\_key\_id](#output\_kms\_key\_id) | KMS Key ID. This is the created key id or the key id of kms\_key\_arn |
| [s3\_bucket\_arn](#output\_s3\_bucket\_arn) | Created S3 Bucket ARN |
| [s3\_bucket\_id](#output\_s3\_bucket\_id) | Created S3 Bucket ID |
diff --git a/standard/main.tf b/standard/main.tf
index ca24540..2de9d6c 100644
--- a/standard/main.tf
+++ b/standard/main.tf
@@ -10,16 +10,24 @@
* # Usage
*
* ```hcl
-* module "mybucket" {
+* module "my-bucket" {
* source = "git@github.e.it.census.gov:terraform-modules/aws-s3.git//standard"
-*
-* bucket_name = "mynormalbucket"
-* access_log_bucket = "mylogbucket"
-* kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
-*
+*
+* bucket_name = "my-normalbucket"
+* access_log_bucket = "my-logbucket"
+* # kms_admin_roles = [ aws_iam_role.cloud-admin.arn ]
+*
* ## optional
-* # kms_policy_document = data.aws_iam_policy_document.mypolicy.json
-* # bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
+* # kms_policy_document = data.aws_iam_policy_document.my-policy.json
+* # bucket_policy_document = data.aws_iam_policy_document.my-bucketpolicy.json
+* }
+*
+* output "my-bucket-info" {
+* description = "S3 Standard Bucket Info"
+* value = {
+* arn = module.my-bucket.s3_bucket_arn
+* id = module.my-bucket.s3_bucket_id
+* }
* }
* ```
*
@@ -89,3 +97,5 @@ locals {
enable_title26 = var.enable_title26 ? true : false
versioning = false
}
+
+