|
| 1 | +# Wrapper for module: `modules/account-public-access` |
| 2 | + |
| 3 | +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). |
| 4 | + |
| 5 | +You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. |
| 6 | + |
| 7 | +This wrapper does not implement any extra functionality. |
| 8 | + |
| 9 | +## Usage with Terragrunt |
| 10 | + |
| 11 | +`terragrunt.hcl`: |
| 12 | + |
| 13 | +```hcl |
| 14 | +terraform { |
| 15 | + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers/account-public-access" |
| 16 | + # Alternative source: |
| 17 | + # source = "git::[email protected]:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers/account-public-access?ref=master" |
| 18 | +} |
| 19 | +
|
| 20 | +inputs = { |
| 21 | + defaults = { # Default values |
| 22 | + create = true |
| 23 | + tags = { |
| 24 | + Terraform = "true" |
| 25 | + Environment = "dev" |
| 26 | + } |
| 27 | + } |
| 28 | +
|
| 29 | + items = { |
| 30 | + my-item = { |
| 31 | + # omitted... can be any argument supported by the module |
| 32 | + } |
| 33 | + my-second-item = { |
| 34 | + # omitted... can be any argument supported by the module |
| 35 | + } |
| 36 | + # omitted... |
| 37 | + } |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +## Usage with Terraform |
| 42 | + |
| 43 | +```hcl |
| 44 | +module "wrapper" { |
| 45 | + source = "terraform-aws-modules/s3-bucket/aws//wrappers/account-public-access" |
| 46 | +
|
| 47 | + defaults = { # Default values |
| 48 | + create = true |
| 49 | + tags = { |
| 50 | + Terraform = "true" |
| 51 | + Environment = "dev" |
| 52 | + } |
| 53 | + } |
| 54 | +
|
| 55 | + items = { |
| 56 | + my-item = { |
| 57 | + # omitted... can be any argument supported by the module |
| 58 | + } |
| 59 | + my-second-item = { |
| 60 | + # omitted... can be any argument supported by the module |
| 61 | + } |
| 62 | + # omitted... |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +## Example: Manage multiple S3 buckets in one Terragrunt layer |
| 68 | + |
| 69 | +`eu-west-1/s3-buckets/terragrunt.hcl`: |
| 70 | + |
| 71 | +```hcl |
| 72 | +terraform { |
| 73 | + source = "tfr:///terraform-aws-modules/s3-bucket/aws//wrappers" |
| 74 | + # Alternative source: |
| 75 | + # source = "git::[email protected]:terraform-aws-modules/terraform-aws-s3-bucket.git//wrappers?ref=master" |
| 76 | +} |
| 77 | +
|
| 78 | +inputs = { |
| 79 | + defaults = { |
| 80 | + force_destroy = true |
| 81 | +
|
| 82 | + attach_elb_log_delivery_policy = true |
| 83 | + attach_lb_log_delivery_policy = true |
| 84 | + attach_deny_insecure_transport_policy = true |
| 85 | + attach_require_latest_tls_policy = true |
| 86 | + } |
| 87 | +
|
| 88 | + items = { |
| 89 | + bucket1 = { |
| 90 | + bucket = "my-random-bucket-1" |
| 91 | + } |
| 92 | + bucket2 = { |
| 93 | + bucket = "my-random-bucket-2" |
| 94 | + tags = { |
| 95 | + Secure = "probably" |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
0 commit comments