diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ae602b --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# .tfvars files +*.tfvars + +.terraform/* +logs +common/README.md + +OLD/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6f20ddd --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.48.0 + hooks: +# - id: terraform_validate + - id: terraform_fmt + - id: terraform_docs_replace + args: ['table'] + exclude: common/*.tf + exclude: version.tf + - id: terraform_tflint + args: [ "--args=--config=__GIT_WORKING_DIR__/.tflint.hcl"] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-symlinks + - id: detect-aws-credentials + - id: detect-private-key diff --git a/.tflint.hcl b/.tflint.hcl new file mode 100644 index 0000000..fcc2fa8 --- /dev/null +++ b/.tflint.hcl @@ -0,0 +1,21 @@ +config { + module = true + force = false + disabled_by_default = false + +# ignore_module = { +# "terraform-aws-modules/vpc/aws" = true +# "terraform-aws-modules/security-group/aws" = true +# } + +# varfile = ["example1.tfvars", "example2.tfvars"] +# variables = ["foo=bar", "bar=[\"baz\"]"] +} + +rule "aws_instance_invalid_type" { + enabled = true +} + +plugin "aws" { + enabled = true +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2ce3418 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Versions + +* v1.0.0 -- {{ yyyy-mm-dd }} + - initial creation + diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/common/availabilty_zones.tf b/common/availabilty_zones.tf new file mode 100644 index 0000000..fdf50d3 --- /dev/null +++ b/common/availabilty_zones.tf @@ -0,0 +1,30 @@ +# locals { +# az_list = data.aws_availability_zones.zones.names +# az_count = length(local.az_list) +# az_count_list = range(local.az_count) +# } + +data "aws_availability_zones" "zones" { + state = "available" +} + +data "aws_availability_zone" "zone" { + count = length(data.aws_availability_zones.zones.names) + state = "available" + name = data.aws_availability_zones.zones.names[count.index] +} + +output "availability_zone_names" { + description = "VPC Availability zone name list (3)" + value = data.aws_availability_zones.zones.names +} + +output "availability_zone_ids" { + description = "VPC Availability zone id list (3)" + value = data.aws_availability_zones.zones.zone_ids +} + +output "availability_zone_suffixes" { + description = "VPC Availability zone suffix list (3)" + value = data.aws_availability_zone.zone[*].name_suffix +} diff --git a/common/data.tf b/common/data.tf new file mode 100644 index 0000000..16506e6 --- /dev/null +++ b/common/data.tf @@ -0,0 +1,7 @@ +data "aws_caller_identity" "current" {} + +data "aws_arn" "current" { + arn = data.aws_caller_identity.current.arn +} + +data "aws_region" "current" {} diff --git a/common/defaults.tf b/common/defaults.tf new file mode 100644 index 0000000..8247df4 --- /dev/null +++ b/common/defaults.tf @@ -0,0 +1,4 @@ +locals { + _defaults = { + } +} diff --git a/common/locals.tf.initial b/common/locals.tf.initial new file mode 100644 index 0000000..2bd4d7f --- /dev/null +++ b/common/locals.tf.initial @@ -0,0 +1,9 @@ +locals { + account_id = var.account_id != "" ? var.account_id : data.aws_caller_identity.current.account_id + account_environment = data.aws_arn.current.partition == "aws-us-gov" ? "gov" : "ew" + + base_tags = { + "boc:tf_module_version" = local._module_version + "boc:created_by" = "terraform" + } +} diff --git a/common/prefixes.tf b/common/prefixes.tf new file mode 100644 index 0000000..d2ee1fe --- /dev/null +++ b/common/prefixes.tf @@ -0,0 +1,28 @@ +locals { + _prefixes = { + "efs" = "v-efs-" + "s3" = "v-s3-" + "ebs" = "v-ebs-" + "kms" = "k-kms-" + "role" = "r-" + "policy" = "p-" + "group" = "g-" + "security-group" = "" # "sg-" + # VPC + "vpc" = "" + "dhcp-options" = "" + "vpc-peer" = "vpcp-" + "route-table" = "route-" + "subnet" = "" + "vpc-endpoint" = "vpce-" + "elastic-ip" = "eip-" + "nat-gateway" = "nat-" + "internet-gateway" = "igw-" + "network-acl" = "nacl-" + "customer-gateway" = "cgw-" + "vpn-gateway" = "vpcg-" + "vpn-connection" = "vpn_" + "log-group" = "lg-" + "log-stream" = "lgs-" + } +} diff --git a/common/variables.common.availability_zones.tf b/common/variables.common.availability_zones.tf new file mode 100644 index 0000000..3e17e57 --- /dev/null +++ b/common/variables.common.availability_zones.tf @@ -0,0 +1,5 @@ +variable "availability_zones" { + description = "AWS Availability Zones to use (by default will use all available)" + type = list(string) + default = [] +} diff --git a/common/variables.common.tf b/common/variables.common.tf new file mode 100644 index 0000000..c77ef47 --- /dev/null +++ b/common/variables.common.tf @@ -0,0 +1,26 @@ +#--- +# account info +#--- +variable "account_id" { + description = "AWS Account ID (default will pull from current user)" + type = string + default = "" +} + +variable "account_alias" { + description = "AWS Account Alias" + type = string + default = "" +} + +variable "override_prefixes" { + description = "Override built-in prefixes by component. This should be used primarily for common infrastructure things" + type = map(string) + default = {} +} + +variable "tags" { + description = "AWS Tags to apply to appropriate resources" + type = map(string) + default = {} +} diff --git a/common/version.tf b/common/version.tf new file mode 100644 index 0000000..a0cd862 --- /dev/null +++ b/common/version.tf @@ -0,0 +1,3 @@ +locals { + _module_version = "0.0.0" +}