Skip to content

Commit

Permalink
v2.2.2: update docs to include sample policy
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Nov 4, 2021
1 parent c0b21a9 commit 232ec9f
Show file tree
Hide file tree
Showing 7 changed files with 235 additions and 10 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# aws-t26-s3
# aws-s3

Provides standard and t26 S3 bucket construction.

## Versions

Expand Down Expand Up @@ -34,3 +36,9 @@

* v2.2.0 -- 20210520
- add bucket_policy_document to be used for additional bucket policy merged with the default

* v2.2.1 -- 20210528
- fix key_id for encryption to be the arn of the key (despite the name)

* v2.2.2 -- 20211104
- update documenation to include sample policy and policy document
2 changes: 1 addition & 1 deletion common/version.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locals {
_module_version = "2.2.1"
_module_version = "2.2.2"
}
42 changes: 42 additions & 0 deletions examples/policy/sample-policy.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
data "aws_iam_policy_document" "policy" {
statement {
sid = "ListBuckets"
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
]
resources = ["*"]
}
statement {
sid = "S3WriteAccess"
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:PutObject*",
"s3:GetObject*",
"s3:GetObjectAcl",
"s3:DeleteObject"
]
resources = [
module.mybucket.s3_bucket_arn,
format("%v/*", mybucket.s3_bucket_arn),
]
}
statement {
sid = "S3AccessEncryptionKey"
effect = "Allow"
actions = [
"kms:ReEncrypt*",
"kms:GenerateDataKey",
"kms:Encrypt",
"kms:Decrypt"
]
resources = [module.mybucket.kms_key_id]
}
}

resource "aws_iam_policy" "policy" {
name = "mypolicy-s3-access"
description = "Policy for S3 access"
policy = data.aws_iam_policy_document.policy.json
}
47 changes: 45 additions & 2 deletions standard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,52 @@ module "mybucket" {
# kms_policy_document = data.aws_iam_policy_document.mypolicy.json
# bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
}
```

Sample policy for write access to the bucket and use of KMS key

```hcl
data "aws_iam_policy_document" "policy" {
statement {
sid = "ListBuckets"
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
]
resources = ["*"]
}
statement {
sid = "S3WriteAccess"
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:PutObject*",
"s3:GetObject*",
"s3:GetObjectAcl",
"s3:DeleteObject"
]
resources = [
module.mybucket.s3_bucket_arn,
format("%v/*", mybucket.s3_bucket_arn),
]
}
statement {
sid = "S3AccessEncryptionKey"
effect = "Allow"
actions = [
"kms:ReEncrypt*",
"kms:GenerateDataKey",
"kms:Encrypt",
"kms:Decrypt"
]
resources = [module.mybucket.kms_key_id]
}
}
data "aws_iam_policy_document" "mypolicy" {
statement { }
resource "aws_iam_policy" "policy" {
name = "mypolicy-s3-access"
description = "Policy for S3 access"
policy = data.aws_iam_policy_document.policy.json
}
```

Expand Down
50 changes: 48 additions & 2 deletions standard/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,52 @@
* # kms_policy_document = data.aws_iam_policy_document.mypolicy.json
* # bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
* }
* ```
*
* Sample policy for write access to the bucket and use of KMS key
*
* data "aws_iam_policy_document" "mypolicy" {
* statement { }
* ```hcl
* data "aws_iam_policy_document" "policy" {
* statement {
* sid = "ListBuckets"
* actions = [
* "s3:ListAllMyBuckets",
* "s3:GetBucketLocation"
* ]
* resources = ["*"]
* }
* statement {
* sid = "S3WriteAccess"
* effect = "Allow"
* actions = [
* "s3:ListBucket",
* "s3:PutObject*",
* "s3:GetObject*",
* "s3:GetObjectAcl",
* "s3:DeleteObject"
* ]
* resources = [
* module.mybucket.s3_bucket_arn,
* format("%v/*", mybucket.s3_bucket_arn),
* ]
* }
* statement {
* sid = "S3AccessEncryptionKey"
* effect = "Allow"
* actions = [
* "kms:ReEncrypt*",
* "kms:GenerateDataKey",
* "kms:Encrypt",
* "kms:Decrypt"
* ]
* resources = [module.mybucket.kms_key_id]
* }
* }
*
* resource "aws_iam_policy" "policy" {
* name = "mypolicy-s3-access"
* description = "Policy for S3 access"
* policy = data.aws_iam_policy_document.policy.json
* }
* ```
*
Expand All @@ -46,3 +89,6 @@ locals {
enable_title26 = var.enable_title26 ? true : false
versioning = false
}



47 changes: 45 additions & 2 deletions title26/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,52 @@ module "mybucket" {
# kms_policy_document = data.aws_iam_policy_document.mypolicy.json
# bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
}
```

Sample policy for write access to the bucket and use of KMS key

```hcl
data "aws_iam_policy_document" "policy" {
statement {
sid = "ListBuckets"
actions = [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
]
resources = ["*"]
}
statement {
sid = "S3WriteAccess"
effect = "Allow"
actions = [
"s3:ListBucket",
"s3:PutObject*",
"s3:GetObject*",
"s3:GetObjectAcl",
"s3:DeleteObject"
]
resources = [
module.mybucket.s3_bucket_arn,
format("%v/*", mybucket.s3_bucket_arn),
]
}
statement {
sid = "S3AccessEncryptionKey"
effect = "Allow"
actions = [
"kms:ReEncrypt*",
"kms:GenerateDataKey",
"kms:Encrypt",
"kms:Decrypt"
]
resources = [module.mybucket.kms_key_id]
}
}
data "aws_iam_policy_document" "mypolicy" {
statement { }
resource "aws_iam_policy" "policy" {
name = "mypolicy-s3-access"
description = "Policy for S3 access"
policy = data.aws_iam_policy_document.policy.json
}
```

Expand Down
47 changes: 45 additions & 2 deletions title26/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,52 @@
* # kms_policy_document = data.aws_iam_policy_document.mypolicy.json
* # bucket_policy_document = data.aws_iam_policy_document.mybucketpolicy.json
* }
* ```
*
* Sample policy for write access to the bucket and use of KMS key
*
* data "aws_iam_policy_document" "mypolicy" {
* statement { }
* ```hcl
* data "aws_iam_policy_document" "policy" {
* statement {
* sid = "ListBuckets"
* actions = [
* "s3:ListAllMyBuckets",
* "s3:GetBucketLocation"
* ]
* resources = ["*"]
* }
* statement {
* sid = "S3WriteAccess"
* effect = "Allow"
* actions = [
* "s3:ListBucket",
* "s3:PutObject*",
* "s3:GetObject*",
* "s3:GetObjectAcl",
* "s3:DeleteObject"
* ]
* resources = [
* module.mybucket.s3_bucket_arn,
* format("%v/*", mybucket.s3_bucket_arn),
* ]
* }
* statement {
* sid = "S3AccessEncryptionKey"
* effect = "Allow"
* actions = [
* "kms:ReEncrypt*",
* "kms:GenerateDataKey",
* "kms:Encrypt",
* "kms:Decrypt"
* ]
* resources = [module.mybucket.kms_key_id]
* }
* }
*
* resource "aws_iam_policy" "policy" {
* name = "mypolicy-s3-access"
* description = "Policy for S3 access"
* policy = data.aws_iam_policy_document.policy.json
* }
* ```
*
Expand Down

0 comments on commit 232ec9f

Please sign in to comment.