This ia a Terraform module to provision a secure Terraform S3 bucket. It also has a provisioning test included in its' Github actions so you can be sure each labelled version works.
It's 100% Open Source and licensed under the APACHE2.
Include this repository as a module in your existing Terraform code:
module "s3" {
source = "JamesWoolfenden/s3/aws"
version = "0.4.0"
s3_bucket_force_destroy = var.s3_bucket_force_destroy
s3_bucket_name = var.s3_bucket_name
s3_bucket_policy = data.aws_iam_policy_document.s3_policy.json
}
This creates an S3 bucket with policy and applies the default tags scheme.
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
Name | Type |
---|---|
aws_s3_bucket.bucket | resource |
aws_s3_bucket_acl.bucket | resource |
aws_s3_bucket_logging.bucket | resource |
aws_s3_bucket_policy.bucket | resource |
aws_s3_bucket_public_access_block.bucket | resource |
aws_s3_bucket_replication_configuration.bucket | resource |
aws_s3_bucket_server_side_encryption_configuration.bucket | resource |
aws_s3_bucket_versioning.bucket | resource |
aws_caller_identity.current | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
access_block | Settings for the public access block | map(any) |
{ |
no |
kms_key_id | n/a | string |
n/a | yes |
logging | n/a | list(string) |
[] |
no |
mfa_delete | To enable/disable MFA delete | string |
"Disable" |
no |
role | Replication configuration | list |
[] |
no |
s3_bucket_acl | Acl on the bucket | string |
"private" |
no |
s3_bucket_force_destroy | String Boolean to set bucket to be undeletable (well more difficult anyway) | string |
n/a | yes |
s3_bucket_name | The name of the bucket | string |
n/a | yes |
s3_bucket_policy | The IAM policy for the bucket | string |
n/a | yes |
sse_algorithm | The type of encryption algorithm to use | string |
"aws:kms" |
no |
versioning | To enable/disable Versioning | string |
"Enabled" |
no |
Name | Description |
---|---|
account_id | The AWS account number in use |
bucket | The bucket |
This is the policy required to build this project:
The Terraform resource required is:
resource "aws_iam_policy" "terraform_pike" {
name_prefix = "terraform_pike"
path = "/"
description = "Pike Autogenerated policy from IAC"
policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:GetAccelerateConfiguration",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetBucketLogging",
"s3:GetBucketObjectLockConfiguration",
"s3:GetBucketPolicy",
"s3:GetBucketPublicAccessBlock",
"s3:GetBucketRequestPayment",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetBucketWebsite",
"s3:GetEncryptionConfiguration",
"s3:GetLifecycleConfiguration",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetReplicationConfiguration",
"s3:ListAllMyBuckets",
"s3:ListBucket",
"s3:PutBucketAcl",
"s3:PutBucketLogging",
"s3:PutBucketPolicy",
"s3:PutBucketPublicAccessBlock",
"s3:PutBucketVersioning",
"s3:PutEncryptionConfiguration"
],
"Resource": "*"
}
]
})
}
Check out these related projects.
- terraform-aws-statebucket - Terraform s3 state buckets
Got a question?
File a GitHub issue.
Please use the issue tracker to report any bugs or file feature requests.
Copyright © 2019-2022 James Woolfenden
See LICENSE for full details.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.