This repository contains two main components:
- Terraform Code: Used for provisioning and managing AWS infrastructure.
- Python Script: A tool to retrieve and display AWS resource inventory by region.
The Terraform code in this repository is designed to provision AWS resources such as VPCs, ALB, Route53 and security-group components. It provides a modular approach for easy customization and scalability.
-
Install Terraform: Ensure Terraform is installed. Download it from Terraform's official website.
-
Navigate to the Terraform Directory:
cd terraform
-
Initialize Terraform:
terraform init
This command initializes the working directory, downloading required providers and modules.
-
Plan Infrastructure Changes:
terraform plan
This step previews the changes Terraform will make to your infrastructure.
-
Apply the Configuration:
terraform apply
Confirm the operation by typing
yes
when prompted. This deploys the infrastructure. -
Destroy the Infrastructure: To clean up and remove all resources created by Terraform:
terraform destroy
The Python script, aws_inventory_by_region.py
, fetches an inventory of AWS resources for a specified region. It utilizes the AWS SDK for Python (boto3
) for seamless interaction with AWS services.
-
Install Python: Ensure Python 3.8 or newer is installed. Download it from Python's official website.
-
Install Dependencies: Use the
requirements.txt
file to install necessary Python packages:pip install -r requirements.txt
Key dependencies include
boto3
for AWS API interactions.
-
Set Up AWS Credentials:
- Use the AWS CLI to configure credentials:
aws configure
- Alternatively, export credentials as environment variables:
export AWS_ACCESS_KEY_ID=<your_access_key> export AWS_SECRET_ACCESS_KEY=<your_secret_key>
- Use the AWS CLI to configure credentials:
-
Run the Script: Execute the script with the required region parameter:
python aws_inventory_by_region.py --region <AWS_REGION>
Replace
<AWS_REGION>
with the desired AWS region (e.g.,us-east-1
). -
Output: The script provides a detailed inventory of AWS resources in the specified region.
- An active AWS account with sufficient permissions.
- Installed tools:
- Terraform
- Python 3.9+
- AWS CLI (optional but recommended)
- Use Terraform to set up the required AWS infrastructure.
- Run the Python script to retrieve an inventory of AWS resources for a specified region.
- Use a virtual environment for Python dependencies:
python -m venv venv source venv/bin/activate
- Validate your Terraform configurations before applying them to avoid unintended changes.
- Use IAM roles or secure environment variable management to protect AWS credentials.
The output generated by the Terraform code can be found in the file:
evidences/terraform_apply_output.txt
The output from running the Python script can be found in the file:
evidences/python_script_output.txt
To demonstrate the creation and validation of the requirements, several images from the AWS account have been included:
These images provide visual confirmation of the successful infrastructure setup and its compliance with the requirements.
Feel free to reach out if you have any questions or need assistance!