Skip to content

Commit

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

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

# .tfvars files
*.tfvars

.terraform/*
logs
common/README.md
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
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Versions

* v1.0.0 -- 20210502
- initial creation
23 changes: 23 additions & 0 deletions common/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
data "aws_caller_identity" "current" {}

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

data "aws_region" "current" {}

# output "caller_account_id" {
# value = data.aws_caller_identity.current.account_id
# }
#
# output "account_caller_arn" {
# value = data.aws_caller_identity.current.arn
# }
#
# output "account_caller_arn_partition" {
# value = data.aws_arn.current.partition
# }
#
# output "account_region_name" {
# value = data.aws_region.current.name
# }
22 changes: 22 additions & 0 deletions common/defaults.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# for the accesss logs for load balancers
# https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html#access-logging-bucket-permissions

locals {
_defaults = {
"load-balancer" = {
"gov" = ["190560391635", "048591011584"]
"us-gov-east-1" = "190560391635"
"us-gov-west-1" = "048591011584"

"ew" = ["127311923021", "033677994240", "027434742980", "797873946194"]
"us-east-1" = "127311923021"
"us-east-2" = "033677994240"
"us-west-1" = "027434742980"
"us-west-2" = "797873946194"
}
"ses" = {
"event_types" = ["bounce", "delivery", "complaint"]
}
}
}

26 changes: 26 additions & 0 deletions common/prefixes.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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-gateweay" = "vpcg-"
"vpn-connection" = "vpn_"
}
}
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 (S3, KMS). Do not include safeguard tags here, use the data_safeguard field for such things."
type = map(string)
default = {}
}
32 changes: 32 additions & 0 deletions common/variables.common.vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#---
# common variables for defining specific VPC components used throughout the submodules
#---
variable "vpc_name" {
description = "VPC name component used through the VPC descrbing its purpose (ex: dice-dev)"
type = string
default = null
}

variable "vpc_short_name" {
description = "VPC short name component (vpc{index})"
type = string
default = null
}

variable "vpc_full_name" {
description = "VPC full name component (vpc{index}-{vpc_name})"
type = string
default = null
}

variable "vpc_index" {
description = "VPC index number (integer starting at 1)"
type = number
default = null
}

variable "vpc_environment" {
description = "VPC environment purpose (infrastructure, common, shared, dev, stage, ite, prod)"
type = string
default = null
}
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 = "1.0.0"
}
1 change: 1 addition & 0 deletions security-groups/data.tf
1 change: 1 addition & 0 deletions security-groups/defaults.tf
70 changes: 70 additions & 0 deletions security-groups/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* # About aws-vpc-setup :: security-groups
*
* This sets up the default base security groups needed in each VPC from the `aws-common-security-groups` module
* and associated submodules.
* * it-linux-base
* * it-windows-base
* * ois-scanner
*
* # Usage
*
* ```hcl
* module "vpc-base-security-groups"
* source = "git@github.e.it.census.gov:terraform-modules/aws-vpc-setup.git//security-groups"
* vpc_id = "vpc-1234568"
* vpc_full_name = "vpc2-dice-dev"
* vpc_environment = "dev"
* tags = {}
* }
* ```
*/

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"
}
}

module "sg-linux-base" {
source = "git@github.e.it.census.gov:terraform-modules/aws-common-security-groups.git//it-linux-base"
vpc_id = var.vpc_id
vpc_full_name = var.vpc_full_name
use_vpc_cidr = false
enable_self = false
tags = merge(
local.base_tags,
local.tags,
map("Environment", var.vpc_environment),
)
}

module "sg-windows-base" {
source = "git@github.e.it.census.gov:terraform-modules/aws-common-security-groups.git//it-windows-base"
vpc_id = var.vpc_id
vpc_full_name = var.vpc_full_name
use_vpc_cidr = false
enable_self = false
tags = merge(
local.base_tags,
local.tags,
map("Environment", var.vpc_environment),
)
}

module "sg-ois-scanner" {
source = "git@github.e.it.census.gov:terraform-modules/aws-common-security-groups.git//ois-scanner"
vpc_id = var.vpc_id
vpc_full_name = var.vpc_full_name
use_vpc_cidr = false
enable_self = false
tags = merge(
local.tags,
local.base_tags,
map("Environment", var.vpc_environment),
)
}
1 change: 1 addition & 0 deletions security-groups/prefixes.tf
1 change: 1 addition & 0 deletions security-groups/variables.common.tf
1 change: 1 addition & 0 deletions security-groups/variables.common.vpc.tf
5 changes: 5 additions & 0 deletions security-groups/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "vpc_id" {
description = "VPC ID"
type = string
}

1 change: 1 addition & 0 deletions security-groups/version.tf

0 comments on commit 1246f39

Please sign in to comment.