Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Aug 2, 2021
0 parents commit e97623a
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Local .terraform directories
**/.terraform/*

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

# .tfvars files
*.tfvars

.terraform/*
logs
common/README.md

OLD/
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Versions

* v1.0.0 -- {{ yyyy-mm-dd }}
- initial creation

Empty file added README.md
Empty file.
30 changes: 30 additions & 0 deletions common/availabilty_zones.tf
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions common/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "aws_caller_identity" "current" {}

data "aws_arn" "current" {
arn = data.aws_caller_identity.current.arn
}

data "aws_region" "current" {}
4 changes: 4 additions & 0 deletions common/defaults.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
_defaults = {
}
}
9 changes: 9 additions & 0 deletions common/locals.tf.initial
Original file line number Diff line number Diff line change
@@ -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"
}
}
28 changes: 28 additions & 0 deletions common/prefixes.tf
Original file line number Diff line number Diff line change
@@ -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-"
}
}
5 changes: 5 additions & 0 deletions common/variables.common.availability_zones.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "availability_zones" {
description = "AWS Availability Zones to use (by default will use all available)"
type = list(string)
default = []
}
26 changes: 26 additions & 0 deletions common/variables.common.tf
Original file line number Diff line number Diff line change
@@ -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 = {}
}
3 changes: 3 additions & 0 deletions common/version.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
_module_version = "0.0.0"
}

0 comments on commit e97623a

Please sign in to comment.