Complete the code to specify the compute layer in a multi-tier AWS architecture.
resource "aws_instance" "app_server" { instance_type = "[1]" ami = "ami-0abcdef1234567890" }
The compute layer in AWS multi-tier architecture is often an EC2 instance, specified by its instance type like t2.micro.
Complete the code to define the database tier in a multi-tier AWS architecture.
resource "aws_db_instance" "database" { engine = "[1]" instance_class = "db.t3.micro" allocated_storage = 20 }
The database tier uses a database engine like mysql for relational databases in AWS RDS.
Fix the error in the code to correctly configure the web tier with a load balancer.
resource "aws_lb" "web_lb" { name = "web-load-balancer" internal = [1] load_balancer_type = "application" subnets = ["subnet-12345", "subnet-67890"] }
The internal attribute expects a boolean value without quotes. Using false makes the load balancer internet-facing.
Fill both blanks to create a security group rule allowing HTTP traffic from anywhere.
resource "aws_security_group_rule" "allow_http" { type = "ingress" from_port = [1] to_port = [2] protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] }
HTTP traffic uses port 80, so both from_port and to_port should be set to 80 to allow HTTP access.
Fill all three blanks to define an auto-scaling group with a launch configuration and desired capacity.
resource "aws_autoscaling_group" "asg" { launch_configuration = "[1]" min_size = [2] desired_capacity = [3] max_size = 5 vpc_zone_identifier = ["subnet-abcde", "subnet-fghij"] }
The auto-scaling group uses a launch configuration named app_launch_config. The minimum size is 2, and the desired capacity is 3 instances.