Terraform-VPC-sample

所属分类:微服务
开发工具:HCL
文件大小:0KB
下载次数:0
上传日期:2024-02-25 23:12:53
上 传 者sh-1993
说明:  Amazon Virtual Private Cloud(Amazon VPC)允许您将Amazon Web Services资源启动到您定义的虚拟网络中。该虚拟网络类似于在自己的数据中心中运行的传统网络,具有使用AWS的可扩展基础架构的优势。
(Amazon Virtual Private Cloud (Amazon VPC) enables you to launch Amazon Web Services resources into a virtual network you ve defined. This virtual network resembles a traditional network that you d operate in your own data center, with the benefits of using the scalable infrastructure of AWS.)

文件列表:
aws-instance.tf
providers.tf
variables.tf
vpc.tf

# AWS VPC Terraform Terraform module which creates VPC resources on AWS. ## Brief description This module will provision a new VPC with 3 public and 3 private subnets along with their public and private route tables. The private route table is configured with NAT gateway. The public route table is configured with Internet gateway. Furthermore, this script will also provision an EC2 bastion server with its custom security group. ## Usage This script creates a VPC along with its related modules : 1. Public and private subnets 2. Public and private route tables 3. Elastic IPs 4. NAT Gateways 5. An Internet Gateway 6. Security group for bastion EC2 instance 7. A bastion EC2 instance ## Prerequisites - [Terraform v1.0.11](https://www.terraform.io/downloads.html) - IAM user with administrator access to EC2. - You can also setup this via IAM Role feature. Just attach the role on the server which we used to run the terraform file or code. ## Terraform Installation ``` $ wget https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip $ unzip terraform_1.0.11_linux_amd64.zip $ mv terraform /usr/bin/ ``` ## Variables used - region - Region of the VPC (default: us-east-2) - cidr_block - CIDR block for the VPC (default: 10.0.0.0/16) - project - Name of project this VPC is meant for (default: demo) - ami - Bastion Amazon Machine Image (AMI) ID - type - Instance type for bastion instance (default: t2.micro) - key - EC2 Key pair name for the bastion - access_key - access key id for the IAM user - secret_key - secret key for the IAM user ## How to Configure Initially, the file variables.tf will contain the variables used in the script. This can be modified according to the requirements in the default section like below. ``` variable "region" { default = "us-east-2" #provide your required region here instead of us-east-2 } ``` ## Installation Navigate to the project directory where the files are to be installed and follow the below steps ``` $ git clone https://github.com/jomyg/Terraform-VPC-sample.git ``` Next, use the 'terraform init' command is used to initialize a working directory containing Terraform configuration files. ``` $ terraform init ``` Then, use 'terraform plan' command to create an execution plan and then use 'terraform apply' to execute the plan. ``` $ terraform plan $ terraform apply ``` ## Result After the execution of this script, you will have a VPC which contains 3 public subnet as well as 3 private subnet ready to use. Also, EC2 bastion server with its custom security group attached to one of the public subnet. ### Connect with Me



近期下载者

相关文件


收藏者