Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a new AWS EC2 instance resource.
Terraform
resource "aws_instance" "app_server" { ami = "ami-0c55b159cbfafe1f0" instance_type = "[1]" }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an instance type that is too large for simple applications.
Using an instance type that is deprecated or unavailable in the region.
✗ Incorrect
The 't3.micro' instance type is a common choice for lightweight applications and supports burstable CPU performance.
2fill in blank
mediumComplete the code to create an AWS Elastic Load Balancer (ELB) resource.
Terraform
resource "aws_elb" "app_elb" { name = "app-elb" availability_zones = ["us-west-2a", "us-west-2b"] listener { instance_port = 80 instance_protocol = "HTTP" lb_port = [1] lb_protocol = "HTTP" } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 without configuring HTTPS.
Using a non-standard port that clients won't connect to.
✗ Incorrect
The load balancer port should be 80 to accept HTTP traffic on the standard web port.
3fill in blank
hardFix the error in the code to properly attach instances to the ELB.
Terraform
resource "aws_elb_attachment" "app_attachment" { elb = aws_elb.app_elb.name instance = [1] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the instance name or IP instead of the ID.
Using an attribute that does not uniquely identify the instance.
✗ Incorrect
The ELB attachment requires the instance ID, which uniquely identifies the EC2 instance.
4fill in blank
hardFill both blanks to create a lifecycle rule that prevents Terraform from destroying the old instance immediately.
Terraform
resource "aws_instance" "old_app_server" { ami = "ami-0c55b159cbfafe1f0" instance_type = "t3.micro" lifecycle { [1] = true [2] = true } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'ignore_changes' with lifecycle control.
Not using 'create_before_destroy' causing downtime.
✗ Incorrect
The 'create_before_destroy' ensures the new instance is created before the old one is destroyed, and 'prevent_destroy' protects the resource from accidental deletion.
5fill in blank
hardFill all three blanks to define a Terraform output that shows the ELB DNS name after deployment.
Terraform
output "elb_dns_name" { value = [1].[2].[3] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'dns_name' for the ELB attribute.
Mixing resource names or types incorrectly.
✗ Incorrect
The output references the ELB resource 'aws_elb.app_elb' and accesses its 'dns_name' attribute to show the load balancer's DNS.