diff --git a/01_05_base/main.tf b/01_05_base/main.tf index e8f85d8..9feef77 100644 --- a/01_05_base/main.tf +++ b/01_05_base/main.tf @@ -10,7 +10,7 @@ variable "ssh_key_name" {} variable "private_key_path" {} variable "region" { - default = "us-east-2" + default = "us-east-1" } variable "vpc_cidr" { @@ -150,5 +150,6 @@ data "aws_ami" "aws-linux" { # OUTPUT # ////////////////////////////// output "instance-dns" { + // ec2-18-208-149-36.compute-1.amazonaws.com value = aws_instance.nodejs1.public_dns } \ No newline at end of file diff --git a/02_01_variables/main.tf b/02_01_variables/main.tf index ff9d644..13422cc 100644 --- a/02_01_variables/main.tf +++ b/02_01_variables/main.tf @@ -6,7 +6,11 @@ variable "aws_access_key" {} variable "aws_secret_key" {} variable "region" { - default = "us-east-2" + default = "us-east-1" +} + +variable "deploy_environment" { + default = "DEV" } variable "vpc_cidr" { @@ -141,15 +145,15 @@ resource "aws_security_group" "sg-nodejs-instance" { # INSTANCE resource "aws_instance" "nodejs1" { ami = data.aws_ami.aws-linux.id - instance_type = var.environment_instance_type["DEV"] - //instance_type = var.environment_instance_settings["PROD"].instance_type + //instance_type = var.environment_instance_type["DEV"] + instance_type = var.environment_instance_settings[var.deploy_environment].instance_type subnet_id = aws_subnet.subnet1.id vpc_security_group_ids = [aws_security_group.sg-nodejs-instance.id] - monitoring = var.environment_instance_settings["PROD"].monitoring - - tags = {Environment = var.environment_list[0]} + monitoring = var.environment_instance_settings[var.deploy_environment].monitoring + # tags = {Environment = var.environment_list[0]} + tags = {Environment = var.environment_map[var.deploy_environment]} } # ////////////////////////////// diff --git a/02_02-07_variables/main.tf b/02_02-07_variables/main.tf index e2bea6c..ff9d644 100644 --- a/02_02-07_variables/main.tf +++ b/02_02-07_variables/main.tf @@ -182,4 +182,8 @@ data "aws_ami" "aws-linux" { # ////////////////////////////// output "instance-dns" { value = aws_instance.nodejs1.public_dns +} + +output "private-dns" { + value = aws_instance.nodejs1.private_dns } \ No newline at end of file diff --git a/02_08-09_expressions_functions/main.tf b/02_08-09_expressions_functions/main.tf index e2bea6c..a092455 100644 --- a/02_08-09_expressions_functions/main.tf +++ b/02_08-09_expressions_functions/main.tf @@ -6,7 +6,7 @@ variable "aws_access_key" {} variable "aws_secret_key" {} variable "region" { - default = "us-east-2" + default = "us-east-1" } variable "vpc_cidr" { diff --git a/02_10_count/main.tf b/02_10_count/main.tf index f96932b..fecfc6f 100644 --- a/02_10_count/main.tf +++ b/02_10_count/main.tf @@ -10,7 +10,7 @@ variable "iam_accounts" { } variable "region" { - default = "us-east-2" + default = "us-east-1" } variable "vpc_cidr" { @@ -143,8 +143,8 @@ resource "aws_security_group" "sg-nodejs-instance" { } # INSTANCE -resource "aws_instance" "nodejs1" { - //count = 4 +resource "aws_instance" "node_instances" { + count = 4 ami = data.aws_ami.aws-linux.id instance_type = var.environment_instance_settings["PROD"].instance_type @@ -156,7 +156,10 @@ resource "aws_instance" "nodejs1" { tags = {Environment = var.environment_list[0]} } - +resource "aws_iam_user" "iam-users" { + for_each = var.iam_accounts + name = each.key +} # ////////////////////////////// # DATA # ////////////////////////////// @@ -186,5 +189,5 @@ data "aws_ami" "aws-linux" { # OUTPUT # ////////////////////////////// output "instance-dns" { - value = aws_instance.nodejs1.public_dns -} \ No newline at end of file + value = aws_instance.node_instances.*.public_dns +} diff --git a/02_11-12_modules/main.tf b/02_11-12_modules/main.tf index f58a102..010035e 100644 --- a/02_11-12_modules/main.tf +++ b/02_11-12_modules/main.tf @@ -6,7 +6,7 @@ variable "aws_access_key" {} variable "aws_secret_key" {} variable "region" { - default = "us-east-2" + default = "us-east-1" } @@ -64,7 +64,7 @@ module "vpc" { name = "frontend-vpc" cidr = "10.0.0.0/16" - azs = ["us-east-2a", "us-east-2b", "us-east-2c"] + azs = ["us-east-1a", "us-east-1b", "us-east-1c"] private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] diff --git a/03_02-03_remotestate/.terraform.lock.hcl b/03_02-03_remotestate/.terraform.lock.hcl new file mode 100644 index 0000000..abb4dba --- /dev/null +++ b/03_02-03_remotestate/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.39.0" + constraints = ">= 3.73.0" + hashes = [ + "h1:tM2mSfH03Ert/Qd+EUMIavtwjPCM/no91VBH/8vobCE=", + "zh:08e3d453bbeaccda3f4ab7ae45f81d515ab49a765ce2d43f060842bb2e653846", + "zh:238a460231e9e6ca786b2cb2088a98edfc48f0e36c433edd7d65a250980f7566", + "zh:4d5663c2cf521e91caddd5508b13759110bc21b2e9543ff6a9f8cf8d02af1aeb", + "zh:5b397e46aac6db155b4b9162ac168010473d6309ae363301f0335184c1f50be6", + "zh:7178536cfebc6423336798aead72fe774f4d8118ae19ffe6a6a1108fe60608d7", + "zh:867c5269cea2fe15f7ea837507ad0fe97e8913be4348868b284c12217d689457", + "zh:88db4bb188f68011cb05eefb3ea7e5741da1d9acdb3c7bd517e715dfc8c0cfc3", + "zh:95b4da4bdbb2eb02333e52c2ced0c5f133d854f730e3744c0c239268c21feee6", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:9bbe67eaa03bfb293913431b39879385e42473bdb61be842fd78b3c89333f1ba", + "zh:a06b9b5fbe8c84a0da431a22d9dd583143406846c1d8febe06f62fc89aeccd1d", + "zh:cb925338b164e916f289e717f8ecaacf5fd5df56790ec6296158e76d6131b914", + "zh:d9dbf68b0defc220085eda1348f439f724ce83a0636bec18dc83aa73fe2385d5", + "zh:eb59e6234e73bd0d48fe372201155802c9b920711a1da078e5b07508271312ee", + "zh:f68b2685ee86bcf314d74a20e97b5cbe0c63741827143f7a4ba7ec56555329dc", + ] +} diff --git a/03_02-03_remotestate/commands.txt b/03_02-03_remotestate/commands.txt deleted file mode 100644 index 39d0f1c..0000000 --- a/03_02-03_remotestate/commands.txt +++ /dev/null @@ -1,7 +0,0 @@ -terraform init \ - -backend-config="bucket=red30-tfstate" \ - -backend-config="key=red30/ecommerceapp/app.state" \ - -backend-config="region=us-east-2" \ - -backend-config="dynamodb_table=red30-tfstatelock" \ - -backend-config="access_key={ACCESS_KEY}" \ - -backend-config="secret_key={SECRET_KEY}" diff --git a/03_02-03_remotestate/remote_resources/.terraform.lock.hcl b/03_02-03_remotestate/remote_resources/.terraform.lock.hcl new file mode 100644 index 0000000..3ca91b1 --- /dev/null +++ b/03_02-03_remotestate/remote_resources/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.39.0" + hashes = [ + "h1:tM2mSfH03Ert/Qd+EUMIavtwjPCM/no91VBH/8vobCE=", + "zh:08e3d453bbeaccda3f4ab7ae45f81d515ab49a765ce2d43f060842bb2e653846", + "zh:238a460231e9e6ca786b2cb2088a98edfc48f0e36c433edd7d65a250980f7566", + "zh:4d5663c2cf521e91caddd5508b13759110bc21b2e9543ff6a9f8cf8d02af1aeb", + "zh:5b397e46aac6db155b4b9162ac168010473d6309ae363301f0335184c1f50be6", + "zh:7178536cfebc6423336798aead72fe774f4d8118ae19ffe6a6a1108fe60608d7", + "zh:867c5269cea2fe15f7ea837507ad0fe97e8913be4348868b284c12217d689457", + "zh:88db4bb188f68011cb05eefb3ea7e5741da1d9acdb3c7bd517e715dfc8c0cfc3", + "zh:95b4da4bdbb2eb02333e52c2ced0c5f133d854f730e3744c0c239268c21feee6", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:9bbe67eaa03bfb293913431b39879385e42473bdb61be842fd78b3c89333f1ba", + "zh:a06b9b5fbe8c84a0da431a22d9dd583143406846c1d8febe06f62fc89aeccd1d", + "zh:cb925338b164e916f289e717f8ecaacf5fd5df56790ec6296158e76d6131b914", + "zh:d9dbf68b0defc220085eda1348f439f724ce83a0636bec18dc83aa73fe2385d5", + "zh:eb59e6234e73bd0d48fe372201155802c9b920711a1da078e5b07508271312ee", + "zh:f68b2685ee86bcf314d74a20e97b5cbe0c63741827143f7a4ba7ec56555329dc", + ] +} diff --git a/03_02-03_remotestate/remote_resources/s3_backend.tf b/03_02-03_remotestate/remote_resources/s3_backend.tf index 0f0f424..087fd46 100644 --- a/03_02-03_remotestate/remote_resources/s3_backend.tf +++ b/03_02-03_remotestate/remote_resources/s3_backend.tf @@ -6,7 +6,7 @@ variable "aws_access_key" {} variable "aws_secret_key" {} variable "bucket_name" { - default = "red30-tfstate" + default = "red30-tfstate-dammngood" } # ////////////////////////////// diff --git a/03_05-06_multi_environment/manifests/variables.tf b/03_05-06_multi_environment/manifests/variables.tf index 3566d6b..abaf1cd 100644 --- a/03_05-06_multi_environment/manifests/variables.tf +++ b/03_05-06_multi_environment/manifests/variables.tf @@ -6,7 +6,7 @@ variable "aws_access_key" {} variable "aws_secret_key" {} variable "region" { - default = "us-east-2" + default = "us-east-1" } variable env_instance_type {} diff --git a/03_05-06_multi_environment/manifests/vpc.tf b/03_05-06_multi_environment/manifests/vpc.tf index b13155f..288a86c 100644 --- a/03_05-06_multi_environment/manifests/vpc.tf +++ b/03_05-06_multi_environment/manifests/vpc.tf @@ -6,7 +6,7 @@ module "vpc" { name = "frontend-vpc" cidr = "10.0.0.0/16" - azs = ["us-east-2a", "us-east-2b", "us-east-2c"] + azs = ["us-east-1a", "us-east-1b", "us-east-1c"] private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] diff --git a/03_07_custommodule/modules/nodejs-instance/variables.tf b/03_07_custommodule/modules/nodejs-instance/variables.tf index 33e5c84..318fdd1 100644 --- a/03_07_custommodule/modules/nodejs-instance/variables.tf +++ b/03_07_custommodule/modules/nodejs-instance/variables.tf @@ -1,6 +1,6 @@ variable "ami_id" { description = "The ID of the NodeJS AMI to deploy" - default = "ami-6685a403" + default = "ami-089a545a9ed9893b6" } variable instance_count { diff --git a/04_04_terraform_cloud_cli/backend.tf b/04_04_terraform_cloud_cli/backend.tf index 1119b39..5da0393 100644 --- a/04_04_terraform_cloud_cli/backend.tf +++ b/04_04_terraform_cloud_cli/backend.tf @@ -1,6 +1,6 @@ terraform { backend "remote" { - organization = "red30" + organization = "red30systems" workspaces { name = "cli-workspace" diff --git a/04_05_terraform_cloud_vcs/variables.tf b/04_05_terraform_cloud_vcs/variables.tf index 06a0e24..003d79d 100644 --- a/04_05_terraform_cloud_vcs/variables.tf +++ b/04_05_terraform_cloud_vcs/variables.tf @@ -17,7 +17,7 @@ variable "instance_count" { variable "instance_tags" { type = map default = { - "environment" = "dev" + "environment" = "staging" } } # //////////////////////////////