Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: isort
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v2.5.0
hooks:
- id: check-ast
- id: check-merge-conflict
Expand Down
2 changes: 1 addition & 1 deletion modules-metadata/rds-aurora_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.11.0
v2.15.0
16 changes: 14 additions & 2 deletions modules-metadata/rds.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
"description": "The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance_window",
"type": "string"
},
"ca_cert_identifier": {
"default": "rds-ca-2019",
"description": "Specifies the identifier of the CA certificate for the DB instance",
"type": "string"
},
"character_set_name": {
"default": "",
"description": "(Optional) The character set name to use for DB encoding in Oracle instances. This can't be changed. See Oracle Character Sets Supported in Amazon RDS for more information",
Expand All @@ -49,7 +54,7 @@
},
"create_db_option_group": {
"default": true,
"description": "Whether to create a database option group",
"description": "(Optional) Create a database option group",
"type": "bool"
},
"create_db_parameter_group": {
Expand Down Expand Up @@ -177,9 +182,16 @@
},
"option_group_name": {
"default": "",
"description": "Name of the DB option group to associate. Setting this automatically disables option_group creation",
"description": "Name of the DB option group to associate",
"type": "string"
},
"option_group_timeouts": {
"default": {
"delete": "15m"
},
"description": "Define maximum timeout for deletion of `aws_db_option_group` resource",
"type": "map(string)"
},
"options": {
"default": [],
"description": "A list of Options to apply.",
Expand Down
16 changes: 14 additions & 2 deletions modules-metadata/rds_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
"description": "The daily time range (in UTC) during which automated backups are created if they are enabled. Example: '09:46-10:16'. Must not overlap with maintenance_window",
"type": "string"
},
"ca_cert_identifier": {
"default": "rds-ca-2019",
"description": "Specifies the identifier of the CA certificate for the DB instance",
"type": "string"
},
"character_set_name": {
"default": "",
"description": "(Optional) The character set name to use for DB encoding in Oracle instances. This can't be changed. See Oracle Character Sets Supported in Amazon RDS for more information",
Expand All @@ -49,7 +54,7 @@
},
"create_db_option_group": {
"default": true,
"description": "Whether to create a database option group",
"description": "(Optional) Create a database option group",
"type": "bool"
},
"create_db_parameter_group": {
Expand Down Expand Up @@ -174,9 +179,16 @@
},
"option_group_name": {
"default": "",
"description": "Name of the DB option group to associate. Setting this automatically disables option_group creation",
"description": "Name of the DB option group to associate",
"type": "string"
},
"option_group_timeouts": {
"default": {
"delete": "15m"
},
"description": "Define maximum timeout for deletion of `aws_db_option_group` resource",
"type": "map(string)"
},
"options": {
"default": [],
"description": "A list of Options to apply.",
Expand Down
2 changes: 1 addition & 1 deletion modules-metadata/rds_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.5.0
v2.14.0
2 changes: 1 addition & 1 deletion modules-metadata/redshift_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.2.0
v2.3.0
2 changes: 1 addition & 1 deletion modules-metadata/s3-bucket_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.0
v1.5.0
2 changes: 1 addition & 1 deletion modules-metadata/security-group_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.2.0
v3.4.0
2 changes: 1 addition & 1 deletion modules-metadata/vpc_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.21.0
v2.24.0
6 changes: 5 additions & 1 deletion modulestf/cloudcraft/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def populate_graph(data): # noqa: C901
if group_node not in G.nodes:
continue

# nodes type "icon" does not have "data", so we skip them
if "data" not in G.nodes[group_node]:
continue

if group_type == "asg":
G.nodes[group_node]["data"]["asg_id"] = group_id
elif group_type == "sg":
Expand Down Expand Up @@ -109,7 +113,7 @@ def populate_graph(data): # noqa: C901
relTo = mapPos.get("relTo")

if relTo in G.nodes:
G.nodes[relTo]["text"] = text["text"]
G.nodes[relTo]["text"] = text["text"].strip()

###########
# REGION
Expand Down
4 changes: 2 additions & 2 deletions modulestf/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ def convert_graph_to_modulestf_config(graph): # noqa: C901

if node.get("engine") == "aurora-mysql":
r.update_params({
"engine": "aurora-postgres",
"engine": "aurora-mysql",
"port": "3306",
"engine_version": "5.7.12",
})
elif node.get("engine") == "postgres":
r.update_params({
"engine": "aurora-postgres",
"engine": "aurora-postgresql",
"port": "5432",
"engine_version": "9.6.9",
})
Expand Down
6 changes: 3 additions & 3 deletions modulestf/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ def render_from_modulestf_config(config, source, regions):
module_type: MODULES[module_type]["variables"],
})

logger.info("Prepare common files")
templates_dir = path.realpath(path.join(COOKIECUTTER_TEMPLATES_DIR, "terragrunt-common-layer/common"))
copy_to_working_dir(templates_dir, "common")
# logger.info("Prepare common files")
# templates_dir = path.realpath(path.join(COOKIECUTTER_TEMPLATES_DIR, "terragrunt-common-layer/common"))
# copy_to_working_dir(templates_dir, "common")

logger.info("Prepare common regional files")
templates_dir = path.realpath(path.join(COOKIECUTTER_TEMPLATES_DIR, "terragrunt-common-layer/region"))
Expand Down
6 changes: 0 additions & 6 deletions templates/root/template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
*.tfstate*
crash.log

