diff --git a/day01/solution.md b/day01/solution.md new file mode 100644 index 0000000..b5aa39d --- /dev/null +++ b/day01/solution.md @@ -0,0 +1,221 @@ +# TerraWeek Day 1 + +### **Day 1: Introduction to Terraform and Terraform Basics** + +#### **What is Terraform, and how can it help you manage Infrastructure as Code?** +Terraform is an open-source tool by HashiCorp that allows you to define, manage, and provision infrastructure as code (IaC). It uses a declarative configuration language, HCL (HashiCorp Configuration Language), to describe the desired state of infrastructure. By applying these configurations, Terraform ensures that the actual infrastructure matches the desired state. + + +Key benefits of Terraform: + +- **Consistency:** The same configurations can be reused across environments (e.g., dev, staging, production). +- **Version Control:** Infrastructure definitions are stored in source control systems like Git. +- **Automation:** Removes the need for manual intervention during resource creation. +- **Cloud-Agnostic:** Supports multiple cloud providers like AWS, Azure, GCP, and even on-prem solutions. + +--- + +#### **Why do we need Terraform, and how does it simplify infrastructure provisioning?** +1. **Eliminates Manual Effort:** Automates the provisioning, scaling, and configuration of resources. +2. **Infrastructure as Code:** Maintains infrastructure as code for better tracking, auditing, and collaboration. +3. **Cross-Cloud Compatibility:** Provides a unified approach to managing multi-cloud and hybrid environments. +4. **Dependency Management:** Automatically understands and manages dependencies between resources. +5. **Cost and Time Efficiency:** Reduces operational overhead and human error, enabling rapid infrastructure changes. + +--- + +#### **How Can You Install Terraform and Set Up the Environment for AWS?** + +#### **Before You Begin: Create an EC2 Instance for Running Commands** + +To execute the following commands in an isolated environment, create an Ubuntu EC2 instance using AWS Management Console: + +##### **Launch an EC2 Instance:** + +1. Go to the **EC2 Dashboard** on AWS. +2. Click **Launch Instance**. +3. Configure: + - **Name:** Terraform-Setup + - **AMI:** Ubuntu Server 22.04 LTS + - **Instance Type:** t2.micro (free tier eligible) + - **Key Pair:** Create or select an existing key pair. + - **Network Settings:** Allow SSH traffic (port 22) from your IP address. + - **Storage:** Keep the default 8 GiB or adjust as needed. + +##### **Connect to the Instance:** + +Use an SSH client or AWS CloudShell to connect: + +```bash +ssh -i "your-key-pair.pem" ubuntu@ +``` + +##### **Update the Instance:** + +Run the following commands after connecting: + +```bash +sudo apt update && sudo apt upgrade -y +``` + +Now proceed with the installation of Terraform and setting up AWS credentials. + + +##### 1. **Install Terraform on Ubuntu:** + +To install Terraform on Ubuntu, follow these steps: + +- **Add the HashiCorp GPG Key and Repository:** + + ```bash + wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list + ``` + +- **Update the Package List and Install Terraform:** + + ```bash + sudo apt update && sudo apt install terraform + ``` + +- **Verify Installation:** + + Confirm that Terraform is installed correctly by checking its version: + + ```bash + terraform version + ``` + +--- + +##### 2. **Set Up Terraform for AWS:** + +- **Create an IAM User in AWS:** + + - Go to the **IAM Management Console** in AWS. + - Create a new IAM user with **programmatic access**. + - Attach the necessary policies (e.g., `AdministratorAccess` or policies tailored to your use case). + - Note down the **Access Key ID** and **Secret Access Key**. + +- **Install the AWS CLI:** + + Install the AWS CLI to configure credentials: + ```bash + sudo apt update && sudo apt install awscli + ``` + +- **Configure AWS CLI Credentials:** + + Run the following command and enter your IAM user details: + ```bash + aws configure + ``` + + Provide: + - **Access Key ID** + - **Secret Access Key** + - **Default region** (e.g., `us-east-1`) + - Output format (default: `json`) + + +- **Verify AWS CLI Configuration:** + + Check your AWS CLI configuration: + ```bash + aws sts get-caller-identity + ``` + +- **Use AWS as a Provider in Terraform:** + Add the provider configuration to your Terraform `.tf` file: + + ```hcl + terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "5.65.0" + } + } + } + + provider "aws" { + region = "us-east-1" + } + ``` + +With these steps, your environment is ready to manage AWS infrastructure using Terraform. + + + +#### **Important Terminologies of Terraform** + +1. **Provider:** + + - Defines the cloud service (e.g., AWS, Azure) or on-premises platform you are interacting with. + + - Example: + + ```hcl + provider "aws" { + region = "us-west-2" + } + ``` + +2. **Resource:** + + - A fundamental element (e.g., an EC2 instance, an S3 bucket) described in the Terraform configuration. + + - Example: + + ```hcl + resource "aws_s3_bucket" "example" { + bucket = "example-bucket" + tags = { + Name = "example-bucket" + } + } + ``` + +3. **State:** + + - A file that tracks the current state of your infrastructure. It helps Terraform understand the desired state versus the actual state. + + - Example: + + Terraform generates a `terraform.tfstate` file during execution. + + +4. **Module:** + + - A reusable and logical grouping of resources defined in separate files or directories. + + - Example: + + ```hcl + module "vpc" { + source = "./modules/vpc" + cidr = "10.0.0.0/16" + } + ``` + +5. **Data Source:** + + - Allows fetching data from external sources (e.g., the details of an existing AWS AMI). + + - Example: + ```hcl + data "aws_ami" "ubuntu" { + most_recent = true + filter { + name = "name" + values = ["ubuntu/images/*"] + } + } + ``` + +These terminologies form the backbone of understanding and working with Terraform effectively! + + + +Watch this [Reference Video](https://www.youtube.com/live/965CaSveIEI?feature=share) + diff --git a/day02/images/task3.1.png b/day02/images/task3.1.png new file mode 100644 index 0000000..5f79c22 Binary files /dev/null and b/day02/images/task3.1.png differ diff --git a/day02/images/task3.2.png b/day02/images/task3.2.png new file mode 100644 index 0000000..59f1c91 Binary files /dev/null and b/day02/images/task3.2.png differ diff --git a/day02/images/task3.3.png b/day02/images/task3.3.png new file mode 100644 index 0000000..35390b3 Binary files /dev/null and b/day02/images/task3.3.png differ diff --git a/day02/main.tf b/day02/main.tf new file mode 100644 index 0000000..5270614 --- /dev/null +++ b/day02/main.tf @@ -0,0 +1,13 @@ + terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } + } + + +provider "aws" { + region = "us-west-2" +} \ No newline at end of file diff --git a/day02/solution.md b/day02/solution.md new file mode 100644 index 0000000..69cd0fe --- /dev/null +++ b/day02/solution.md @@ -0,0 +1,98 @@ +# TerraWeek Day 2 + + +## Task 1: Familiarize yourself with HCL syntax used in Terraform +HCL (HashiCorp Configuration Language) is used to define infrastructure in Terraform. Here are the key components: + +- **Blocks**: These define a configuration in Terraform, e.g., `resource`, `provider`, `output`. + Example: + ```hcl + resource "aws_s3_bucket" "example" { + bucket = "my-unique-bucket-name" + } + ``` +- **Parameters**: These define values within a block, e.g., `bucket`. +- **Arguments**: These are the specific values provided to parameters. For example, `"my-unique-bucket-name"` is an argument for the `bucket` parameter. + +**Resources** in Terraform represent infrastructure objects like instances, buckets, and databases. **Data sources** fetch information about existing infrastructure, such as querying for AWS instance details. + +## Task 2: Understand variables, data types, and expressions in HCL +- **Variables**: Variables allow you to reuse configuration and pass values dynamically. Define a variable in `variables.tf`. + + Example of a `variables.tf`: + ```hcl + variable "bucket_name" { + description = "The name of the S3 bucket" + type = string + default = "my-default-bucket" + } + ``` + +- **Use the variable in `main.tf`**: + ```hcl + resource "aws_s3_bucket" "example" { + bucket = var.bucket_name + } + ``` + +## Task 3: Practice writing Terraform configurations using HCL syntax +- **Required Providers**: In your `main.tf`, specify providers such as Docker or AWS. + Example: + ```hcl + terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } + } + ``` + +- **Testing Configuration**: To test the configuration: + 1. Initialize the Terraform working directory: + ```bash + terraform init + ``` + + ![task3.1](images/task3.1.png) + + + 2. Run a plan to check for errors and preview changes: + ```bash + terraform plan + ``` + + ![task3.2](images/task3.2.png) + + + 3. Apply the configuration: + ```bash + terraform apply + ``` + + ![task3.3](images/task3.3.png) + + + 4. If necessary, adjust the configuration and reapply. + + +## Example of a `main.tf` file: +```hcl +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.0" + } + } +} + +provider "aws" { + region = "us-west-2" +} + +resource "aws_s3_bucket" "example" { + bucket = var.bucket_name +} +``` diff --git a/day02/variable.tf b/day02/variable.tf new file mode 100644 index 0000000..cf6dcbd --- /dev/null +++ b/day02/variable.tf @@ -0,0 +1,5 @@ + variable "bucket_name" { + description = "The name of the S3 bucket" + type = string + default = "my-default-bucket" + } \ No newline at end of file diff --git a/day03/ec2.tf b/day03/ec2.tf new file mode 100644 index 0000000..8e9770c --- /dev/null +++ b/day03/ec2.tf @@ -0,0 +1,107 @@ +data "aws_ami" "ubuntu" { + owners = [var.aws_ami_owners] + most_recent = true + + filter { + name = "name" + values = [var.aws_ami_image] + } + + filter { + name = "state" + values = ["available"] + } +} + +resource "aws_key_pair" "terraweek_key" { + key_name = var.aws_private_key_pair_name + public_key = file(var.aws_public_key_pair_name) +} + +resource "aws_default_vpc" "default" { +} + +resource "aws_security_group" "my_terraweek_sg" { + name = var.aws_sg_name + description = var.aws_sg_description + vpc_id = aws_default_vpc.default.id + + ingress { + description = "Allow access to SSH port 22" + from_port = 22 + to_port = 22 + protocol = var.ssh_protocol + cidr_blocks = [var.ssh_cidr] + } + + ingress { + description = "Allow access to HTTP port 80" + from_port = 80 + to_port = 80 + protocol = var.http_protocol + cidr_blocks = [var.http_cidr] + } + + ingress { + description = "Allow access to HTTPS port 443" + from_port = 443 + to_port = 443 + protocol = var.https_protocol + cidr_blocks = [var.https_cidr] + } + + egress { + description = "allow all outgoing traffic" + from_port = 0 + to_port = 0 + protocol = var.outgoing_protocol + cidr_blocks = [var.outgoing_cidr] + ipv6_cidr_blocks = [var.outgoing_ipv6_cidr] + } + + tags = { + Name = var.aws_sg_name + } +} + +resource "aws_instance" "my_instance" { + ami = data.aws_ami.ubuntu.id + instance_type = var.aws_instance_type + key_name = aws_key_pair.terraweek_key.key_name + security_groups = [aws_security_group.my_terraweek_sg.name] + + root_block_device { + volume_size = var.aws_instance_volume_size + volume_type = var.aws_instance_volume_type + } + + tags = { + Name = var.aws_instance_name + } + + # Provisioner to install nginx on the instance after it's created + provisioner "remote-exec" { + inline = [ + "sudo apt update", + "sudo apt install -y nginx", + "sudo systemctl start nginx", + "sudo systemctl enable nginx" + ] + + # Use the private key for SSH authentication + connection { + type = "ssh" + user = "ubuntu" + private_key = file(var.aws_private_key_pair_name) + host = self.public_ip + } + } + + # Lifecycle management configuration + lifecycle { + create_before_destroy = true # Create the new instance before destroying the old one + prevent_destroy = false # Allow the resource to be destroyed + ignore_changes = [tags] # Ignore changes to the tags + } +} + diff --git a/day03/images/task2.1.png b/day03/images/task2.1.png new file mode 100644 index 0000000..b539fa6 Binary files /dev/null and b/day03/images/task2.1.png differ diff --git a/day03/images/task2.2.png b/day03/images/task2.2.png new file mode 100644 index 0000000..5b87ac7 Binary files /dev/null and b/day03/images/task2.2.png differ diff --git a/day03/images/task2.3.1.png b/day03/images/task2.3.1.png new file mode 100644 index 0000000..cf5bafa Binary files /dev/null and b/day03/images/task2.3.1.png differ diff --git a/day03/images/task2.3.2.png b/day03/images/task2.3.2.png new file mode 100644 index 0000000..64ca86f Binary files /dev/null and b/day03/images/task2.3.2.png differ diff --git a/day03/images/task2.4.1.png b/day03/images/task2.4.1.png new file mode 100644 index 0000000..cb1fd58 Binary files /dev/null and b/day03/images/task2.4.1.png differ diff --git a/day03/images/task2.4.2.png b/day03/images/task2.4.2.png new file mode 100644 index 0000000..fc1f0cd Binary files /dev/null and b/day03/images/task2.4.2.png differ diff --git a/day03/images/task2.5.png b/day03/images/task2.5.png new file mode 100644 index 0000000..8fa875e Binary files /dev/null and b/day03/images/task2.5.png differ diff --git a/day03/images/task3.1.png b/day03/images/task3.1.png new file mode 100644 index 0000000..0ee645e Binary files /dev/null and b/day03/images/task3.1.png differ diff --git a/day03/images/task3.2.1.png b/day03/images/task3.2.1.png new file mode 100644 index 0000000..2a04a1f Binary files /dev/null and b/day03/images/task3.2.1.png differ diff --git a/day03/images/task3.2.2.png b/day03/images/task3.2.2.png new file mode 100644 index 0000000..98c8858 Binary files /dev/null and b/day03/images/task3.2.2.png differ diff --git a/day03/images/task3.3.1.png b/day03/images/task3.3.1.png new file mode 100644 index 0000000..33414bc Binary files /dev/null and b/day03/images/task3.3.1.png differ diff --git a/day03/images/task3.3.2.png b/day03/images/task3.3.2.png new file mode 100644 index 0000000..cedc803 Binary files /dev/null and b/day03/images/task3.3.2.png differ diff --git a/day03/images/task3.3.3.png b/day03/images/task3.3.3.png new file mode 100644 index 0000000..cb32219 Binary files /dev/null and b/day03/images/task3.3.3.png differ diff --git a/day03/images/task3.3.4.png b/day03/images/task3.3.4.png new file mode 100644 index 0000000..8fa68f0 Binary files /dev/null and b/day03/images/task3.3.4.png differ diff --git a/day03/images/task4.1.png b/day03/images/task4.1.png new file mode 100644 index 0000000..224148e Binary files /dev/null and b/day03/images/task4.1.png differ diff --git a/day03/images/task4.2.1.png b/day03/images/task4.2.1.png new file mode 100644 index 0000000..1ad8a7a Binary files /dev/null and b/day03/images/task4.2.1.png differ diff --git a/day03/images/task4.2.2.png b/day03/images/task4.2.2.png new file mode 100644 index 0000000..18359e0 Binary files /dev/null and b/day03/images/task4.2.2.png differ diff --git a/day03/images/task4.2.3.png b/day03/images/task4.2.3.png new file mode 100644 index 0000000..e9512a3 Binary files /dev/null and b/day03/images/task4.2.3.png differ diff --git a/day03/main.tf b/day03/main.tf new file mode 100644 index 0000000..94dde81 --- /dev/null +++ b/day03/main.tf @@ -0,0 +1,4 @@ +# Configure the AWS Provider +provider "aws" { + region = var.aws_region +} \ No newline at end of file diff --git a/day03/output.tf b/day03/output.tf new file mode 100644 index 0000000..cef105a --- /dev/null +++ b/day03/output.tf @@ -0,0 +1,11 @@ +# Output for Public IP Address of the EC2 Instance +output "ec2_public_ip" { + description = "The public IP address of the EC2 instance" + value = aws_instance.my_instance.public_ip +} + +# Output for Private IP Address of the EC2 Instance +output "ec2_private_ip" { + description = "The private IP address of the EC2 instance" + value = aws_instance.my_instance.private_ip +} diff --git a/day03/solution.md b/day03/solution.md new file mode 100644 index 0000000..ef1bfc7 --- /dev/null +++ b/day03/solution.md @@ -0,0 +1,216 @@ +# TerraWeek Day 3 + + +### Task 1: **Create a Terraform configuration file to define a resource (AWS EC2 instance)** + +The `main.tf` and `ec2.tf` files define the AWS EC2 instance along with necessary resources like security groups, key pairs, and AMI. Here's a breakdown: + +- **AWS Provider Configuration**: + - The AWS provider is set up in `main.tf`, which specifies the region and version for the `aws` provider. + +- **EC2 Instance**: + - In `ec2.tf`, the resource `aws_instance.my_instance` defines an EC2 instance, referencing the latest Ubuntu AMI and configuring a security group (`aws_security_group.my_terraweek_sg`) and key pair (`aws_key_pair.terraweek_key`). + +- **Security Group**: + - A security group is configured to allow SSH, HTTP, and HTTPS traffic, as specified in `ec2.tf`. + +- **Provisioner**: + - A remote-exec provisioner is added to install Nginx on the EC2 instance once it's created. This is defined inside the `aws_instance.my_instance` resource block. + +- **See the `main.tf` and `terraform.tf` for source code regarding this task** + +--- + + +### Task 2: **Check state files before running plan and apply commands & Use validate command** + +- **State Files**: + - Terraform stores the state of your infrastructure in a state file (usually `terraform.tfstate`). This file tracks the resources you create and manage with Terraform. Before running `terraform plan` or `terraform apply`, it's essential to check this state file to ensure your infrastructure matches the current state. + + - State files before plan and apply : + + ![task2.1](images/task2.1.png) + +- **Validate Command**: + - The `terraform validate` command checks for syntax errors and validates that the configuration files are correct and usable. + + **Commands to run**: + ```bash + terraform validate + ``` + + This command will output `Success! The configuration is valid.` if there are no issues. + + + ![task2.2](images/task2.2.png) + + + - Terraform plan : + + ![task2.3.1](images/task2.3.1.png) + + ![task2.3.2](images/task2.3.2.png) + + + - Terraform apply : + + ![task2.4.1](images/task2.4.1.png) + + ![task2.4.2](images/task2.4.2.png) + + + - EC2 instance running successfully : + + ![task2.5](images/task2.5.png) + +--- + + +### Task 3: **Add a provisioner to configure the resource after creation and use Terraform commands to apply and destroy** + +A provisioner is already included in the `aws_instance.my_instance` resource block in `ec2.tf`, which installs and starts Nginx after the instance is created. + +- **Provisioner Block**: + ```hcl + provisioner "remote-exec" { + inline = [ + "sudo apt update", + "sudo apt install -y nginx", + "sudo systemctl start nginx", + "sudo systemctl enable nginx" + ] + connection { + type = "ssh" + user = "ubuntu" + private_key = file(var.aws_private_key_pair_name) + host = self.public_ip + } + } + ``` + This block ensures that after the instance is created, Nginx is installed and started automatically. + + - Added Provisioner block to existing ec2.tf : + + ![task3.1](images/task3.1.png) + + +- **Terraform Commands**: +- To apply changes and provision the EC2 instance, run: + + ```bash + terraform apply --auto-approve + ``` + + - Terraform apply images: + + ![task3.3.1](images/task3.3.1.png) + + ![task3.3.2](images/task3.3.2.png) + + ![task3.3.3](images/task3.3.3.png) + + + - Nginx running successfully : + + ![task3.3.4](images/task3.3.4.png) + + +- To destroy the resources (in this case, the EC2 instance), run: + + ```bash + terraform destroy + ``` + + This will prompt you to confirm the deletion of the resources (type `yes` to proceed). + + - Terraform destroy images : + + ![task3.2.1](images/task3.2.1.png) + + ![task3.2.2](images/task3.2.2.png) + +--- + + +### Task 4: **Add lifecycle management configurations to the configuration file** + +The `lifecycle` block in the `aws_instance.my_instance` resource manages how Terraform handles resource creation, modification, and destruction. Here's a breakdown of the lifecycle configuration you provided: + +```hcl +lifecycle { + create_before_destroy = true # Create the new instance before destroying the old one + prevent_destroy = false # Allow the resource to be destroyed + ignore_changes = [tags] # Ignore changes to the tags +} +``` + +- Added lifecycle block to existing ec2.tf : + + ![task4.1](images/task4.1.png) + + +- **`create_before_destroy = true`**: + - This ensures that Terraform creates a new instance before destroying the old one. This is useful in situations where you don't want downtime while updating the instance. + +- **`prevent_destroy = false`**: + - This allows the resource to be destroyed. Setting it to `true` would prevent the destruction of the resource, which can be useful for critical infrastructure. + + - what if I set `prevent_destroy = true` ,this will cause error , you can see in below images + + ![task4.2.1](images/task4.2.1.png) + + ![task4.2.2](images/task4.2.2.png) + + ![task4.2.3](images/task4.2.3.png) + + +- **`ignore_changes = [tags]`**: + - This instructs Terraform to ignore any changes to the `tags` attribute. If the tags are updated in the configuration or manually, Terraform will not attempt to modify the tags on the resource. + +--- + + +### Terraform Commands for Task 4: + +- **Apply the Changes**: + After modifying the lifecycle management block, you can run: + ```bash + terraform apply + ``` + + +--- + + + +### Summary of Terraform Commands: + +1. **Validate Configuration**: + ```bash + terraform validate + ``` + +2. **Initialize Terraform (if not done already)**: + ```bash + terraform init + ``` + +3. **Plan Changes**: + ```bash + terraform plan + ``` + +4. **Apply Changes**: + ```bash + terraform apply + ``` + + ```bash + terraform apply --auto-approve + ``` + +5. **Destroy Resources**: + ```bash + terraform destroy + ``` + diff --git a/day03/terraform.tf b/day03/terraform.tf new file mode 100644 index 0000000..25256d1 --- /dev/null +++ b/day03/terraform.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} + diff --git a/day03/variable.tf b/day03/variable.tf new file mode 100644 index 0000000..042dd42 --- /dev/null +++ b/day03/variable.tf @@ -0,0 +1,139 @@ +# AMI owner ID for the AWS account (default: Canonical for Ubuntu images) +variable "aws_ami_owners" { + description = "AWS account ID of the AMI owner" + type = string + default = "099720109477" +} + +# AWS region where the EC2 instance will be launched +variable "aws_region" { + description = "The AWS region to deploy resources in" + type = string + default = "eu-west-1" +} + +# AMI filter pattern for the desired Ubuntu image +variable "aws_ami_image" { + description = "Filter pattern for the desired AWS AMI (Ubuntu)" + type = string + default = "ubuntu/images/hvm-ssd/*amd64*" +} + +# Path to the private key file for SSH access +variable "aws_private_key_pair_name" { + description = "Path to the private key pair for SSH" + type = string + default = "~/terraweek-key" +} + +# Path to the public key file for SSH access +variable "aws_public_key_pair_name" { + description = "Path to the public key pair for SSH" + type = string + default = "terraweek-key.pub" +} + +# Name of the security group to be created +variable "aws_sg_name" { + description = "Name of the security group" + type = string + default = "my_terraweek_sg" +} + +# Description of the security group +variable "aws_sg_description" { + description = "Description of the security group" + type = string + default = "Allow TLS inbound traffic and all outbound traffic" +} + +# Protocol used for SSH access (default: TCP) +variable "ssh_protocol" { + description = "Protocol for SSH traffic" + type = string + default = "tcp" +} + +# CIDR block for SSH access (default: allow all) +variable "ssh_cidr" { + description = "CIDR block for SSH access" + type = string + default = "0.0.0.0/0" +} + +# Protocol used for HTTP traffic (default: TCP) +variable "http_protocol" { + description = "Protocol for HTTP traffic" + type = string + default = "tcp" +} + +# CIDR block for HTTP access (default: allow all) +variable "http_cidr" { + description = "CIDR block for HTTP access" + type = string + default = "0.0.0.0/0" +} + +# Protocol used for HTTPS traffic (default: TCP) +variable "https_protocol" { + description = "Protocol for HTTPS traffic" + type = string + default = "tcp" +} + +# CIDR block for HTTPS access (default: allow all) +variable "https_cidr" { + description = "CIDR block for HTTPS access" + type = string + default = "0.0.0.0/0" +} + +# Protocol used for outgoing traffic (default: all) +variable "outgoing_protocol" { + description = "Protocol for outgoing traffic" + type = string + default = "-1" +} + +# CIDR block for outgoing traffic (IPv4) +variable "outgoing_cidr" { + description = "CIDR block for outgoing IPv4 traffic" + type = string + default = "0.0.0.0/0" +} + +# CIDR block for outgoing traffic (IPv6) +variable "outgoing_ipv6_cidr" { + description = "CIDR block for outgoing IPv6 traffic" + type = string + default = "::/0" +} + +# Instance type for the AWS EC2 instance (default: t2.micro) +variable "aws_instance_type" { + description = "Type of EC2 instance to be launched" + type = string + default = "t2.micro" +} + +# Size of the root volume for the EC2 instance in GB +variable "aws_instance_volume_size" { + description = "Size of the root volume in GB" + type = number + default = 10 +} + +# Type of the root volume for the EC2 instance (default: gp3) +variable "aws_instance_volume_type" { + description = "Type of the root volume (e.g., gp3, gp2, io1)" + type = string + default = "gp3" +} + +# Name tag for the AWS EC2 instance +variable "aws_instance_name" { + description = "Name tag for the EC2 instance" + type = string + default = "Terraweek-Day-03" +}