diff --git a/.terraform-version b/.terraform-version
index 421e954..ebf55b3 100644
--- a/.terraform-version
+++ b/.terraform-version
@@ -1 +1 @@
-0.12.24
+0.13.6
diff --git a/account/Makefile b/account/Makefile
new file mode 100644
index 0000000..bb69e69
--- /dev/null
+++ b/account/Makefile
@@ -0,0 +1 @@
+include ../Makefile
diff --git a/account/README.md b/account/README.md
index e4fee98..481af84 100644
--- a/account/README.md
+++ b/account/README.md
@@ -5,7 +5,7 @@
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.12.0 |
+| [terraform](#requirement\_terraform) | >= 0.13.0 |
## Providers
@@ -16,13 +16,13 @@ No providers.
| Name | Source | Version |
|------|--------|---------|
| [backend](#module\_backend) | rhythmictech/backend/aws | 2.1.0 |
-| [cloudtrail\_bucket](#module\_cloudtrail\_bucket) | rhythmictech/cloudtrail-bucket/aws | 1.2.0 |
-| [cloudtrail\_logging](#module\_cloudtrail\_logging) | rhythmictech/cloudtrail-logging/aws | 1.1.0 |
+| [cloudtrail\_bucket](#module\_cloudtrail\_bucket) | rhythmictech/cloudtrail-bucket/aws | ~> 1.2.0 |
+| [cloudtrail\_logging](#module\_cloudtrail\_logging) | rhythmictech/cloudtrail-logging/aws | ~> 1.1.0 |
| [does\_workspace\_match\_env](#module\_does\_workspace\_match\_env) | rhythmictech/errorcheck/terraform | ~> 1.0.0 |
| [iam\_password\_policy](#module\_iam\_password\_policy) | rhythmictech/iam-password-policy/aws | 1.0.0 |
-| [rhythmic\_iam\_roles](#module\_rhythmic\_iam\_roles) | rhythmictech/rhythmic-iam-roles/aws | 1.1.0 |
-| [s3logging\_bucket](#module\_s3logging\_bucket) | rhythmictech/s3logging-bucket/aws | 1.0.1 |
-| [tags](#module\_tags) | rhythmictech/tags/terraform | 1.1.0 |
+| [rhythmic\_iam\_roles](#module\_rhythmic\_iam\_roles) | rhythmictech/rhythmic-iam-roles/aws | ~> 1.1.0 |
+| [s3logging\_bucket](#module\_s3logging\_bucket) | rhythmictech/s3logging-bucket/aws | ~> 1.0.1 |
+| [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1.0 |
## Resources
diff --git a/account/main.tf b/account/main.tf
index 1b68226..539f231 100644
--- a/account/main.tf
+++ b/account/main.tf
@@ -1,6 +1,6 @@
module "tags" {
source = "rhythmictech/tags/terraform"
- version = "1.1.0"
+ version = "~> 1.1.0"
names = [
"account",
@@ -17,22 +17,32 @@ module "tags" {
module "rhythmic_iam_roles" {
source = "rhythmictech/rhythmic-iam-roles/aws"
- version = "1.1.0"
+ version = "~> 1.1.0"
role_prefix = var.iam_role_prefix
master_account = var.iam_master_account
}
module "s3logging_bucket" {
- source = "rhythmictech/s3logging-bucket/aws"
- version = "1.0.1"
+ source = "rhythmictech/s3logging-bucket/aws"
+ version = "~> 1.0.1"
+
bucket_suffix = "account"
region = var.region
tags = module.tags.tags_no_name
+
+ # store for 1 yr
+ lifecycle_rules = [{
+ id = "expire"
+ enabled = true
+ prefix = null
+ expiration = 365
+ noncurrent_version_expiration = 365
+ }]
}
module "cloudtrail_bucket" {
source = "rhythmictech/cloudtrail-bucket/aws"
- version = "1.2.0"
+ version = "~> 1.2.0"
logging_bucket = module.s3logging_bucket.s3logging_bucket_name
region = var.region
tags = module.tags.tags_no_name
@@ -40,7 +50,7 @@ module "cloudtrail_bucket" {
module "cloudtrail_logging" {
source = "rhythmictech/cloudtrail-logging/aws"
- version = "1.1.0"
+ version = "~> 1.1.0"
region = var.region
cloudtrail_bucket = module.cloudtrail_bucket.s3_bucket_name
kms_key_id = module.cloudtrail_bucket.kms_key_id
diff --git a/account/setup/main.tf b/account/setup/main.tf
index 92f0945..9a4e624 100644
--- a/account/setup/main.tf
+++ b/account/setup/main.tf
@@ -1,4 +1,5 @@
+#tfsec:ignore:aws-dynamodb-table-customer-key,aws-dynamodb-enable-recovery
module "backend" {
source = "rhythmictech/backend/aws"
version = "2.1.0"
diff --git a/bin/new-project.sh b/bin/new-project.sh
new file mode 100644
index 0000000..1a496ab
--- /dev/null
+++ b/bin/new-project.sh
@@ -0,0 +1,124 @@
+#!/usr/bin/env bash -e
+
+#
+# this script is used for bootstraping a new project in your AWS account
+#
+
+new_folder=$1
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+# authoritative backend file
+backend_file="account/backend.auto.tfvars"
+
+# remote state variables
+tfstate_bucket=""
+region="us-east-1"
+dynamodb_table="tf-locktable"
+
+
+function usage() {
+ cat <> $new_backend
+ echo "key = \"$new_folder.tfstate\"" >> $new_backend
+ echo "dynamodb_table = $dynamodb_table" >> $new_backend
+ echo "region = $region" >> $new_backend
+}
+
+function create_readme() {
+ echo "# $new_folder" > README.md
+cat <> README.md
+
+
+## Inputs
+
+| Name | Description | Type | Default | Required |
+|------|-------------|:----:|:-----:|:-----:|
+
+## Outputs
+
+| Name | Description |
+|------|-------------|
+
+
+EOT
+
+}
+
+function create_terraform_files() {
+ create_readme
+
+ echo "include ../Makefile" > Makefile
+
+ touch main.tf
+ touch variables.tf
+ touch outputs.tf
+
+ create_backend_file
+}
+
+function main() {
+ check_for_errors
+ get_backend_variables
+ create_new_folder
+ create_terraform_files
+
+ echo 'done'
+}
+
+main "$@"
diff --git a/bin/setup.sh b/bin/setup.sh
new file mode 100644
index 0000000..e77cb8e
--- /dev/null
+++ b/bin/setup.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash -e
+
+#
+# this script is used for bootstraping the project base infrastructure
+#
+
+# create base infra
+echo "Initializing tfstate"
+cd account/setup
+terraform init
+terraform apply -auto-approve
+cd ../..
+
+# migrate local state to the remote with the s3 bucket and dynamodb table
+echo "Migrating tfstate to bucket"
+cd account
+cp setup/terraform.tfstate .
+terraform init -backend-config=backend.auto.tfvars
+rm terraform.tfstate
+cd ..
diff --git a/common/common.tf b/common/common.tf
index c58ac4a..4a53677 100644
--- a/common/common.tf
+++ b/common/common.tf
@@ -8,7 +8,7 @@ provider "aws" {
terraform {
backend "s3" {}
- required_version = ">= 0.12.0"
+ required_version = ">= 0.13.0"
}
# Intentionally throws an error if the workspace doesn't match the env
diff --git a/network/README.md b/network/README.md
index 4b43e02..61f8b2d 100644
--- a/network/README.md
+++ b/network/README.md
@@ -5,7 +5,7 @@
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 0.12.0 |
+| [terraform](#requirement\_terraform) | >= 0.13.0 |
## Providers
@@ -20,8 +20,8 @@
|------|--------|---------|
| [does\_workspace\_match\_env](#module\_does\_workspace\_match\_env) | rhythmictech/errorcheck/terraform | ~> 1.0.0 |
| [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1.0 |
-| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 2.44.0 |
-| [vpcflowlogs](#module\_vpcflowlogs) | rhythmictech/vpcflowlogs/aws | 1.1.2 |
+| [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.44.0 |
+| [vpcflowlogs](#module\_vpcflowlogs) | rhythmictech/vpcflowlogs/aws | ~> 1.1.2 |
## Resources
diff --git a/network/main.tf b/network/main.tf
index b288cd2..20289a2 100644
--- a/network/main.tf
+++ b/network/main.tf
@@ -36,7 +36,7 @@ module "tags" {
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
- version = "2.44.0"
+ version = "~> 2.44.0"
name = module.tags.name
azs = var.availability_zones
@@ -49,7 +49,7 @@ module "vpc" {
module "vpcflowlogs" {
source = "rhythmictech/vpcflowlogs/aws"
- version = "1.1.2"
+ version = "~> 1.1.2"
create_bucket = true
create_kms_key = true