Lab 37: Elastic IP Variable Setup Using Terraform
The Nautilus DevOps team is automating IAM user creation using Terraform for better identity management.
For this task, create an AWS IAM User using Terraform with the following requirements:
- The IAM User name
iamuser_yousufshould be stored in a variable namedKKE_user.
Note:
-
- The configuration values should be stored in a
variables.tffile.
- The configuration values should be stored in a
-
- The Terraform script should be structured with a
main.tffile referencingvariables.tf.
- The Terraform script should be structured with a
-
The Terraform working directory is
/home/bob/terraform. -
Right-click under the
EXPLORERsection inVS Codeand selectOpen in Integrated Terminalto launch the terminal.
# /home/bob/terraform/variables.tf
variable "KKE_eip" {
description = "The name to be used for the Elastic IP address."
type = string
default = "devops-eip"
}
# /home/bob/terraform/main.tf
resource "aws_eip" "devops_elastic_ip" {
# The tags block is used to name the resource in the AWS console.
tags = {
Name = var.KKE_eip
}
}
terraform init
# or apply forcefully without creating plan and applying it
terraform apply -auto-approve