File tree Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Expand file tree Collapse file tree 5 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Example: Managing multiple S3 buckets and create policy for them
Original file line number Diff line number Diff line change
1
+ module "s3" {
2
+ source = " ../../"
3
+ names = [" bucket-1" , " bucket2" , " bucket_3" ]
4
+ environment = " ${ var . environment } "
5
+ organization = " ${ var . organization } "
6
+ }
7
+
8
+ data "aws_iam_policy_document" "s3" {
9
+ statement {
10
+ actions = [" s3:*" ]
11
+ effect = " Allow"
12
+ resources = [" ${ formatlist (" %s/*" , module. s3 . arns )} " ]
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ output "arns" {
2
+ description = " List of AWS S3 Bucket ARNs"
3
+ value = " ${ module . s3 . arns } "
4
+ }
5
+
6
+ output "domain_names" {
7
+ description = " List of AWS S3 Bucket Domain Names"
8
+ value = " ${ module . s3 . domain_names } "
9
+ }
10
+
11
+ output "hosted_zone_ids" {
12
+ description = " List of AWS S3 Bucket Hosted Zone IDs"
13
+ value = " ${ module . s3 . hosted_zone_ids } "
14
+ }
15
+
16
+ output "ids" {
17
+ description = " List of AWS S3 Bucket IDs"
18
+ value = " ${ module . s3 . ids } "
19
+ }
20
+
21
+ output "names" {
22
+ description = " List of AWS S3 Bucket Names"
23
+ value = " ${ module . s3 . names } "
24
+ }
25
+
26
+ output "regions" {
27
+ description = " List of AWS S3 Bucket Regions"
28
+ value = " ${ module . s3 . regions } "
29
+ }
30
+
31
+ // Unique to this example
32
+ output "policy" {
33
+ value = " ${ data . aws_iam_policy_document . s3 . json } "
34
+ }
Original file line number Diff line number Diff line change
1
+ provider "aws" {
2
+ region = " ${ var . region } "
3
+ }
Original file line number Diff line number Diff line change
1
+ variable "environment" {
2
+ default = " dev"
3
+ }
4
+
5
+ variable "organization" {
6
+ default = " testorg"
7
+ }
8
+
9
+ variable "region" {
10
+ default = " us-west-2"
11
+ }
You can’t perform that action at this time.
0 commit comments