0
0
AWScloud~30 mins

Key pairs for SSH access in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Key pairs for SSH access
📖 Scenario: You are setting up a secure connection to a cloud server. To do this, you need to create a key pair that will allow you to log in safely using SSH without a password.
🎯 Goal: Create an AWS EC2 key pair resource using Infrastructure as Code. This key pair will be used to securely access your cloud server.
📋 What You'll Learn
Create a key pair resource with a specific name
Add a public key material to the key pair
Output the key pair name as a reference
Use valid AWS resource configuration syntax
💡 Why This Matters
🌍 Real World
Key pairs are essential for securely accessing cloud servers without passwords. This project shows how to automate key pair creation for safe SSH access.
💼 Career
Cloud engineers and DevOps professionals often create and manage key pairs to secure server access in AWS environments.
Progress0 / 4 steps
1
Create the key pair resource
Create an AWS EC2 key pair resource named my_key_pair with the key pair name set to my-ssh-key.
AWS
Need a hint?

Use the aws_key_pair resource with the name my_key_pair. Set key_name to my-ssh-key and provide a public key string for public_key.

2
Add a variable for the public key
Create a variable named public_key_value to hold the public SSH key string. Assign it the value ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7...user@example.com.
AWS
Need a hint?

Define a variable block named public_key_value with the public key string as its default value. Reference it in the public_key attribute of the key pair resource.

3
Output the key pair name
Create an output named key_pair_name that outputs the key_name attribute of the aws_key_pair.my_key_pair resource.
AWS
Need a hint?

Use an output block named key_pair_name to expose the key_name from the key pair resource.

4
Add a tag to the key pair resource
Add a tags block to the aws_key_pair.my_key_pair resource with a tag Environment set to Development.
AWS
Need a hint?

Add a tags map inside the key pair resource with the key Environment and value Development.