-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Terraform] // Missing Description, Add examples in module, Add valid…
…ation (#99)
- Loading branch information
1 parent
52e8209
commit 09c798e
Showing
24 changed files
with
214 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,6 @@ jobs: | |
- name: "Setup - Checkout" | ||
uses: actions/[email protected] | ||
|
||
# Static analysis of Terraform templates to spot potential security issues | ||
# Marketplace: https://github.com/marketplace/actions/terraform-security-scan | ||
- name: "Setup - Security Scan" | ||
uses: triat/terraform-security-scan@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Downloads a specific version of Terraform CLI and adds it to PATH | ||
# Marketplace: https://github.com/marketplace/actions/hashicorp-setup-terraform | ||
- name: Setup Terraform | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
module "bastion" { | ||
source = "../../modules/bastion" | ||
app = var.app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
module "mysql" { | ||
source = "../../../modules/database/mysql" | ||
app = var.app | ||
instance_type = var.instance_type | ||
master_user = var.master_user | ||
master_password = var.master_password | ||
multi_az = var.multi_az | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Provider configuration | ||
provider "aws" { | ||
region = var.region | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
data "aws_region" "current" {} | ||
|
||
data "aws_vpc" "selected" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
module "vpc" { | ||
source = "../../modules/network" | ||
app = var.app | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "= 3.22.0" | ||
} | ||
template = { | ||
source = "hashicorp/template" | ||
version = "= 2.2.0" | ||
} | ||
} | ||
required_version = "= 0.13.5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
provider "aws" { | ||
region = "us-west-2" | ||
} | ||
|
||
locals { | ||
name_suffix = "us-west-2-l-psi" | ||
tags = { | ||
AppId = "psi" | ||
Version = "1.0.0" | ||
Role = "security" | ||
Environment = "lab" | ||
} | ||
} | ||
|
||
# Add VPC | ||
module "vpc" { | ||
source = "../../network/example" | ||
} | ||
|
||
# Add security group | ||
module "bastion_sg" { | ||
source = "terraform-aws-modules/security-group/aws//modules/ssh" | ||
version = "3.17.0" | ||
name = "security-group-${local.name_suffix}-bastion" | ||
vpc_id = module.vpc.vpc_id | ||
description = "Bastion security group" | ||
ingress_cidr_blocks = ["0.0.0.0/0"] | ||
use_name_prefix = false | ||
auto_ingress_with_self = [] | ||
tags = merge(local.tags, { | ||
App = "bastion" | ||
}) | ||
} | ||
|
||
module "bastion" { | ||
source = "../" | ||
app = { | ||
id = "psi" | ||
name = "todo" | ||
version = "1.0.0" | ||
env = "lab" | ||
} | ||
ssh_users = [ | ||
{ | ||
username = "bastionuser" | ||
public_key = "######################[PLACE-YOUR-SSH-PUBLIC-KEY-HERE]######################" | ||
} | ||
] | ||
} |
48 changes: 48 additions & 0 deletions
48
todo-app/aws/3-tier-app/modules/database/mysql/example/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
provider "aws" { | ||
region = "us-west-2" | ||
} | ||
|
||
locals { | ||
name_suffix = "us-west-2-l-psi" | ||
tags = { | ||
AppId = "psi" | ||
Version = "1.0.0" | ||
Role = "security" | ||
Environment = "lab" | ||
} | ||
} | ||
|
||
# Add VPC | ||
module "vpc" { | ||
source = "../../network/example" | ||
} | ||
|
||
#Add security group | ||
module "mysql_sg" { | ||
source = "terraform-aws-modules/security-group/aws//modules/mysql" | ||
version = "3.17.0" | ||
name = "security-group-${local.name_suffix}-mysql" | ||
vpc_id = module.vpc.vpc_id | ||
description = "Test mysql database connection" | ||
use_name_prefix = false | ||
auto_ingress_with_self = [] | ||
# auto_ingress_rules = [] | ||
ingress_cidr_blocks = ["0.0.0.0/0"] | ||
|
||
tags = merge(local.tags, { | ||
App = "mysql" | ||
}) | ||
} | ||
|
||
module "mysql" { | ||
source = "../" | ||
app = { | ||
id = "psi" | ||
version = "1.0.0" | ||
env = "lab" | ||
} | ||
instance_type = "db.t2.micro" | ||
master_user = "masteruser" | ||
master_password = "masterpassword" | ||
multi_az = false | ||
} |
4 changes: 4 additions & 0 deletions
4
todo-app/aws/3-tier-app/modules/database/mysql/example/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "vpc_id" { | ||
description = "The ID of the VPC" | ||
value = module.vpc.vpc_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "= 3.22.0" | ||
} | ||
} | ||
required_version = "= 0.13.5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
provider "aws" { | ||
region = "us-west-2" | ||
} | ||
|
||
module "vpc" { | ||
source = "../" | ||
app = { | ||
id = "psi" | ||
version = "1.0.0" | ||
env = "lab" | ||
} | ||
cidr = "172.31.0.0/24" | ||
azs = ["us-west-2a", "us-west-2b"] | ||
public_subnets = ["172.31.0.128/26", "172.31.0.192/26"] | ||
private_subnets = ["172.31.0.0/27", "172.31.0.32/27"] | ||
database_subnets = ["172.31.0.64/27", "172.31.0.96/27"] | ||
create_internet_gateway = true | ||
create_database_subnet_group = true | ||
enable_nat_gateway_single = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "vpc_id" { | ||
description = "The ID of the VPC" | ||
value = module.vpc.vpc_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.