├── level_11 ├── dev │ ├── compute │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── providers.tf │ ├── variables.tf │ ├── versions.tf │ ├── data │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── main.tf │ ├── data_variables.tf │ ├── compute_variables.tf │ ├── main.tf │ └── dev.tfvars ├── hml │ ├── compute │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── providers.tf │ ├── variables.tf │ ├── versions.tf │ ├── data │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── main.tf │ ├── data_variables.tf │ ├── compute_variables.tf │ ├── main.tf │ └── hml.tfvars ├── prd │ ├── compute │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── main.tf │ │ └── variables.tf │ ├── providers.tf │ ├── variables.tf │ ├── versions.tf │ ├── data │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── variables.tf │ │ └── main.tf │ ├── data_variables.tf │ ├── compute_variables.tf │ ├── main.tf │ └── prd.tfvars └── modules │ ├── ec2 │ ├── outputs.tf │ ├── versions.tf │ ├── variables.tf │ └── main.tf │ └── s3 │ ├── versions.tf │ ├── outputs.tf │ ├── main.tf │ └── variables.tf ├── level_5 ├── s3_module.tfvars ├── providers.tf ├── variables.tf ├── versions.tf ├── modules │ ├── versions.tf │ ├── outputs.tf │ ├── main.tf │ └── variables.tf └── main.tf ├── level_2 ├── providers.tf ├── versions.tf ├── main.tf └── variables.tf ├── level_3 ├── providers.tf ├── versions.tf ├── s3.tfvars ├── main.tf └── variables.tf ├── level_4 ├── providers.tf ├── versions.tf ├── s3.tfvars ├── outputs.tf ├── main.tf └── variables.tf ├── level_6 ├── providers.tf ├── versions.tf ├── modules │ ├── versions.tf │ ├── outputs.tf │ ├── main.tf │ └── variables.tf ├── outputs.tf ├── s3_module.tfvars ├── main.tf └── variables.tf ├── level_7 ├── providers.tf ├── modules │ ├── ec2 │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ └── s3 │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── main.tf │ │ └── variables.tf ├── versions.tf ├── multiple_modules.tfvars ├── outputs.tf ├── main.tf └── variables.tf ├── level_8 ├── providers.tf ├── modules │ ├── ec2 │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ └── s3 │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── main.tf │ │ └── variables.tf ├── versions.tf ├── multiple_modules.tfvars ├── outputs.tf ├── main.tf └── variables.tf ├── level_9 ├── providers.tf ├── modules │ ├── ec2 │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ └── s3 │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── main.tf │ │ └── variables.tf ├── versions.tf ├── outputs.tf ├── multiple_modules.tfvars ├── main.tf └── variables.tf ├── level_1 ├── providers.tf ├── versions.tf └── main.tf ├── level_10 ├── providers.tf ├── modules │ ├── ec2 │ │ ├── outputs.tf │ │ ├── versions.tf │ │ ├── variables.tf │ │ └── main.tf │ └── s3 │ │ ├── versions.tf │ │ ├── outputs.tf │ │ ├── main.tf │ │ └── variables.tf ├── versions.tf ├── outputs.tf ├── multiple_modules.tfvars ├── variables.tf └── main.tf ├── .gitignore ├── README.md ├── .pre-commit-config.yaml └── LICENSE /level_11/dev/compute/outputs.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /level_11/hml/compute/outputs.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /level_11/prd/compute/outputs.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /level_5/s3_module.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" -------------------------------------------------------------------------------- /level_2/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_3/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_4/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_5/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_6/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_7/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_8/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_9/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_1/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = "us-east-1" 3 | } -------------------------------------------------------------------------------- /level_10/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_11/dev/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_11/hml/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_11/prd/providers.tf: -------------------------------------------------------------------------------- 1 | provider "aws" { 2 | region = var.region 3 | } -------------------------------------------------------------------------------- /level_11/dev/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | } -------------------------------------------------------------------------------- /level_11/hml/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | } -------------------------------------------------------------------------------- /level_11/prd/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | } -------------------------------------------------------------------------------- /level_5/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } -------------------------------------------------------------------------------- /level_10/modules/ec2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "instance_id" { 2 | description = "EC2 instance id." 3 | value = aws_instance.level_10.id 4 | } -------------------------------------------------------------------------------- /level_11/modules/ec2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "instance_id" { 2 | description = "EC2 instance id." 3 | value = aws_instance.level_11.id 4 | } -------------------------------------------------------------------------------- /level_7/modules/ec2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "instance_id" { 2 | description = "EC2 instance id." 3 | value = aws_instance.level_7.id 4 | } -------------------------------------------------------------------------------- /level_8/modules/ec2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "instance_id" { 2 | description = "EC2 instance id." 3 | value = aws_instance.level_8.id 4 | } -------------------------------------------------------------------------------- /level_9/modules/ec2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "instance_id" { 2 | description = "EC2 instance id." 3 | value = aws_instance.level_9.id 4 | } -------------------------------------------------------------------------------- /level_1/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_10/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_4/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_5/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_6/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_7/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_8/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_9/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/dev/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/hml/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/prd/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = "~> 3.0" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/dev/data/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/hml/data/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/prd/data/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_5/modules/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_6/modules/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_10/modules/ec2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_10/modules/s3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/dev/compute/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/hml/compute/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/modules/ec2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/modules/s3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_11/prd/compute/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_7/modules/ec2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_7/modules/s3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_8/modules/ec2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_8/modules/s3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_9/modules/ec2/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_9/modules/s3/versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14" 3 | 4 | required_providers { 5 | aws = { 6 | source = "hashicorp/aws" 7 | version = ">= 3.15" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /level_7/modules/ec2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } -------------------------------------------------------------------------------- /level_6/outputs.tf: -------------------------------------------------------------------------------- 1 | output "s3_bucket_name" { 2 | description = "S3 bucket name." 3 | value = module.s3.bucket_name 4 | } 5 | 6 | output "s3_bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = module.s3.bucket_arn 9 | } -------------------------------------------------------------------------------- /level_5/modules/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_5.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_5.arn 9 | } -------------------------------------------------------------------------------- /level_6/modules/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_6.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_6.arn 9 | } -------------------------------------------------------------------------------- /level_10/modules/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_10.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_10.arn 9 | } -------------------------------------------------------------------------------- /level_11/modules/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_11.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_11.arn 9 | } -------------------------------------------------------------------------------- /level_3/s3.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | bucket_name = "my-level-3-bucket" 3 | block_public_acls = true 4 | block_public_policy = true 5 | ignore_public_acls = true 6 | restrict_public_buckets = true 7 | 8 | 9 | -------------------------------------------------------------------------------- /level_4/s3.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | bucket_name = "my-level-4-bucket" 3 | block_public_acls = true 4 | block_public_policy = true 5 | ignore_public_acls = true 6 | restrict_public_buckets = true 7 | 8 | 9 | -------------------------------------------------------------------------------- /level_7/modules/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_7.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_7.arn 9 | } -------------------------------------------------------------------------------- /level_8/modules/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_8.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_8.arn 9 | } -------------------------------------------------------------------------------- /level_9/modules/s3/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_9.id 4 | } 5 | 6 | output "bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = aws_s3_bucket.level_9.arn 9 | } -------------------------------------------------------------------------------- /level_4/outputs.tf: -------------------------------------------------------------------------------- 1 | output "bucket_name" { 2 | description = "S3 bucket name." 3 | value = aws_s3_bucket.level_4.id 4 | } 5 | 6 | 7 | output "bucket_arn" { 8 | description = "S3 bucket ARN." 9 | value = aws_s3_bucket.level_4.arn 10 | } -------------------------------------------------------------------------------- /level_6/s3_module.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | s3_bucket_name = "my-level-6-bucket" 3 | s3_block_public_acls = true 4 | s3_block_public_policy = true 5 | s3_ignore_public_acls = true 6 | s3_restrict_public_buckets = true -------------------------------------------------------------------------------- /level_5/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/" 3 | bucket_name = "my-level-5-bucket" 4 | block_public_acls = true 5 | block_public_policy = true 6 | ignore_public_acls = true 7 | restrict_public_buckets = true 8 | } -------------------------------------------------------------------------------- /level_11/dev/data/outputs.tf: -------------------------------------------------------------------------------- 1 | output "data_s3_bucket_names" { 2 | description = "S3 bucket name." 3 | value = [for i in module.s3 : i.bucket_name] 4 | } 5 | 6 | output "data_s3_bucket_arns" { 7 | description = "S3 bucket ARN." 8 | value = [for i in module.s3 : i.bucket_arn] 9 | } -------------------------------------------------------------------------------- /level_11/hml/data/outputs.tf: -------------------------------------------------------------------------------- 1 | output "data_s3_bucket_names" { 2 | description = "S3 bucket name." 3 | value = [for i in module.s3 : i.bucket_name] 4 | } 5 | 6 | output "data_s3_bucket_arns" { 7 | description = "S3 bucket ARN." 8 | value = [for i in module.s3 : i.bucket_arn] 9 | } -------------------------------------------------------------------------------- /level_11/prd/data/outputs.tf: -------------------------------------------------------------------------------- 1 | output "data_s3_bucket_names" { 2 | description = "S3 bucket name." 3 | value = [for i in module.s3 : i.bucket_name] 4 | } 5 | 6 | output "data_s3_bucket_arns" { 7 | description = "S3 bucket ARN." 8 | value = [for i in module.s3 : i.bucket_arn] 9 | } -------------------------------------------------------------------------------- /level_11/dev/compute/main.tf: -------------------------------------------------------------------------------- 1 | module "ec2" { 2 | source = "../../modules/ec2/" 3 | instance_type = var.compute_ec2_instance_type 4 | instance_name = var.compute_ec2_instance_name 5 | instance_subnet_id = var.compute_ec2_instance_subnet_id 6 | bucket_arns = var.data_s3_bucket_arns 7 | } -------------------------------------------------------------------------------- /level_11/hml/compute/main.tf: -------------------------------------------------------------------------------- 1 | module "ec2" { 2 | source = "../../modules/ec2/" 3 | instance_type = var.compute_ec2_instance_type 4 | instance_name = var.compute_ec2_instance_name 5 | instance_subnet_id = var.compute_ec2_instance_subnet_id 6 | bucket_arns = var.data_s3_bucket_arns 7 | } -------------------------------------------------------------------------------- /level_11/prd/compute/main.tf: -------------------------------------------------------------------------------- 1 | module "ec2" { 2 | source = "../../modules/ec2/" 3 | instance_type = var.compute_ec2_instance_type 4 | instance_name = var.compute_ec2_instance_name 5 | instance_subnet_id = var.compute_ec2_instance_subnet_id 6 | bucket_arns = var.data_s3_bucket_arns 7 | } -------------------------------------------------------------------------------- /level_11/dev/data/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_11/dev/data_variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_11/hml/data/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_11/hml/data_variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_11/prd/data/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_11/prd/data_variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_buckets" { 2 | description = "List of S3 buckets." 3 | type = map(object({ 4 | bucket_name = string 5 | block_public_acls = bool 6 | block_public_policy = bool 7 | ignore_public_acls = bool 8 | restrict_public_buckets = bool 9 | })) 10 | } -------------------------------------------------------------------------------- /level_6/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/" 3 | bucket_name = var.s3_bucket_name 4 | block_public_acls = var.s3_block_public_acls 5 | block_public_policy = var.s3_block_public_policy 6 | ignore_public_acls = var.s3_ignore_public_acls 7 | restrict_public_buckets = var.s3_restrict_public_buckets 8 | } -------------------------------------------------------------------------------- /level_7/multiple_modules.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | s3_bucket_name = "my-level-7-bucket" 3 | s3_block_public_acls = true 4 | s3_block_public_policy = true 5 | s3_ignore_public_acls = true 6 | s3_restrict_public_buckets = true 7 | ec2_instance_name = "EC2_Level_7" 8 | ec2_instance_type = "t3.micro" -------------------------------------------------------------------------------- /level_8/multiple_modules.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | s3_bucket_name = "my-level-8-bucket" 3 | s3_block_public_acls = true 4 | s3_block_public_policy = true 5 | s3_ignore_public_acls = true 6 | s3_restrict_public_buckets = true 7 | ec2_instance_name = "EC2_Level_8" 8 | ec2_instance_type = "t3.micro" -------------------------------------------------------------------------------- /level_1/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_1" { 2 | bucket = "my-level-1-bucket" 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_1" { 6 | bucket = aws_s3_bucket.level_1.id 7 | block_public_acls = true 8 | block_public_policy = true 9 | ignore_public_acls = true 10 | restrict_public_buckets = true 11 | } -------------------------------------------------------------------------------- /level_7/outputs.tf: -------------------------------------------------------------------------------- 1 | output "s3_bucket_name" { 2 | description = "S3 bucket name." 3 | value = module.s3.bucket_name 4 | } 5 | 6 | output "s3_bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = module.s3.bucket_arn 9 | } 10 | 11 | output "ec2_instance_id" { 12 | description = "EC2 instance id." 13 | value = module.ec2.instance_id 14 | } -------------------------------------------------------------------------------- /level_8/outputs.tf: -------------------------------------------------------------------------------- 1 | output "s3_bucket_name" { 2 | description = "S3 bucket name." 3 | value = module.s3.bucket_name 4 | } 5 | 6 | output "s3_bucket_arn" { 7 | description = "S3 bucket ARN." 8 | value = module.s3.bucket_arn 9 | } 10 | 11 | output "ec2_instance_id" { 12 | description = "EC2 instance id." 13 | value = module.ec2.instance_id 14 | } -------------------------------------------------------------------------------- /level_8/modules/ec2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "bucket_arn" { 12 | description = "S3 bucket ARN for Read Only Access IAM Policy." 13 | type = string 14 | } -------------------------------------------------------------------------------- /level_10/modules/ec2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "bucket_arns" { 12 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 13 | type = list(string) 14 | } -------------------------------------------------------------------------------- /level_9/modules/ec2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "bucket_arns" { 12 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 13 | type = list(string) 14 | } -------------------------------------------------------------------------------- /level_11/dev/compute_variables.tf: -------------------------------------------------------------------------------- 1 | variable "compute_ec2_instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "compute_ec2_instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_subnet_id" { 12 | description = "EC2 subnet ID." 13 | type = string 14 | } -------------------------------------------------------------------------------- /level_11/hml/compute_variables.tf: -------------------------------------------------------------------------------- 1 | variable "compute_ec2_instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "compute_ec2_instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_subnet_id" { 12 | description = "EC2 subnet ID." 13 | type = string 14 | } -------------------------------------------------------------------------------- /level_11/prd/compute_variables.tf: -------------------------------------------------------------------------------- 1 | variable "compute_ec2_instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "compute_ec2_instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_subnet_id" { 12 | description = "EC2 subnet ID." 13 | type = string 14 | } -------------------------------------------------------------------------------- /level_10/outputs.tf: -------------------------------------------------------------------------------- 1 | output "s3_bucket_names" { 2 | description = "S3 bucket name." 3 | value = [for i in module.s3 : i.bucket_name] 4 | } 5 | 6 | output "s3_bucket_arns" { 7 | description = "S3 bucket ARN." 8 | value = [for i in module.s3 : i.bucket_arn] 9 | } 10 | 11 | output "ec2_instance_id" { 12 | description = "EC2 instance id." 13 | value = module.ec2.instance_id 14 | } -------------------------------------------------------------------------------- /level_9/outputs.tf: -------------------------------------------------------------------------------- 1 | output "s3_bucket_names" { 2 | description = "S3 bucket name." 3 | value = [for i in module.s3 : i.bucket_name] 4 | } 5 | 6 | output "s3_bucket_arns" { 7 | description = "S3 bucket ARN." 8 | value = [for i in module.s3 : i.bucket_arn] 9 | } 10 | 11 | output "ec2_instance_id" { 12 | description = "EC2 instance id." 13 | value = module.ec2.instance_id 14 | } -------------------------------------------------------------------------------- /level_2/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_2" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_2" { 6 | bucket = aws_s3_bucket.level_2.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_3" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_3" { 6 | bucket = aws_s3_bucket.level_3.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_4/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_4" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_4" { 6 | bucket = aws_s3_bucket.level_4.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_5/modules/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_5" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_5" { 6 | bucket = aws_s3_bucket.level_5.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_6/modules/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_6" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_6" { 6 | bucket = aws_s3_bucket.level_6.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_9/multiple_modules.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | s3_bucket_names = ["my-level-9-bucket", "my-level-9-bucket-2", "my-level-9-bucket-3", "my-level-9-bucket-4", "my-level-9-bucket-5"] 3 | s3_block_public_acls = true 4 | s3_block_public_policy = true 5 | s3_ignore_public_acls = true 6 | s3_restrict_public_buckets = true 7 | ec2_instance_name = "EC2_Level_9" 8 | ec2_instance_type = "t3.micro" -------------------------------------------------------------------------------- /level_10/modules/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_10" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_10" { 6 | bucket = aws_s3_bucket.level_10.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_11/modules/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_11" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_11" { 6 | bucket = aws_s3_bucket.level_11.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_7/modules/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_7" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_7" { 6 | bucket = aws_s3_bucket.level_7.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_8/modules/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_8" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_8" { 6 | bucket = aws_s3_bucket.level_8.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_9/modules/s3/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_s3_bucket" "level_9" { 2 | bucket = var.bucket_name 3 | } 4 | 5 | resource "aws_s3_bucket_public_access_block" "level_9" { 6 | bucket = aws_s3_bucket.level_9.id 7 | block_public_acls = var.block_public_acls 8 | block_public_policy = var.block_public_policy 9 | ignore_public_acls = var.ignore_public_acls 10 | restrict_public_buckets = var.restrict_public_buckets 11 | } -------------------------------------------------------------------------------- /level_11/dev/data/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "../../modules/s3/" 3 | for_each = var.data_s3_buckets 4 | bucket_name = each.value.bucket_name 5 | block_public_acls = try(each.value.block_public_acls, true) 6 | block_public_policy = try(each.value.block_public_policy, true) 7 | ignore_public_acls = try(each.value.ignore_public_acls, true) 8 | restrict_public_buckets = try(each.value.restrict_public_buckets, true) 9 | } -------------------------------------------------------------------------------- /level_11/dev/main.tf: -------------------------------------------------------------------------------- 1 | module "data" { 2 | source = "./data/" 3 | data_s3_buckets = var.data_s3_buckets 4 | } 5 | 6 | module "compute" { 7 | source = "./compute/" 8 | compute_ec2_instance_type = var.compute_ec2_instance_type 9 | compute_ec2_instance_name = var.compute_ec2_instance_name 10 | compute_ec2_instance_subnet_id = var.compute_ec2_instance_subnet_id 11 | data_s3_bucket_arns = module.data.data_s3_bucket_arns 12 | } -------------------------------------------------------------------------------- /level_11/hml/data/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "../../modules/s3/" 3 | for_each = var.data_s3_buckets 4 | bucket_name = each.value.bucket_name 5 | block_public_acls = try(each.value.block_public_acls, true) 6 | block_public_policy = try(each.value.block_public_policy, true) 7 | ignore_public_acls = try(each.value.ignore_public_acls, true) 8 | restrict_public_buckets = try(each.value.restrict_public_buckets, true) 9 | } -------------------------------------------------------------------------------- /level_11/hml/main.tf: -------------------------------------------------------------------------------- 1 | module "data" { 2 | source = "./data/" 3 | data_s3_buckets = var.data_s3_buckets 4 | } 5 | 6 | module "compute" { 7 | source = "./compute/" 8 | compute_ec2_instance_type = var.compute_ec2_instance_type 9 | compute_ec2_instance_name = var.compute_ec2_instance_name 10 | compute_ec2_instance_subnet_id = var.compute_ec2_instance_subnet_id 11 | data_s3_bucket_arns = module.data.data_s3_bucket_arns 12 | } -------------------------------------------------------------------------------- /level_11/prd/data/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "../../modules/s3/" 3 | for_each = var.data_s3_buckets 4 | bucket_name = each.value.bucket_name 5 | block_public_acls = try(each.value.block_public_acls, true) 6 | block_public_policy = try(each.value.block_public_policy, true) 7 | ignore_public_acls = try(each.value.ignore_public_acls, true) 8 | restrict_public_buckets = try(each.value.restrict_public_buckets, true) 9 | } -------------------------------------------------------------------------------- /level_11/prd/main.tf: -------------------------------------------------------------------------------- 1 | module "data" { 2 | source = "./data/" 3 | data_s3_buckets = var.data_s3_buckets 4 | } 5 | 6 | module "compute" { 7 | source = "./compute/" 8 | compute_ec2_instance_type = var.compute_ec2_instance_type 9 | compute_ec2_instance_name = var.compute_ec2_instance_name 10 | compute_ec2_instance_subnet_id = var.compute_ec2_instance_subnet_id 11 | data_s3_bucket_arns = module.data.data_s3_bucket_arns 12 | } -------------------------------------------------------------------------------- /level_11/modules/ec2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "instance_name" { 2 | description = "EC2 instance name." 3 | type = string 4 | } 5 | 6 | variable "instance_type" { 7 | description = "EC2 instance type." 8 | type = string 9 | } 10 | 11 | variable "instance_subnet_id" { 12 | description = "EC2 subnet ID." 13 | type = string 14 | } 15 | 16 | variable "bucket_arns" { 17 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 18 | type = list(string) 19 | } -------------------------------------------------------------------------------- /level_7/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/s3/" 3 | bucket_name = var.s3_bucket_name 4 | block_public_acls = var.s3_block_public_acls 5 | block_public_policy = var.s3_block_public_policy 6 | ignore_public_acls = var.s3_ignore_public_acls 7 | restrict_public_buckets = var.s3_restrict_public_buckets 8 | } 9 | 10 | module "ec2" { 11 | source = "./modules/ec2/" 12 | instance_type = var.ec2_instance_type 13 | instance_name = var.ec2_instance_name 14 | } -------------------------------------------------------------------------------- /level_11/dev/compute/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_bucket_arns" { 2 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 3 | type = list(string) 4 | } 5 | 6 | variable "compute_ec2_instance_name" { 7 | description = "EC2 instance name." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_type" { 12 | description = "EC2 instance type." 13 | type = string 14 | } 15 | 16 | variable "compute_ec2_instance_subnet_id" { 17 | description = "EC2 subnet ID." 18 | type = string 19 | } -------------------------------------------------------------------------------- /level_11/hml/compute/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_bucket_arns" { 2 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 3 | type = list(string) 4 | } 5 | 6 | variable "compute_ec2_instance_name" { 7 | description = "EC2 instance name." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_type" { 12 | description = "EC2 instance type." 13 | type = string 14 | } 15 | 16 | variable "compute_ec2_instance_subnet_id" { 17 | description = "EC2 subnet ID." 18 | type = string 19 | } -------------------------------------------------------------------------------- /level_11/prd/compute/variables.tf: -------------------------------------------------------------------------------- 1 | variable "data_s3_bucket_arns" { 2 | description = "S3 bucket ARNs for Read Only Access IAM Policy." 3 | type = list(string) 4 | } 5 | 6 | variable "compute_ec2_instance_name" { 7 | description = "EC2 instance name." 8 | type = string 9 | } 10 | 11 | variable "compute_ec2_instance_type" { 12 | description = "EC2 instance type." 13 | type = string 14 | } 15 | 16 | variable "compute_ec2_instance_subnet_id" { 17 | description = "EC2 subnet ID." 18 | type = string 19 | } -------------------------------------------------------------------------------- /level_8/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/s3/" 3 | bucket_name = var.s3_bucket_name 4 | block_public_acls = var.s3_block_public_acls 5 | block_public_policy = var.s3_block_public_policy 6 | ignore_public_acls = var.s3_ignore_public_acls 7 | restrict_public_buckets = var.s3_restrict_public_buckets 8 | } 9 | 10 | module "ec2" { 11 | source = "./modules/ec2/" 12 | instance_type = var.ec2_instance_type 13 | instance_name = var.ec2_instance_name 14 | bucket_arn = module.s3.bucket_arn 15 | } -------------------------------------------------------------------------------- /level_9/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/s3/" 3 | for_each = toset(var.s3_bucket_names) 4 | bucket_name = each.key 5 | block_public_acls = var.s3_block_public_acls 6 | block_public_policy = var.s3_block_public_policy 7 | ignore_public_acls = var.s3_ignore_public_acls 8 | restrict_public_buckets = var.s3_restrict_public_buckets 9 | } 10 | 11 | module "ec2" { 12 | source = "./modules/ec2/" 13 | instance_type = var.ec2_instance_type 14 | instance_name = var.ec2_instance_name 15 | bucket_arns = [for i in module.s3 : i.bucket_arn] 16 | } -------------------------------------------------------------------------------- /level_10/multiple_modules.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-2" 2 | ec2_instance_name = "EC2_Level_10" 3 | ec2_instance_type = "t3.micro" 4 | 5 | 6 | s3_buckets = { 7 | "level-10" = { 8 | bucket_name = "my-bucket-level-10" 9 | block_public_acls = false 10 | block_public_policy = false 11 | ignore_public_acls = true 12 | restrict_public_buckets = true 13 | }, 14 | "level-10-2" = { 15 | bucket_name = "my-bucket-level-10-2" 16 | block_public_acls = false 17 | block_public_policy = false 18 | ignore_public_acls = true 19 | restrict_public_buckets = true 20 | } 21 | } -------------------------------------------------------------------------------- /level_10/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "ec2_instance_name" { 8 | description = "EC2 instance name." 9 | type = string 10 | } 11 | 12 | variable "s3_buckets" { 13 | description = "List of S3 buckets." 14 | type = map(object({ 15 | bucket_name = string 16 | block_public_acls = bool 17 | block_public_policy = bool 18 | ignore_public_acls = bool 19 | restrict_public_buckets = bool 20 | })) 21 | } 22 | 23 | variable "ec2_instance_type" { 24 | description = "EC2 instance type." 25 | type = string 26 | } -------------------------------------------------------------------------------- /level_10/main.tf: -------------------------------------------------------------------------------- 1 | module "s3" { 2 | source = "./modules/s3/" 3 | for_each = var.s3_buckets 4 | bucket_name = each.value.bucket_name 5 | block_public_acls = try(each.value.block_public_acls, true) 6 | block_public_policy = try(each.value.block_public_policy, true) 7 | ignore_public_acls = try(each.value.ignore_public_acls, true) 8 | restrict_public_buckets = try(each.value.restrict_public_buckets, true) 9 | } 10 | 11 | module "ec2" { 12 | source = "./modules/ec2/" 13 | instance_type = var.ec2_instance_type 14 | instance_name = var.ec2_instance_name 15 | bucket_arns = [for i in module.s3 : i.bucket_arn] 16 | } -------------------------------------------------------------------------------- /level_11/dev/dev.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-1" 2 | 3 | compute_ec2_instance_name = "EC2_Level_11_DEV" 4 | compute_ec2_instance_type = "t3.micro" 5 | compute_ec2_instance_subnet_id = "subnet-123456789abcd" 6 | 7 | data_s3_buckets = { 8 | "level-11" = { 9 | bucket_name = "my-bucket-level-11-dev" 10 | block_public_acls = false 11 | block_public_policy = false 12 | ignore_public_acls = true 13 | restrict_public_buckets = true 14 | }, 15 | "level-11-2" = { 16 | bucket_name = "my-bucket-level-11-2-dev" 17 | block_public_acls = false 18 | block_public_policy = false 19 | ignore_public_acls = true 20 | restrict_public_buckets = true 21 | } 22 | } -------------------------------------------------------------------------------- /level_11/hml/hml.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-1" 2 | 3 | compute_ec2_instance_name = "EC2_Level_11_HML" 4 | compute_ec2_instance_type = "t3.micro" 5 | compute_ec2_instance_subnet_id = "subnet-123456789abcd" 6 | 7 | data_s3_buckets = { 8 | "level-11" = { 9 | bucket_name = "my-bucket-level-11-hml" 10 | block_public_acls = false 11 | block_public_policy = false 12 | ignore_public_acls = true 13 | restrict_public_buckets = true 14 | }, 15 | "level-11-2" = { 16 | bucket_name = "my-bucket-level-11-2-hml" 17 | block_public_acls = false 18 | block_public_policy = false 19 | ignore_public_acls = true 20 | restrict_public_buckets = true 21 | } 22 | } -------------------------------------------------------------------------------- /level_11/prd/prd.tfvars: -------------------------------------------------------------------------------- 1 | region = "us-east-1" 2 | 3 | compute_ec2_instance_name = "EC2_Level_11_PRD" 4 | compute_ec2_instance_type = "t3.micro" 5 | compute_ec2_instance_subnet_id = "subnet-123456789abcd" 6 | 7 | data_s3_buckets = { 8 | "level-11" = { 9 | bucket_name = "my-bucket-level-11-prd" 10 | block_public_acls = false 11 | block_public_policy = false 12 | ignore_public_acls = true 13 | restrict_public_buckets = true 14 | }, 15 | "level-11-2" = { 16 | bucket_name = "my-bucket-level-11-2-prd" 17 | block_public_acls = false 18 | block_public_policy = false 19 | ignore_public_acls = true 20 | restrict_public_buckets = true 21 | } 22 | } -------------------------------------------------------------------------------- /level_5/modules/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_6/modules/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_10/modules/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_11/modules/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_7/modules/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_8/modules/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /level_9/modules/s3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "bucket_name" { 2 | description = "S3 bucket name." 3 | type = string 4 | } 5 | 6 | variable "block_public_acls" { 7 | description = "Whether Amazon S3 should block public ACLs for this bucket." 8 | type = bool 9 | } 10 | variable "block_public_policy" { 11 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 12 | type = bool 13 | } 14 | 15 | variable "ignore_public_acls" { 16 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 17 | type = bool 18 | } 19 | variable "restrict_public_buckets" { 20 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 21 | type = bool 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | 8 | # Crash log files 9 | crash.log 10 | .terraform.* 11 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most 12 | # .tfvars files are managed as part of configuration and so should be included in 13 | # version control. 14 | # 15 | # example.tfvars 16 | 17 | # Ignore override files as they are usually used to override resources locally and so 18 | # are not checked in 19 | override.tf 20 | override.tf.json 21 | *_override.tf 22 | *_override.tf.json 23 | 24 | # Include override files you do wish to add to version control using negated pattern 25 | # 26 | # !example_override.tf 27 | 28 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan 29 | # example: *tfplan* 30 | -------------------------------------------------------------------------------- /level_3/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "bucket_name" { 8 | description = "S3 bucket name." 9 | type = string 10 | } 11 | 12 | variable "block_public_acls" { 13 | description = "Whether Amazon S3 should block public ACLs for this bucket." 14 | type = bool 15 | } 16 | variable "block_public_policy" { 17 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 18 | type = bool 19 | } 20 | 21 | variable "ignore_public_acls" { 22 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 23 | type = bool 24 | } 25 | variable "restrict_public_buckets" { 26 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 27 | type = bool 28 | } 29 | -------------------------------------------------------------------------------- /level_4/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "bucket_name" { 8 | description = "S3 bucket name." 9 | type = string 10 | } 11 | 12 | variable "block_public_acls" { 13 | description = "Whether Amazon S3 should block public ACLs for this bucket." 14 | type = bool 15 | } 16 | variable "block_public_policy" { 17 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 18 | type = bool 19 | } 20 | 21 | variable "ignore_public_acls" { 22 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 23 | type = bool 24 | } 25 | variable "restrict_public_buckets" { 26 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 27 | type = bool 28 | } 29 | -------------------------------------------------------------------------------- /level_6/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "s3_block_public_acls" { 8 | description = "Whether Amazon S3 should block public ACLs for this bucket." 9 | type = bool 10 | } 11 | variable "s3_block_public_policy" { 12 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 13 | type = bool 14 | } 15 | 16 | variable "s3_ignore_public_acls" { 17 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 18 | type = bool 19 | } 20 | variable "s3_restrict_public_buckets" { 21 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 22 | type = bool 23 | } 24 | 25 | variable "s3_bucket_name" { 26 | description = "S3 bucket name." 27 | type = string 28 | } -------------------------------------------------------------------------------- /level_2/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "bucket_name" { 8 | description = "S3 bucket name." 9 | type = string 10 | default = "my-level-2-bucket" 11 | } 12 | 13 | variable "block_public_acls" { 14 | description = "Whether Amazon S3 should block public ACLs for this bucket." 15 | type = bool 16 | default = true 17 | } 18 | variable "block_public_policy" { 19 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 20 | type = bool 21 | default = true 22 | } 23 | 24 | variable "ignore_public_acls" { 25 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 26 | type = bool 27 | default = true 28 | } 29 | variable "restrict_public_buckets" { 30 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 31 | type = bool 32 | default = true 33 | } 34 | -------------------------------------------------------------------------------- /level_7/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "s3_block_public_acls" { 8 | description = "Whether Amazon S3 should block public ACLs for this bucket." 9 | type = bool 10 | } 11 | variable "s3_block_public_policy" { 12 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 13 | type = bool 14 | } 15 | 16 | variable "s3_ignore_public_acls" { 17 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 18 | type = bool 19 | } 20 | variable "s3_restrict_public_buckets" { 21 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 22 | type = bool 23 | } 24 | 25 | variable "s3_bucket_name" { 26 | description = "S3 bucket name." 27 | type = string 28 | } 29 | 30 | 31 | variable "ec2_instance_name" { 32 | description = "EC2 instance name." 33 | type = string 34 | } 35 | 36 | variable "ec2_instance_type" { 37 | description = "EC2 instance type." 38 | type = string 39 | } -------------------------------------------------------------------------------- /level_8/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "s3_block_public_acls" { 8 | description = "Whether Amazon S3 should block public ACLs for this bucket." 9 | type = bool 10 | } 11 | variable "s3_block_public_policy" { 12 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 13 | type = bool 14 | } 15 | 16 | variable "s3_ignore_public_acls" { 17 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 18 | type = bool 19 | } 20 | variable "s3_restrict_public_buckets" { 21 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 22 | type = bool 23 | } 24 | 25 | variable "s3_bucket_name" { 26 | description = "S3 bucket name." 27 | type = string 28 | } 29 | 30 | 31 | variable "ec2_instance_name" { 32 | description = "EC2 instance name." 33 | type = string 34 | } 35 | 36 | variable "ec2_instance_type" { 37 | description = "EC2 instance type." 38 | type = string 39 | } -------------------------------------------------------------------------------- /level_9/variables.tf: -------------------------------------------------------------------------------- 1 | variable "region" { 2 | description = "AWS region." 3 | type = string 4 | default = "us-east-1" 5 | } 6 | 7 | variable "s3_block_public_acls" { 8 | description = "Whether Amazon S3 should block public ACLs for this bucket." 9 | type = bool 10 | } 11 | variable "s3_block_public_policy" { 12 | description = "Whether Amazon S3 should block public bucket policies for this bucket." 13 | type = bool 14 | } 15 | 16 | variable "s3_ignore_public_acls" { 17 | description = "Whether Amazon S3 should ignore public ACLs for this bucket." 18 | type = bool 19 | } 20 | variable "s3_restrict_public_buckets" { 21 | description = "Whether Amazon S3 should restrict public bucket policies for this bucket." 22 | type = bool 23 | } 24 | 25 | variable "s3_bucket_names" { 26 | description = "S3 bucket name." 27 | type = list(string) 28 | } 29 | 30 | 31 | variable "ec2_instance_name" { 32 | description = "EC2 instance name." 33 | type = string 34 | } 35 | 36 | variable "ec2_instance_type" { 37 | description = "EC2 instance type." 38 | type = string 39 | } -------------------------------------------------------------------------------- /level_7/modules/ec2/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_instance" "level_7" { 2 | ami = data.aws_ami.level_7_amzn_linux_2.id 3 | instance_type = var.instance_type 4 | tags = { 5 | Name = var.instance_name 6 | } 7 | iam_instance_profile = aws_iam_instance_profile.level_7.name 8 | } 9 | 10 | data "aws_ami" "level_7_amzn_linux_2" { 11 | most_recent = true 12 | 13 | 14 | filter { 15 | name = "owner-alias" 16 | values = ["amazon"] 17 | } 18 | 19 | 20 | filter { 21 | name = "name" 22 | values = ["amzn2-ami-hvm*"] 23 | } 24 | 25 | owners = ["amazon"] 26 | } 27 | 28 | resource "aws_iam_instance_profile" "level_7" { 29 | name = "EC2_Instance_Profile_${var.instance_name}" 30 | role = aws_iam_role.level_7.name 31 | } 32 | 33 | resource "aws_iam_role" "level_7" { 34 | name = "EC2_Role_${var.instance_name}" 35 | path = "/" 36 | 37 | assume_role_policy = <