Skip to content

Commit

Permalink
build: setup terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSnow committed Feb 29, 2024
1 parent f276472 commit 86c92fd
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 0 deletions.
1 change: 1 addition & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# and cannot reference projects located outside the workspace boundary.
projects:
- .
- terraform

# Configures the version control system to utilize within the workspace. A VCS
# is required for determining touched (added, modified, etc) files, calculating file hashes,
Expand Down
11 changes: 11 additions & 0 deletions moon.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# yaml-language-server: $schema=https://moonrepo.dev/schemas/project.json

project:
name: leaky-paywall
description: Storipress Leaky Paywall

type: library
language: typescript

tasks:
build:
command:
Expand Down Expand Up @@ -58,6 +65,10 @@ tasks:
deps:
- ~:lib-analyze
platform: node
deploy:
command: noop
deps:
- ~:minify
size:
command:
- size-limit
Expand Down
34 changes: 34 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
25 changes: 25 additions & 0 deletions terraform/.terraform.lock.hcl

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

30 changes: 30 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.38.0"
}
}

cloud {
organization = "Storipress"
workspaces {
name = "leaky-paywall"
}
}

required_version = "1.5.7"
}

provider "aws" {
region = "us-east-1"
access_key = var.aws_access_key
secret_key = var.aws_secret_key
}

resource "aws_s3_object" "leaky_paywall" {
bucket = "storipress"
key = "assets/storipress/leaky-paywall.min.js"
source = "../lib/leaky-paywall.min.js"
source_hash = filemd5("../lib/leaky-paywall.min.js")
}
27 changes: 27 additions & 0 deletions terraform/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
project:
name: terraform
description: Deploy leaky-paywall to CDN

type: automation

dependsOn:
- leaky-paywall

tasks:
fmt:
command:
- terraform
- fmt
plan:
command:
- terraform
- plan
deps:
- ^:deploy
deploy:
command:
- terraform
- apply
- -auto-approve
deps:
- ^:deploy
5 changes: 5 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "aws_access_key" {
}

variable "aws_secret_key" {
}

0 comments on commit 86c92fd

Please sign in to comment.