Skip to content

Commit 16b23c5

Browse files
authored
Merge pull request #16 from rhythmictech/terraform-v0.13.x
Terraform v0.13.x
2 parents 72e13b3 + c4d4e9a commit 16b23c5

10 files changed

Lines changed: 175 additions & 19 deletions

File tree

.terraform-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.24
1+
0.13.6

account/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../Makefile

account/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
| Name | Version |
77
|------|---------|
8-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
8+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
99

1010
## Providers
1111

@@ -16,13 +16,13 @@ No providers.
1616
| Name | Source | Version |
1717
|------|--------|---------|
1818
| <a name="module_backend"></a> [backend](#module\_backend) | rhythmictech/backend/aws | 2.1.0 |
19-
| <a name="module_cloudtrail_bucket"></a> [cloudtrail\_bucket](#module\_cloudtrail\_bucket) | rhythmictech/cloudtrail-bucket/aws | 1.2.0 |
20-
| <a name="module_cloudtrail_logging"></a> [cloudtrail\_logging](#module\_cloudtrail\_logging) | rhythmictech/cloudtrail-logging/aws | 1.1.0 |
19+
| <a name="module_cloudtrail_bucket"></a> [cloudtrail\_bucket](#module\_cloudtrail\_bucket) | rhythmictech/cloudtrail-bucket/aws | ~> 1.2.0 |
20+
| <a name="module_cloudtrail_logging"></a> [cloudtrail\_logging](#module\_cloudtrail\_logging) | rhythmictech/cloudtrail-logging/aws | ~> 1.1.0 |
2121
| <a name="module_does_workspace_match_env"></a> [does\_workspace\_match\_env](#module\_does\_workspace\_match\_env) | rhythmictech/errorcheck/terraform | ~> 1.0.0 |
2222
| <a name="module_iam_password_policy"></a> [iam\_password\_policy](#module\_iam\_password\_policy) | rhythmictech/iam-password-policy/aws | 1.0.0 |
23-
| <a name="module_rhythmic_iam_roles"></a> [rhythmic\_iam\_roles](#module\_rhythmic\_iam\_roles) | rhythmictech/rhythmic-iam-roles/aws | 1.1.0 |
24-
| <a name="module_s3logging_bucket"></a> [s3logging\_bucket](#module\_s3logging\_bucket) | rhythmictech/s3logging-bucket/aws | 1.0.1 |
25-
| <a name="module_tags"></a> [tags](#module\_tags) | rhythmictech/tags/terraform | 1.1.0 |
23+
| <a name="module_rhythmic_iam_roles"></a> [rhythmic\_iam\_roles](#module\_rhythmic\_iam\_roles) | rhythmictech/rhythmic-iam-roles/aws | ~> 1.1.0 |
24+
| <a name="module_s3logging_bucket"></a> [s3logging\_bucket](#module\_s3logging\_bucket) | rhythmictech/s3logging-bucket/aws | ~> 1.0.1 |
25+
| <a name="module_tags"></a> [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1.0 |
2626

2727
## Resources
2828

account/main.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "tags" {
22
source = "rhythmictech/tags/terraform"
3-
version = "1.1.0"
3+
version = "~> 1.1.0"
44

55
names = [
66
"account",
@@ -17,30 +17,40 @@ module "tags" {
1717

1818
module "rhythmic_iam_roles" {
1919
source = "rhythmictech/rhythmic-iam-roles/aws"
20-
version = "1.1.0"
20+
version = "~> 1.1.0"
2121
role_prefix = var.iam_role_prefix
2222
master_account = var.iam_master_account
2323
}
2424

2525
module "s3logging_bucket" {
26-
source = "rhythmictech/s3logging-bucket/aws"
27-
version = "1.0.1"
26+
source = "rhythmictech/s3logging-bucket/aws"
27+
version = "~> 1.0.1"
28+
2829
bucket_suffix = "account"
2930
region = var.region
3031
tags = module.tags.tags_no_name
32+
33+
# store for 1 yr
34+
lifecycle_rules = [{
35+
id = "expire"
36+
enabled = true
37+
prefix = null
38+
expiration = 365
39+
noncurrent_version_expiration = 365
40+
}]
3141
}
3242

3343
module "cloudtrail_bucket" {
3444
source = "rhythmictech/cloudtrail-bucket/aws"
35-
version = "1.2.0"
45+
version = "~> 1.2.0"
3646
logging_bucket = module.s3logging_bucket.s3logging_bucket_name
3747
region = var.region
3848
tags = module.tags.tags_no_name
3949
}
4050

4151
module "cloudtrail_logging" {
4252
source = "rhythmictech/cloudtrail-logging/aws"
43-
version = "1.1.0"
53+
version = "~> 1.1.0"
4454
region = var.region
4555
cloudtrail_bucket = module.cloudtrail_bucket.s3_bucket_name
4656
kms_key_id = module.cloudtrail_bucket.kms_key_id

account/setup/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
#tfsec:ignore:aws-dynamodb-table-customer-key,aws-dynamodb-enable-recovery
23
module "backend" {
34
source = "rhythmictech/backend/aws"
45
version = "2.1.0"

bin/new-project.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env bash -e
2+
3+
#
4+
# this script is used for bootstraping a new project in your AWS account
5+
#
6+
7+
new_folder=$1
8+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
9+
10+
# authoritative backend file
11+
backend_file="account/backend.auto.tfvars"
12+
13+
# remote state variables
14+
tfstate_bucket=""
15+
region="us-east-1"
16+
dynamodb_table="tf-locktable"
17+
18+
19+
function usage() {
20+
cat <<EOF
21+
Usage: bin/new-project.sh FOLDER_NAME
22+
23+
Creates new folder with common files for another cloud component defined in terraform.
24+
25+
EOF
26+
}
27+
28+
function check_for_errors() {
29+
if [ -z $new_folder ]; then
30+
echo "ERROR: no new folder specified"
31+
usage
32+
exit 1
33+
fi
34+
if [ -d $new_folder ]; then
35+
echo "ERROR: $new_folder already exits"
36+
usage
37+
exit 1
38+
fi
39+
}
40+
41+
function get_backend_variables() {
42+
echo "Getting backend variables from $backend_file"
43+
while read line; do
44+
key=$(echo $line | sed -E 's/([a-zAZ_]*)([ =]*)(.*)/\1/')
45+
value=$(echo $line | sed -E 's/([a-zAZ_]*)([ =]*)(.*)/\3/')
46+
case $key in
47+
bucket)
48+
tfstate_bucket=$value
49+
;;
50+
region)
51+
region=$value
52+
;;
53+
dynamodb_table)
54+
dynamodb_table=$value
55+
;;
56+
*)
57+
;;
58+
esac
59+
60+
done <$backend_file
61+
}
62+
63+
function create_new_folder() {
64+
echo "creating new folder, $new_folder"
65+
mkdir $new_folder
66+
67+
cd $new_folder
68+
69+
echo "symlinking common files"
70+
ln -s ../common/* .
71+
echo "done creating new folder"
72+
}
73+
74+
function create_backend_file() {
75+
new_backend="backend.auto.tfvars"
76+
touch $new_backend
77+
echo "bucket = $tfstate_bucket" >> $new_backend
78+
echo "key = \"$new_folder.tfstate\"" >> $new_backend
79+
echo "dynamodb_table = $dynamodb_table" >> $new_backend
80+
echo "region = $region" >> $new_backend
81+
}
82+
83+
function create_readme() {
84+
echo "# $new_folder" > README.md
85+
cat <<EOT >> README.md
86+
87+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
88+
## Inputs
89+
90+
| Name | Description | Type | Default | Required |
91+
|------|-------------|:----:|:-----:|:-----:|
92+
93+
## Outputs
94+
95+
| Name | Description |
96+
|------|-------------|
97+
98+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
99+
EOT
100+
101+
}
102+
103+
function create_terraform_files() {
104+
create_readme
105+
106+
echo "include ../Makefile" > Makefile
107+
108+
touch main.tf
109+
touch variables.tf
110+
touch outputs.tf
111+
112+
create_backend_file
113+
}
114+
115+
function main() {
116+
check_for_errors
117+
get_backend_variables
118+
create_new_folder
119+
create_terraform_files
120+
121+
echo 'done'
122+
}
123+
124+
main "$@"

bin/setup.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash -e
2+
3+
#
4+
# this script is used for bootstraping the project base infrastructure
5+
#
6+
7+
# create base infra
8+
echo "Initializing tfstate"
9+
cd account/setup
10+
terraform init
11+
terraform apply -auto-approve
12+
cd ../..
13+
14+
# migrate local state to the remote with the s3 bucket and dynamodb table
15+
echo "Migrating tfstate to bucket"
16+
cd account
17+
cp setup/terraform.tfstate .
18+
terraform init -backend-config=backend.auto.tfvars
19+
rm terraform.tfstate
20+
cd ..

common/common.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ provider "aws" {
88
terraform {
99
backend "s3" {}
1010

11-
required_version = ">= 0.12.0"
11+
required_version = ">= 0.13.0"
1212
}
1313

1414
# Intentionally throws an error if the workspace doesn't match the env

network/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
| Name | Version |
77
|------|---------|
8-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12.0 |
8+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
99

1010
## Providers
1111

@@ -20,8 +20,8 @@
2020
|------|--------|---------|
2121
| <a name="module_does_workspace_match_env"></a> [does\_workspace\_match\_env](#module\_does\_workspace\_match\_env) | rhythmictech/errorcheck/terraform | ~> 1.0.0 |
2222
| <a name="module_tags"></a> [tags](#module\_tags) | rhythmictech/tags/terraform | ~> 1.1.0 |
23-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 2.44.0 |
24-
| <a name="module_vpcflowlogs"></a> [vpcflowlogs](#module\_vpcflowlogs) | rhythmictech/vpcflowlogs/aws | 1.1.2 |
23+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 2.44.0 |
24+
| <a name="module_vpcflowlogs"></a> [vpcflowlogs](#module\_vpcflowlogs) | rhythmictech/vpcflowlogs/aws | ~> 1.1.2 |
2525

2626
## Resources
2727

network/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module "tags" {
3636

3737
module "vpc" {
3838
source = "terraform-aws-modules/vpc/aws"
39-
version = "2.44.0"
39+
version = "~> 2.44.0"
4040

4141
name = module.tags.name
4242
azs = var.availability_zones
@@ -49,7 +49,7 @@ module "vpc" {
4949

5050
module "vpcflowlogs" {
5151
source = "rhythmictech/vpcflowlogs/aws"
52-
version = "1.1.2"
52+
version = "~> 1.1.2"
5353

5454
create_bucket = true
5555
create_kms_key = true

0 commit comments

Comments
 (0)