This README provides an overview of the Terraform configuration you have in this project. It describes the AWS resources being created and how to set up your environment.
This Terraform project is designed to provision AWS resources using the aws provider. It creates the following AWS resources:
-
An EC2 instance named "rajendra" with the following specifications:
- Instance Type:
t2.micro - Amazon Machine Image (AMI): Make sure to change the AMI ID as per your requirements.
- Subnet ID: Change the Subnet ID to the desired subnet.
- Instance Type:
-
An S3 bucket named "s3-demo-xyz". You should change the bucket name to a unique name if necessary.
-
An Amazon DynamoDB table named "terraform-lock" with the following attributes:
- Table Name: "terraform-lock"
- Billing Mode: "PAY_PER_REQUEST"
- Hash Key: "LockID" (String type)
The Terraform configuration is defined in a .tf file, and the backend configuration is stored in the backend.tf file. The structure of the files is as follows:
main.tf: Contains the AWS resource definitions for the EC2 instance, S3 bucket, and DynamoDB table.backend.tf: Defines the Terraform backend configuration for state management in an S3 bucket and uses DynamoDB for state locking.
Before you apply this Terraform configuration, ensure you have the following prerequisites set up:
-
Terraform Installation: Make sure Terraform is installed on your local machine. You can download it from Terraform's official website.
-
AWS Credentials: Configure your AWS credentials on your local machine. You can do this by setting up the AWS Access Key ID and Secret Access Key as environment variables or using AWS CLI configurations.
-
IAM Permissions: Ensure that the AWS credentials you're using have the necessary permissions to create and manage the specified AWS resources.
-
Clone this repository to your local machine.
-
Navigate to the project directory containing the
.tffiles. -
Initialize your Terraform working directory by running the following command:
terraform init -
Review and update the Terraform configuration files as needed, especially the AMI, subnet, and S3 bucket names.
-
Apply the Terraform configuration to create the specified resources:
terraform applyYou will be prompted to confirm the resource creation. Type "yes" to proceed.
To destroy the AWS resources created by this Terraform configuration, use the following command:
terraform destroy
You will be prompted to confirm the resource deletion. Type "yes" to proceed.
-
Make sure to review and customize the Terraform configuration according to your specific requirements before applying it.
-
Always handle AWS credentials and sensitive information securely and follow best practices for managing infrastructure as code.
-
This README serves as a basic guide to get you started with the Terraform project. For more advanced usage and further details, refer to the official Terraform documentation: Terraform Documentation.
Feel free to reach out if you have any questions or need further assistance with this Terraform project.