This Terraform project deploys an Amazon Web Services (AWS) Virtual Private Cloud (VPC) with subnets in the us-west-1 region and VM resources in on-premises VMware vCenter 7.0. It's designed for streamlining entities' creation process in different environments.
- Prerequisites
- Getting Started with AWS networking
- Project Structure
- Variables
- Resources
- Outputs
- Getting Started with AWS EC2 instances
- Getting Started with VMware vCenter
- Terraform Commands
Before you begin, ensure you have the following prerequisites:
- Terraform installed on your local machine.
- AWS credentials configured with the necessary permissions. These credentials should be set up in your ~/.aws/credentials file.
- Clone this repository to your local machine:
git clone <repository-url> - Navigate to the project directory:
cd <project-directory> - Initialize Terraform:
terraform init - Review and customize the variables in the variables.tf file as needed.
- Create a terraform.tfvars file (or use -var options with terraform apply) to provide values for your variables.
- Apply the Terraform configuration:
terraform apply - Confirm and apply the changes by typing "yes" when prompted.
- Once the deployment is complete, Terraform will display the outputs, including VPC and subnet IDs.
The project structure is organized as follows:
- main.tf: Defines the AWS provider, variables, resources, and outputs.
- variables.tf: Declares input variables and their descriptions.
- terraform.tfvars: Provides values for variables (create this file).
- outputs.tf: Defines the output values displayed after deployment.
- cidr_blocks: A list of CIDR blocks and name tags for VPC and subnets.
- environment: Deployment environment (e.g., "dev", "prod").
- aws_vpc: Defines an AWS VPC resource with the specified CIDR block and tags.
- aws_subnet: Defines AWS subnets within the VPC.
- data.aws_vpc.existing_vpc: Retrieves information about an existing VPC.
- vpc-id: Displays the VPC's name tag.
- subnet-1-id: Displays the name tag for subnet 1.
- subnet-2-id: Displays the name tag for subnet 2.
- To start working with this project navigate to the project directory:
cd web
This Terraform configuration defines the provisioning of a virtual machine (VM) on a VMware vSphere infrastructure. It includes the setup of the necessary providers, data sources for datacenter, datastore, compute cluster, and network, as well as the creation of a virtual machine.
- To start working with this project navigate to the project directory:
cd vmware
- username: The username for authenticating with the vCenter server.
- password: The password for authenticating with the vCenter server.
- vsphere_server: The address of the vCenter server.
The vsphere provider is configured to connect to the VMware vSphere infrastructure using the provided credentials and server address. Additionally, the allow_unverified_ssl option is set to true to allow connections to vCenter servers with self-signed SSL certificates.
- vsphere_datacenter: Retrieves information about the datacenter named "1iq-dc" in the vSphere infrastructure.
- vsphere_datastore: Retrieves information about the datastore named "vsanDatastore" associated with the specified datacenter.
- vsphere_compute_cluster: Retrieves information about the compute cluster named "1iq-vsan" within the specified datacenter.
- vsphere_network: Retrieves information about the network named "vLAN Lab" within the specified datacenter.
The vsphere_virtual_machine resource defines the creation of a virtual machine with the following characteristics:
Name: "opensuse-15-6"
Resource pool: The resource pool associated with the specified compute cluster.
Datastore: The datastore associated with the specified datacenter.
CPU: 1 virtual CPU.
Memory: 2048 MB.
Guest ID: "other3xLinux64Guest."
Network: Connected to the "vLAN Lab" network.
Disk: One disk labeled "disk0" with a size of 16 GB.
No wait for guest network timeout.
The vm_ip output provides the IP address of the VMware vSphere virtual machine. This IP address can be used to access and manage the provisioned virtual machine.
- terraform init: Initialize the Terraform project.
- terraform plan: Review the execution plan.
- terraform apply: Apply the Terraform configuration to create AWS resources.
- terraform destroy: Destroy all created resources.
- terraform output: Display the output values.