Skip to content

Commit

Permalink
Merge pull request #20 from fillup/develop
Browse files Browse the repository at this point in the history
Release 6.0.1 - Remove deprecated hashicorp/template
  • Loading branch information
briskt committed Aug 9, 2023
2 parents 8efd94c + 05a3b03 commit d533244
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 6 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow installs the latest version of Terraform CLI. On pull request events, this workflow will run
# `terraform init`, `terraform fmt`, and `terraform plan`.
#
# Documentation for `hashicorp/setup-terraform` is located here: https://github.com/hashicorp/setup-terraform

name: 'Terraform'

on:
push:
pull_request:

permissions:
contents: read

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest

# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3

# Install the latest version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2

# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check -diff -recursive

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform -chdir=test init

# Validate the files, referring only to the configuration and not accessing any remote services
- name: Terraform Validate
run: terraform -chdir=test validate
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
.terraform/
10 changes: 4 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/*
* Create S3 bucket with appropriate permissions
*/
data "template_file" "bucket_policy" {
template = file("${path.module}/bucket-policy.json")

vars = {
locals {
bucket_policy = templatefile("${path.module}/bucket-policy.json", {
bucket_name = var.bucket_name
deployment_user_arn = var.deployment_user_arn
}
})
}

resource "aws_s3_bucket" "hugo" {
Expand All @@ -22,7 +20,7 @@ resource "aws_s3_bucket_acl" "hugo" {

resource "aws_s3_bucket_policy" "hugo" {
bucket = aws_s3_bucket.hugo.id
policy = data.template_file.bucket_policy.rendered
policy = local.bucket_policy
}

resource "aws_s3_bucket_website_configuration" "hugo" {
Expand Down
25 changes: 25 additions & 0 deletions test/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions test/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module "simple" {
source = "../"

aliases = ["www"]
bucket_name = "bucket"
cert_domain = "example.com"
deployment_user_arn = "arn:aws:iam::1234567890:user/deploy"
}

module "full" {
source = "../"

aliases = ["www"]
aws_region = "us-east-1"
bucket_name = "bucket"
cert_domain = "example.com"
cf_default_ttl = "86400"
cf_min_ttl = "0"
cf_max_ttl = "31536000"
cf_price_class = "PriceClass_All"
cors_allowed_headers = []
cors_allowed_methods = ["GET"]
cors_allowed_origins = ["https://s3.amazonaws.com"]
cors_expose_headers = []
cors_max_age_seconds = "3000"
custom_error_response = []
default_root_object = "index.html"
error_document = "404.html"
index_document = "index.html"
minimum_viewer_tls_version = "TLSv1.2_2019"
origin_path = "/public"
origin_ssl_protocols = ["TLSv1.2"]
routing_rules = "[]"
s3_origin_id = "hugo-s3-origin"
viewer_protocol_policy = "redirect-to-https"
deployment_user_arn = "arn:aws:iam::1234567890:user/deploy"
}
12 changes: 12 additions & 0 deletions test/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_version = ">= 1.0"
required_providers {
aws = {
source = "hashicorp/aws"
}
}
}

provider "aws" {
region = "us-east-1"
}

0 comments on commit d533244

Please sign in to comment.