Skip to content

Commit

Permalink
Add new example to sho wcreating an IAM policy for s3 buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Nemetz committed May 18, 2018
1 parent 3b1c2ec commit dfd9041
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/policy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Example: Managing multiple S3 buckets and create policy for them
14 changes: 14 additions & 0 deletions examples/policy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module "s3" {
source = "../../"
names = ["bucket-1", "bucket2", "bucket_3"]
environment = "${var.environment}"
organization = "${var.organization}"
}

data "aws_iam_policy_document" "s3" {
statement {
actions = ["s3:*"]
effect = "Allow"
resources = ["${formatlist("%s/*", module.s3.arns)}"]
}
}
34 changes: 34 additions & 0 deletions examples/policy/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
output "arns" {
description = "List of AWS S3 Bucket ARNs"
value = "${module.s3.arns}"
}

output "domain_names" {
description = "List of AWS S3 Bucket Domain Names"
value = "${module.s3.domain_names}"
}

output "hosted_zone_ids" {
description = "List of AWS S3 Bucket Hosted Zone IDs"
value = "${module.s3.hosted_zone_ids}"
}

output "ids" {
description = "List of AWS S3 Bucket IDs"
value = "${module.s3.ids}"
}

output "names" {
description = "List of AWS S3 Bucket Names"
value = "${module.s3.names}"
}

output "regions" {
description = "List of AWS S3 Bucket Regions"
value = "${module.s3.regions}"
}

// Unique to this example
output "policy" {
value = "${data.aws_iam_policy_document.s3.json}"
}
3 changes: 3 additions & 0 deletions examples/policy/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = "${var.region}"
}
11 changes: 11 additions & 0 deletions examples/policy/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "environment" {
default = "dev"
}

variable "organization" {
default = "testorg"
}

variable "region" {
default = "us-west-2"
}

0 comments on commit dfd9041

Please sign in to comment.