Skip to content
Open
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
60 changes: 60 additions & 0 deletions src/basic-web-infra/exercises/alb-exercise1/lb/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
include {
path = find_in_parent_folders()
}

include "account" {
path = "${get_terragrunt_dir()}/../../../account.hcl"
expose = true
}

include "env" {
path = "${get_terragrunt_dir()}/../../env.hcl"
expose = true
}

dependencies {
paths = [
"${get_terragrunt_dir()}/../../vpc",
"${get_terragrunt_dir()}/../web"
]
}

dependency "vpc" {
config_path = "${get_terragrunt_dir()}/../../vpc"

mock_outputs = {
vpc_id = "vpc-test"
private_subnets_ids = [ "subnet-private-a", "subnet-private-b" ]
public_subnets_ids = [ "subnet-public-a", "subnet-public-b" ]
private_subnets_cidr_blocks = [ "10.1.2.0/24", "10.1.4.0/24" ]
public_subnets_cidr_blocks = [ "10.1.1.0/24", "10.1.3.0/24" ]
}
}

dependency "web" {
config_path = "${get_terragrunt_dir()}/../web"

mock_outputs = {
webserver_ids = ["i-12343459359", "i-94949494242424" ]
}
}

terraform {
source = "${get_terragrunt_dir()}/../../../modules/lb//"
}

inputs = {
deployment_long_name = include.account.locals.deployment_long_name
deployment_short_name = include.account.locals.deployment_short_name
deployment_role = include.env.locals.deployment_role
vpc_id = dependency.vpc.outputs.vpc_id
loadbalancer_subnets = dependency.vpc.outputs.public_subnets_ids

default_domain_name = "careevolution.dev"
default_subdomain = "alb-exercise1"
target_instances = dependency.web.outputs.webserver_ids
target_security_group_id = dependency.web.outputs.security_group_id
target_port = "80"

tags = include.env.locals.tags
}
52 changes: 52 additions & 0 deletions src/basic-web-infra/exercises/alb-exercise1/web/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
include {
path = find_in_parent_folders()
}

include "account" {
path = "${get_terragrunt_dir()}/../../../account.hcl"
expose = true
}

include "env" {
path = "${get_terragrunt_dir()}/../../env.hcl"
expose = true
}

dependencies {
paths = [
"${get_terragrunt_dir()}/../../vpc"
]
}

dependency "vpc" {
config_path = "${get_terragrunt_dir()}/../../vpc"

mock_outputs = {
vpc_id = "vpc-test"
private_subnets_ids = [ "subnet-private-a", "subnet-private-b" ]
public_subnets_ids = [ "subnet-public-a", "subnet-public-b" ]
private_subnets_cidr_blocks = [ "10.1.2.0/24", "10.1.4.0/24" ]
public_subnets_cidr_blocks = [ "10.1.1.0/24", "10.1.3.0/24" ]
}
}
terraform {
source = "${get_terragrunt_dir()}/../../../modules/web//"
}

inputs = {
deployment_long_name = include.account.locals.deployment_long_name
deployment_short_name = include.account.locals.deployment_short_name
deployment_role = include.env.locals.deployment_role

vpc_id = dependency.vpc.outputs.vpc_id
vpc_cidr_block = include.env.locals.vpc_cidr
instance_subnet_id = dependency.vpc.outputs.public_subnets_ids[0]
suffixes = [ "01A", "02A" ]
instance_type = "t3.medium"
keypair_name = "${include.account.locals.deployment_long_name}-${include.env.locals.deployment_role}"
tags = include.env.locals.tags
patch_group = "Windows Automatic Reboot"

allow_remote_access = include.env.locals.allow_remote_access
remote_access_cidrs = include.env.locals.remote_access_cidrs
}
21 changes: 21 additions & 0 deletions src/basic-web-infra/exercises/env.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

locals {
deployment_role = "exercises"
vpc_cidr = "10.45.0.0/16"

allow_remote_access = false
remote_access_cidrs = [
]

terragrunt_tags = {
created_by = "terraform"
terraform_path = "/${lower(path_relative_to_include())}"
}

tags = {
ce_resource_path = "/HIRING/EXERCISES"
created_by = "terraform",
project = "exercises"
cost_center = "hiring"
}
}
34 changes: 34 additions & 0 deletions src/basic-web-infra/exercises/vpc/terragrunt.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include {
path = find_in_parent_folders()
}

include "account" {
path = "${get_terragrunt_dir()}/../../account.hcl"
expose = true
}

include "env" {
path = "${get_terragrunt_dir()}/../env.hcl"
expose = true
}

dependency "infrastructure" {
config_path = "${get_terragrunt_dir()}/../../../infrastructure/prod"
}

terraform {
source = "${get_terragrunt_dir()}/../../modules/vpc//"
}

inputs = {
deployment_long_name = include.account.locals.deployment_long_name
deployment_short_name = include.account.locals.deployment_short_name
deployment_role = include.env.locals.deployment_role

vpc_cidr = include.env.locals.vpc_cidr
infrastructure_dns_domain_name = dependency.infrastructure.outputs.dns_domain_name
infrastructure_dns_server_ips = dependency.infrastructure.outputs.dns_server_ips
infrastructure_ntp_server_ips = dependency.infrastructure.outputs.ntp_server_ips
infrastructure_netbios_nameserver_ips = dependency.infrastructure.outputs.netbios_name_server_ips
infrastructure_netbios_node_type = dependency.infrastructure.outputs.netbios_node_type
}
28 changes: 28 additions & 0 deletions src/basic-web-infra/global/config/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

resource "aws_iam_role" "config" {
name = "AWSConfigRole"

assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "config.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
POLICY
}

resource "aws_iam_role_policy_attachment" "config" {
role = aws_iam_role.config.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSConfigRole"
}

Loading