From 24b88e8ec1b02c48f49b5eb04d7ccda8569cde1e Mon Sep 17 00:00:00 2001 From: Dave Hollerbach Date: Thu, 25 May 2023 15:09:06 -0600 Subject: [PATCH] feat: Added outputs for s3 bucket lifecycle rules and policy (#234) --- README.md | 2 ++ examples/complete/README.md | 2 ++ examples/complete/outputs.tf | 10 ++++++++++ examples/notification/main.tf | 1 - examples/object/main.tf | 1 - examples/s3-inventory/main.tf | 1 - examples/s3-replication/main.tf | 2 -- outputs.tf | 10 ++++++++++ 8 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 58cf259a..ece1a853 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,8 @@ No modules. | [s3\_bucket\_bucket\_regional\_domain\_name](#output\_s3\_bucket\_bucket\_regional\_domain\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. | | [s3\_bucket\_hosted\_zone\_id](#output\_s3\_bucket\_hosted\_zone\_id) | The Route 53 Hosted Zone ID for this bucket's region. | | [s3\_bucket\_id](#output\_s3\_bucket\_id) | The name of the bucket. | +| [s3\_bucket\_lifecycle\_configuration\_rules](#output\_s3\_bucket\_lifecycle\_configuration\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. | +| [s3\_bucket\_policy](#output\_s3\_bucket\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. | | [s3\_bucket\_region](#output\_s3\_bucket\_region) | The AWS region this bucket resides in. | | [s3\_bucket\_website\_domain](#output\_s3\_bucket\_website\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. | | [s3\_bucket\_website\_endpoint](#output\_s3\_bucket\_website\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. | diff --git a/examples/complete/README.md b/examples/complete/README.md index 70c46ab3..fc726b5a 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -73,6 +73,8 @@ No inputs. | [s3\_bucket\_bucket\_regional\_domain\_name](#output\_s3\_bucket\_bucket\_regional\_domain\_name) | The bucket region-specific domain name. The bucket domain name including the region name, please refer here for format. Note: The AWS CloudFront allows specifying S3 region-specific endpoint when creating S3 origin, it will prevent redirect issues from CloudFront to S3 Origin URL. | | [s3\_bucket\_hosted\_zone\_id](#output\_s3\_bucket\_hosted\_zone\_id) | The Route 53 Hosted Zone ID for this bucket's region. | | [s3\_bucket\_id](#output\_s3\_bucket\_id) | The name of the bucket. | +| [s3\_bucket\_lifecycle\_configuration\_rules](#output\_s3\_bucket\_lifecycle\_configuration\_rules) | The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string. | +| [s3\_bucket\_policy](#output\_s3\_bucket\_policy) | The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string. | | [s3\_bucket\_region](#output\_s3\_bucket\_region) | The AWS region this bucket resides in. | | [s3\_bucket\_website\_domain](#output\_s3\_bucket\_website\_domain) | The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records. | | [s3\_bucket\_website\_endpoint](#output\_s3\_bucket\_website\_endpoint) | The website endpoint, if the bucket is configured with a website. If not, this will be an empty string. | diff --git a/examples/complete/outputs.tf b/examples/complete/outputs.tf index 3c66187e..eddd5416 100644 --- a/examples/complete/outputs.tf +++ b/examples/complete/outputs.tf @@ -23,6 +23,16 @@ output "s3_bucket_hosted_zone_id" { value = module.s3_bucket.s3_bucket_hosted_zone_id } +output "s3_bucket_lifecycle_configuration_rules" { + description = "The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string." + value = module.s3_bucket.s3_bucket_lifecycle_configuration_rules +} + +output "s3_bucket_policy" { + description = "The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string." + value = module.s3_bucket.s3_bucket_policy +} + output "s3_bucket_region" { description = "The AWS region this bucket resides in." value = module.s3_bucket.s3_bucket_region diff --git a/examples/notification/main.tf b/examples/notification/main.tf index a208ae59..e2b2ff10 100644 --- a/examples/notification/main.tf +++ b/examples/notification/main.tf @@ -2,7 +2,6 @@ provider "aws" { region = local.region # Make it faster by skipping something - skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true diff --git a/examples/object/main.tf b/examples/object/main.tf index 1aca0f0e..979eca48 100644 --- a/examples/object/main.tf +++ b/examples/object/main.tf @@ -2,7 +2,6 @@ provider "aws" { region = local.region # Make it faster by skipping something - skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true diff --git a/examples/s3-inventory/main.tf b/examples/s3-inventory/main.tf index 47504765..3ae3eb78 100644 --- a/examples/s3-inventory/main.tf +++ b/examples/s3-inventory/main.tf @@ -7,7 +7,6 @@ provider "aws" { region = local.region # Make it faster by skipping something - skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true diff --git a/examples/s3-replication/main.tf b/examples/s3-replication/main.tf index 98897334..73179c80 100644 --- a/examples/s3-replication/main.tf +++ b/examples/s3-replication/main.tf @@ -2,7 +2,6 @@ provider "aws" { region = local.origin_region # Make it faster by skipping something - skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true @@ -15,7 +14,6 @@ provider "aws" { alias = "replica" # Make it faster by skipping something - skip_get_ec2_platforms = true skip_metadata_api_check = true skip_region_validation = true skip_credentials_validation = true diff --git a/outputs.tf b/outputs.tf index 518cf437..e46a9a2f 100644 --- a/outputs.tf +++ b/outputs.tf @@ -23,6 +23,16 @@ output "s3_bucket_hosted_zone_id" { value = try(aws_s3_bucket.this[0].hosted_zone_id, "") } +output "s3_bucket_lifecycle_configuration_rules" { + description = "The lifecycle rules of the bucket, if the bucket is configured with lifecycle rules. If not, this will be an empty string." + value = try(aws_s3_bucket_lifecycle_configuration.this[0].rule, "") +} + +output "s3_bucket_policy" { + description = "The policy of the bucket, if the bucket is configured with a policy. If not, this will be an empty string." + value = try(aws_s3_bucket_policy.this[0].policy, "") +} + output "s3_bucket_region" { description = "The AWS region this bucket resides in." value = try(aws_s3_bucket.this[0].region, "")