Skip to content

Commit

Permalink
TF Modules First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stacksimplify committed Mar 9, 2021
1 parent 6678b14 commit 351ceeb
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Licensed 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

http://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.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Terraform Module for Private Registry - AWS S3 Static website
- This module provisions AWS S3 buckets configured for static website hosting.
- This will be a demo S3 module

30 changes: 30 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Create S3 Bucket Resource
resource "aws_s3_bucket" "s3_bucket" {
bucket = var.bucket_name
acl = "public-read"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::${var.bucket_name}/*"
]
}
]
}
EOF
website {
index_document = "index.html"
error_document = "error.html"
}
tags = var.tags
force_destroy = true
}

21 changes: 21 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Output variable definitions

output "arn" {
description = "ARN of the S3 Bucket"
value = aws_s3_bucket.s3_bucket.arn
}

output "name" {
description = "Name (id) of the bucket"
value = aws_s3_bucket.s3_bucket.id
}

output "domain" {
description = "Domain Name of the bucket"
value = aws_s3_bucket.s3_bucket.website_domain
}

output "endpoint" {
description = "Endpoint Information of the bucket"
value = aws_s3_bucket.s3_bucket.website_endpoint
}
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Input variable definitions

variable "bucket_name" {
description = "Name of the S3 bucket. Must be Unique across AWS"
type = string
}

variable "tags" {
description = "Tages to set on the bucket"
type = map(string)
default = {}
}

0 comments on commit 351ceeb

Please sign in to comment.