From 1bfde837694b9bed34e831426888c0814897c30f Mon Sep 17 00:00:00 2001 From: badra001 Date: Tue, 1 Mar 2022 10:12:05 -0500 Subject: [PATCH] add example --- examples/outputs/s3_module_settings.md | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/outputs/s3_module_settings.md diff --git a/examples/outputs/s3_module_settings.md b/examples/outputs/s3_module_settings.md new file mode 100644 index 0000000..31f306e --- /dev/null +++ b/examples/outputs/s3_module_settings.md @@ -0,0 +1,28 @@ +# Outputs :: s3_module_settings + +Here is an exmaple of using the `s3_module_settings` outputs. Here, we have a lot of s3 modules. We pack all the outputs into +a list, and then use the `s3_module_settings` from each to translate from a requested bucket name to the ARN. This is because +we can call the module with a bucket naem of `mybucket` with some settings to add the account ID and region (compressed or not) +and this helps us match it up with what was really created. + +```hcl +locals { + module_outputs = [ + module.s3_cdl-asset, + module.s3_cdl-athena, + module.s3_cdl-code, + module.s3_cdl-datalake, + } + s3_bucket_name_arns = { for s3 in local.module_outputs : s3.s3_module_settings["bucket_name"] => s3.s3_module_settings["resulting_bucket_arn"] } +} +``` + +The resulting data is like + +```hcl +s3_bucket_name_arns = { + "adsd-edl-prod-cdl-asset" = "arn:aws-us-gov:s3:::v-s3-adsd-edl-prod-cdl-asseet-818199694861-ugw1" +. +. +} +```