https://github.com/kgoksal/terraform-module
This is a Terraform Module Sample
https://github.com/kgoksal/terraform-module
Last synced: 4 months ago
JSON representation
This is a Terraform Module Sample
- Host: GitHub
- URL: https://github.com/kgoksal/terraform-module
- Owner: KGoksal
- Created: 2024-07-06T23:50:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-29T10:58:36.000Z (11 months ago)
- Last Synced: 2025-01-29T11:34:58.017Z (11 months ago)
- Language: HCL
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Terraform AWS VPC Module
This Terraform configuration sets up an AWS Virtual Private Cloud (VPC) with public and private subnets. It utilizes a module to manage VPC resources across different environments.
## Files
- **main.tf**: Defines the AWS provider and resources for creating the VPC and subnets.
- **variables.tf**: Defines input variables used in the configuration.
- **dev-vpc.tf**: Configuration for the development environment using the `tf-vpc` module.
- **prod-vpc.tf**: Configuration for the production environment using the `tf-vpc` module.
- **outputs.tf**: Defines output values to be displayed after Terraform applies the configuration.
## Usage
1. **Set up AWS Provider**: Ensure you have AWS credentials configured either through environment variables or AWS CLI configuration.
2. **Adjust Variables (if necessary)**: Modify `variables.tf` to customize CIDR blocks or other parameters as needed.
3. **Initialize Terraform**: Run `terraform init` in the directory where these files are located to initialize Terraform and download necessary providers.
4. **Review Plan**: Run `terraform plan` to see the execution plan and ensure it matches your expectations.
5. **Apply Changes**: Run `terraform apply` to apply the configuration and create the AWS resources.
6. **Destroy Resources**: If needed, run `terraform destroy` to destroy the created AWS resources.
## Modules
- **tf-vpc**: A module located in the `../modules` directory is used to encapsulate the VPC creation logic. It accepts an `environment` parameter to distinguish between environments (DEV, PROD).
## Outputs
- **vpc-cidr-block**: Outputs the CIDR block of the VPC created by the `tf-vpc` module.
## Notes
- Ensure proper AWS IAM permissions are set for the AWS credentials used with Terraform.
- As you see this configuration assumes AWS region `us-east-1`. Modify `provider "aws"` block in `main.tf` to change the region if necessary.