Lab Information
The Nautilus DevOps team is strategizing the migration of a portion of their infrastructure to the AWS cloud. Recognizing the scale of this undertaking, they have opted to approach the migration in incremental steps rather than as a single massive transition. To achieve this, they have segmented large tasks into smaller, more manageable units. This granular approach enables the team to execute the migration in gradual phases, ensuring smoother implementation and minimizing disruption to ongoing operations. By breaking down the migration into smaller tasks, the Nautilus DevOps team can systematically progress through each stage, allowing for better control, risk mitigation, and optimization of resources throughout the migration process.
For this task, allocate an Elastic IP address named devops-eip using Terraform.
The Terraform working directory is /home/bob/terraform. Create the main.tf file (do not create a different .tf file) to accomplish this task.
Note: Right-click under the EXPLORER section in VS Code and select Open in Integrated Terminal to launch the terminal.
Lab Solutions
Create main.tf file:
# main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "aws_eip" "devops_eip" {
domain = "vpc"
tags = {
Name = "devops-eip"
}
}
This configuration:
Provider Configuration: Sets up the AWS provider (defaults to us-east-1 region, which is commonly used if not specified, but I've explicitly set it for clarity).
Elastic IP Resource: Creates the Elastic IP with:
Domain: vpc - This specifies that the EIP is for use in VPC (required for modern AWS)
Name tag: devops-eip as specified in the requirements
Important Notes:
The domain = "vpc" parameter is essential as it allocates the EIP for use in EC2-VPC (the current standard)
Without specifying a region, it would default to us-east-1, but I've included it explicitly for clarity
The EIP will be allocated to your AWS account and remain associated until you explicitly release it
To deploy this configuration:
Navigate to the Terraform directory:
cd /home/bob/terraform
Initialize Terraform:
terraform init
Plan the deployment to verify the configuration:
terraform plan
Apply the configuration:
terraform apply
Then type yes when prompted to confirm the creation of the Elastic IP.
After successful creation, Terraform will output the allocated Elastic IP address. You can also check the allocation in the AWS Management Console under EC2 → Elastic IPs.
This Elastic IP can now be used by the Nautilus DevOps team for various purposes in their incremental migration, such as:
Associating with NAT Gateways
Assigning to EC2 instances that need static public IPs
Load balancers or other resources requiring persistent public IP addresses


Top comments (0)