# Copies of main_providers.tf
main_providers.tf

# Except original (see related issue - https://github.com/gruntwork-io/terragrunt/issues/785)
!common/main_providers.tf

# Secrets are not allowed in general
*.key
*.pem
Expand Down
4 changes: 2 additions & 2 deletions templates/root/template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.20.0
rev: v1.25.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v2.5.0
hooks:
- id: check-merge-conflict
2 changes: 1 addition & 1 deletion templates/root/template/LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The MIT License (MIT)
Copyright (c) 2018-2019 Anton Babenko
Copyright (c) 2018-2020 Anton Babenko

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
8 changes: 4 additions & 4 deletions templates/root/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This repository contains infrastructure as Terraform configurations which were automatically generated from blueprint created using [cloudcraft.co](https://cloudcraft.co/app).

[Terragrunt](https://github.com/gruntwork-io/terragrunt) is used to work with Terraform configurations which allows to orchestrate dependent layers, update arguments dynamically and keep configurations [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).
[Terragrunt](https://terragrunt.gruntwork.io/) is used to work with Terraform configurations which allows to orchestrate dependent layers, update arguments dynamically and keep configurations [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself).

## Table of Contents

Expand All @@ -16,7 +16,7 @@ This repository contains infrastructure as Terraform configurations which were a
## Quick start

1. [Install Terraform 0.12 or newer](https://www.terraform.io/intro/getting-started/install.html)
1. [Install Terragrunt 0.19 or newer](https://github.com/gruntwork-io/terragrunt#install-terragrunt)
1. [Install Terragrunt 0.22 or newer](https://terragrunt.gruntwork.io/docs/getting-started/install/)
1. Optionally, [install pre-commit hooks](https://pre-commit.com/#install) to keep Terraform formatting and documentation up-to-date.

If you are using macOS you can install all dependencies using [Homebrew](https://brew.sh/):
Expand All @@ -33,7 +33,7 @@ $ export AWS_ACCESS_KEY_ID=...
$ export AWS_SECRET_ACCESS_KEY=...
```

Alternatively, you can edit `common/main_providers.tf` and use another authentication mechanism as described in [AWS provider documentation](https://www.terraform.io/docs/providers/aws/index.html#authentication).
Alternatively, you can edit `terragrunt.hcl` and use another authentication mechanism as described in [AWS provider documentation](https://www.terraform.io/docs/providers/aws/index.html#authentication).

## Create and manage your infrastructure

Expand Down Expand Up @@ -67,7 +67,7 @@ After the confirmation your infrastructure should be created.

## References

* [Terraform documentation](https://terraform.io/) and [Terragrunt documentation](https://github.com/gruntwork-io/terragrunt/blob/master/README.md) for all available commands and features.
* [Terraform documentation](https://www.terraform.io/docs/) and [Terragrunt documentation](https://terragrunt.gruntwork.io/docs/) for all available commands and features.
* [Terraform AWS modules](https://github.com/terraform-aws-modules/).
* [Terraform modules registry](https://registry.terraform.io/).

Expand Down
13 changes: 0 additions & 13 deletions templates/terragrunt-common-layer/common/main_providers.tf

This file was deleted.

40 changes: 25 additions & 15 deletions templates/terragrunt-common-layer/region/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,41 @@ terraform {
commands = get_terraform_commands_that_need_input()
arguments = ["-input=false"]
}

after_hook "copy_common_main_providers" {
commands = ["init-from-module"]
execute = ["cp", "${get_parent_terragrunt_dir()}/../../common/main_providers.tf", "."]
}

// Do not delete the copied file because of the odd behavior described in this related issue - https://github.com/gruntwork-io/terragrunt/issues/785
// after_hook "remove_useless_copy_of_main_providers" {
// commands = ["init"]
// execute = ["rm", "-f", "${get_parent_terragrunt_dir()}/${path_relative_to_include()}/main_providers.tf"]
// }
}

remote_state {
backend = "s3"
backend = "s3"
disable_init = tobool(get_env("TERRAGRUNT_DISABLE_INIT", "false"))

generate = {
path = "_backend.tf"
if_exists = "overwrite"
}

config = {
encrypt = true
region = "{{ cookiecutter.region }}"
key = "${path_relative_to_include()}/terraform.tfstate"
bucket = "terraform-states-${get_aws_account_id()}"
dynamodb_table = "terraform-locks-${get_aws_account_id()}"
key = format("%s/terraform.tfstate", path_relative_to_include())
bucket = format("terraform-states-%s", get_aws_account_id())
dynamodb_table = format("terraform-locks-%s", get_aws_account_id())

skip_metadata_api_check = true
skip_credentials_validation = true
}
}

generate "main_providers" {
path = "main_providers.tf"
if_exists = "overwrite"
contents = <<EOF
provider "aws" {
region = "{{ cookiecutter.region }}"

# Make it faster by skipping something
skip_get_ec2_platforms = true
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
}
EOF
}
2 changes: 1 addition & 1 deletion test_fixtures/input_cloudcraft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"queryStringParameters":
{
"cloudcraft": "https://cloudcraft.co/api/blueprint/cd5294fb-0aab-4475-bbcc-196f12738eac?key=KVQAR8lIWQP6ycISkqGjIA"
"cloudcraft": "https://cloudcraft.co/api/blueprint/b2eda0eb-21b2-45d8-93d5-c0b4906eb69e?key=XlAaasYL4pOa5f-Wzkt5CQ"
}
}