diff --git a/Terraform_EC2_with_custom_install/config.auto.tfvars b/Terraform_EC2_with_custom_install/config.auto.tfvars new file mode 100755 index 0000000..f23e6a9 --- /dev/null +++ b/Terraform_EC2_with_custom_install/config.auto.tfvars @@ -0,0 +1,23 @@ +region = "us-east-2" + +namespace = "ai" + +stage = "train" + +name = "AI_dev_Train" + +availability_zones = "us-east-2a" + +assign_eip_address = false + +associate_public_ip_address = true + +instance_type = "g4dn.xlarge" + +ami = "ami-084aa4c7d8755422a" + +volume_size = 100 + +access_key = "AKIAV3FLEZJF6CWZBKEZ" + +secret_key = "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" diff --git a/Terraform_EC2_with_custom_install/key_generator/main.tf b/Terraform_EC2_with_custom_install/key_generator/main.tf new file mode 100755 index 0000000..4ef5819 --- /dev/null +++ b/Terraform_EC2_with_custom_install/key_generator/main.tf @@ -0,0 +1,25 @@ +resource "tls_private_key" "key_init" { + algorithm = var.key_algorithm + provisioner "local-exec" { + command = "rm -r -f keys" + } + provisioner "local-exec" { + command = "mkdir keys" + } +} +resource "aws_key_pair" "generated" { + depends_on = [tls_private_key.key_init] + key_name = var.key_name + public_key = tls_private_key.key_init.public_key_openssh +} +resource "local_file" "public_key_openssh" { + depends_on = [tls_private_key.key_init] + content = tls_private_key.key_init.public_key_openssh + filename = ".//keys/${var.key_name}.pub" +} + +resource "local_file" "private_key_pem" { + depends_on = [tls_private_key.key_init] + content = tls_private_key.key_init.private_key_pem + filename = ".//keys/${var.key_name}.pem" +} diff --git a/Terraform_EC2_with_custom_install/key_generator/variables.tf b/Terraform_EC2_with_custom_install/key_generator/variables.tf new file mode 100755 index 0000000..de8b2f3 --- /dev/null +++ b/Terraform_EC2_with_custom_install/key_generator/variables.tf @@ -0,0 +1,11 @@ +variable "key_name" { + type = string + default = "key" + description = "key name" +} + +variable "key_algorithm" { + type = string + default = "RSA" + description = "key algorithm eg: RSA and ECDSA" +} diff --git a/Terraform_EC2_with_custom_install/main.tf b/Terraform_EC2_with_custom_install/main.tf new file mode 100755 index 0000000..0442541 --- /dev/null +++ b/Terraform_EC2_with_custom_install/main.tf @@ -0,0 +1,34 @@ +provider "aws" { + access_key = var.access_key + secret_key = var.secret_key + region = var.region +} +module "vpc" { + source = ".//vpc" + name = var.name + instance_tenancy = "default" + enable_dns_hostnames = false + enable_dns_support = true + single_nat_gateway = false + map_public_ip_on_launch = true + assign_generated_ipv6_cidr_block = false + cidr = "10.0.0.0/16" + azs = var.availability_zones +} +module "key_creator" { + source = ".//key_generator" + key_name = var.name +} +module "ec2_instance" { + source = "terraform-aws-modules/ec2-instance/aws" + version = "~> 3.0" + name = "EC2-${var.name}" + associate_public_ip_address = var.associate_public_ip_address + instance_type = var.instance_type + vpc_security_group_ids = [module.vpc.security_group_id] + subnet_id = module.vpc.public_subnet + ami = var.ami + key_name = var.name + ebs_optimized = true + ebs_block_device = [{"device_name"="/dev/sda1","volume_size"=var.volume_size,"delete_on_termination"="true"}] +} diff --git a/Terraform_EC2_with_custom_install/terraform.tfstate b/Terraform_EC2_with_custom_install/terraform.tfstate new file mode 100755 index 0000000..eac0be0 --- /dev/null +++ b/Terraform_EC2_with_custom_install/terraform.tfstate @@ -0,0 +1,8 @@ +{ + "version": 4, + "terraform_version": "1.1.7", + "serial": 318, + "lineage": "75d86650-37d3-a9b6-4710-f7cf965759f5", + "outputs": {}, + "resources": [] +} diff --git a/Terraform_EC2_with_custom_install/terraform.tfstate.backup b/Terraform_EC2_with_custom_install/terraform.tfstate.backup new file mode 100755 index 0000000..e3743ef --- /dev/null +++ b/Terraform_EC2_with_custom_install/terraform.tfstate.backup @@ -0,0 +1,704 @@ +{ + "version": 4, + "terraform_version": "1.1.7", + "serial": 300, + "lineage": "75d86650-37d3-a9b6-4710-f7cf965759f5", + "outputs": {}, + "resources": [ + { + "module": "module.ec2_instance", + "mode": "managed", + "type": "aws_instance", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "index_key": 0, + "schema_version": 1, + "attributes": { + "ami": "ami-084aa4c7d8755422a", + "arn": "arn:aws:ec2:us-east-2:401938369099:instance/i-0e92ac153b8f36b78", + "associate_public_ip_address": true, + "availability_zone": "us-east-2a", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 2, + "cpu_threads_per_core": 2, + "credit_specification": [ + { + "cpu_credits": null + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 3000, + "kms_key_id": "", + "snapshot_id": "", + "tags": {}, + "throughput": 125, + "volume_id": "vol-08497ccd5b65fa352", + "volume_size": 100, + "volume_type": "gp3" + } + ], + "ebs_optimized": true, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": null, + "iam_instance_profile": "", + "id": "i-0e92ac153b8f36b78", + "instance_initiated_shutdown_behavior": "stop", + "instance_state": "running", + "instance_type": "g4dn.xlarge", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "AI_dev_Train", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": null, + "primary_network_interface_id": "eni-0062110ed84ba83fb", + "private_dns": "ip-10-0-125-8.us-east-2.compute.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.0.125.8", + "public_dns": "ec2-3-139-87-83.us-east-2.compute.amazonaws.com", + "public_ip": "3.139.87.83", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 3000, + "kms_key_id": "", + "tags": {}, + "throughput": 125, + "volume_id": "vol-08497ccd5b65fa352", + "volume_size": 100, + "volume_type": "gp3" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "subnet_id": "subnet-084d839ec120267db", + "tags": { + "Name": "EC2-AI_dev_Train" + }, + "tags_all": { + "Name": "EC2-AI_dev_Train" + }, + "tenancy": "default", + "timeouts": { + "create": null, + "delete": null, + "update": null + }, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": { + "Name": "EC2-AI_dev_Train" + }, + "vpc_security_group_ids": [ + "sg-09560a66375f46b75" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "module.vpc.aws_security_group.ec2", + "module.vpc.aws_subnet.public", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.key_creator", + "mode": "managed", + "type": "aws_key_pair", + "name": "generated", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:key-pair/AI_dev_Train", + "fingerprint": "4b:4f:52:14:a7:4f:21:9c:06:45:ca:37:60:96:6d:45", + "id": "AI_dev_Train", + "key_name": "AI_dev_Train", + "key_name_prefix": "", + "key_pair_id": "key-03eaab5aa8e7924ef", + "key_type": "rsa", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq5cWkI5xmeqYXURMMPKeomBdcG0aaV6UW01p5edkd9ufyW0M3N2I3ImjGkMuh1+Aa0OjsanjlSN34SlaZO75HKvNvtlF0+Aw3AT7nvoSZMc5EEYUohsMWTq/g7Yy4YD+SY98HcUDxqHXEpR5DrxJddkDTCEmRpsOmN85/ADHqaOggbgdteZE0BfG9H/chbu246ULWjD6HVhZsfDv9LolCf/YMB/HoMIT5oE7JncrlasbgCwZzHt4smWJIsvLS6Kzv0WrfH89BUlvxqBahqYoYznFju016PgJBlqzPVXmUqlkgAKz+rDOLuAkaFLFb3UeB4uZ5YkB1B8oOZYo0VF0V", + "tags": null, + "tags_all": {} + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "module.key_creator.tls_private_key.key_init" + ] + } + ] + }, + { + "module": "module.key_creator", + "mode": "managed", + "type": "local_file", + "name": "private_key_pem", + "provider": "provider[\"registry.terraform.io/hashicorp/local\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "content": "-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAquXFpCOcZnqmF1ETDDynqJgXXBtGmlelFtNaeXnZHfbn8ltD\nNzdiNyJoxpDLodfgGtDo7Gp45Ujd+EpWmTu+Ryrzb7ZRdPgMNwE+576EmTHORBGF\nKIbDFk6v4O2MuGA/kmPfB3FA8ah1xKUeQ68SXXZA0whJkabDpjfOfwAx6mjoIG4H\nbXmRNAXxvR/3IW7tuOlC1ow+h1YWbHw7/S6JQn/2DAfx6DCE+aBOyZ3K5WrG4AsG\ncx7eLJliSLLy0uis79Fq3x/PQVJb8agWoamKGM5xY7tNej4CQZasz1V5lKpZIACs\n/qwzi7gJGhSxW91HgeLmeWJAdQfKDmWKNFRdFQIDAQABAoIBAC19jjeb9xTcTvvj\n6+MU/jgFjCpLZGbPL7W8utedFKtCPwmnO2QmTPGKKkO45UuGcDQTKf1MdjPqSpO+\nDgEqAwNkrnotGM+++1lk7n63mwpAVLyPwVdBUArPFUgVU6D8lc984DBV+EibZAXd\nQgoYPxY71ROXoCWyM2A6eLAbuC3CIaNNGMmMrzSxjGXBvLxNndHEDXq1BtkMauhp\nAyRxq8fEyFs2g4cZ+34EKJjvsmcXo9m876yOW/oJX+d8tBXKqymjL4Zpw26iYmCa\nb8D6ln70e9sn9eE0xKZzs0Cfg5s9WKgsNdHmkUvAgTcLXA+IZx8vJbP71oilimem\npqii9qECgYEAyeG6R1T7G4f+Gh7+eENGPJGfrgRPjuRmb3R853CQe7OGZo2w5AOm\nuOaTmRWT74duAeZb5N5nudLGkMUC6/c6X97Lqxle4gJ1dMfikixuVVDblrMl1TX1\nBX8zbcHGPVvuyhbmjEJ0TVBKDtVTvnnE2rnXdy+NFIMZXoWA1p4xen0CgYEA2LW7\ngxGeisiIUV5/2LwqzakpCz/hAVCQLeex6cUAE5zZTcA++hZo+dDBJ8wwUHWoMzTA\nvBkjqw8JP2pKncPw2ffosNqs7WpzDePOK5T3tdZFfX8AMsPT+TRvKp79N/v3J3f4\np66b9pM3bqkAtXEbsBIpn0mTRlKx9aZuxWl42HkCgYEAxS5XblKfjQ1v7/1z2O0E\njiZCC4qkVlHZh2UEll1IkboQPNyJ+LtkPVbgtPXxb1Qc63gfK1TbhRFM5pu2tdjc\nyETpMu3t0dxK8sxFDTaecXAvemryOeSgtETAa6SHRukjO3nQpxBFXjpci05rpDB1\nSJmZzQzBxFYkEkFdTMJoW1UCgYBWzpVKL2iely1jysLTgqxyrWwvgWsUJ71ZZhIy\nXiNlt9Kj/no7m3Z5e1GkK3q/ACJcQKljr35GK0O9D0rMX4y/AztGfJIAmD92NOaF\nNqrzP92eI51kuGTU0lglboJoRpn+SWRlZuA6qUXvIeuSwrggk2Xw1HwWE1IN4JlG\norUxoQKBgHZNlB7S3Ibjjum69AXpRMVhbvmk78k1CxueofAO6NORugUE2H4Ct79J\nDpxdEBOQ77f6vqCiboFT7jBr6fGzkGsDniA1+Jdrc7jyOxkPeJjDqtC9m5CCncQ5\n/wujdjlX7zk+Rm6Zoc5Luw9Qpcg1IwYBPZFEUZv/SQqs41DoOFfB\n-----END RSA PRIVATE KEY-----\n", + "content_base64": null, + "directory_permission": "0777", + "file_permission": "0777", + "filename": ".//keys/AI_dev_Train.pem", + "id": "0b65db96e1a4fd190c072c53cb6e04ab73d1ad3a", + "sensitive_content": null, + "source": null + }, + "sensitive_attributes": [ + [ + { + "type": "get_attr", + "value": "content" + } + ] + ], + "private": "bnVsbA==", + "dependencies": [ + "module.key_creator.tls_private_key.key_init" + ] + } + ] + }, + { + "module": "module.key_creator", + "mode": "managed", + "type": "local_file", + "name": "public_key_openssh", + "provider": "provider[\"registry.terraform.io/hashicorp/local\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "content": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq5cWkI5xmeqYXURMMPKeomBdcG0aaV6UW01p5edkd9ufyW0M3N2I3ImjGkMuh1+Aa0OjsanjlSN34SlaZO75HKvNvtlF0+Aw3AT7nvoSZMc5EEYUohsMWTq/g7Yy4YD+SY98HcUDxqHXEpR5DrxJddkDTCEmRpsOmN85/ADHqaOggbgdteZE0BfG9H/chbu246ULWjD6HVhZsfDv9LolCf/YMB/HoMIT5oE7JncrlasbgCwZzHt4smWJIsvLS6Kzv0WrfH89BUlvxqBahqYoYznFju016PgJBlqzPVXmUqlkgAKz+rDOLuAkaFLFb3UeB4uZ5YkB1B8oOZYo0VF0V\n", + "content_base64": null, + "directory_permission": "0777", + "file_permission": "0777", + "filename": ".//keys/AI_dev_Train.pub", + "id": "80ee2c2862ca48a4b10dd5a78f621ab7cdab2f24", + "sensitive_content": null, + "source": null + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "module.key_creator.tls_private_key.key_init" + ] + } + ] + }, + { + "module": "module.key_creator", + "mode": "managed", + "type": "tls_private_key", + "name": "key_init", + "provider": "provider[\"registry.terraform.io/hashicorp/tls\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "algorithm": "RSA", + "ecdsa_curve": "P224", + "id": "1eba08d270fc86941f353b7c520cf46e3fca66c7", + "private_key_openssh": "-----BEGIN OPENSSH PRIVATE KEY-----\nb3Bl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8kZ+uBE+O5GZvdHzncJB7s4ZmjbDkA6a45pOZFZPvh24B5lvk3me50saQxQLr\n9zpf3surGV7iAnV0x+KSLG5VUNuWsyXVNfUFfzNtwcY9W+7KFuaMQnRNUEoO1VO+\necTaudd3L40UgxlehYDWnjF6fQKBgQDYtbuDEZ6KyIhRXn/YvCrNqSkLP+EBUJAt\n57HpxQATnNlNwD76Fmj50MEnzDBQdagzNMC8GSOrDwk/akqdw/DZ9+iw2qztanMN\n484rlPe11kV9fwAyw9P5NG8qnv03+/cnd/inrpv2kzduqQC1cRuwEimfSZNGUrH1\npm7FaXjYeQKBgQDFLlduUp+NDW/v/XPY7QSOJkILiqRWUdmHZQSWXUiRuhA83In4\nu2Q9VuC09fFvVBzreB8rVNuFEUzmm7a12NzIROky7e3R3EryzEUNNp5xcC96avI5\n5KC0RMBrpIdG6SM7edCnEEVeOlyLTmukMHVImZnNDMHEViQSQV1MwmhbVQKBgFbO\nlUovaJ6XLWPKwtOCrHKtbC+BaxQnvVlmEjJeI2W30qP+ejubdnl7UaQrer8AIlxA\nqWOvfkYrQ70PSsxfjL8DO0Z8kgCYP3Y05oU2qvM/3Z4jnWS4ZNTSWCVugmhGmf5J\nZGVm4DqpRe8h65LCuCCTZfDUfBYTUg3gmUaitTGhAoGAdk2UHtLchuOO6br0BelE\nxWFu+aTvyTULG56h8A7o05G6BQTYfgK3v0kOnF0QE5Dvt/q+oKJugVPuMGvp8bOQ\nawOeIDX4l2tzuPI7GQ94mMOq0L2bkIKdxDn/C6N2OVfvOT5Gbpmhzku7D1ClyDUj\nBgE9kURRm/9JCqzjUOg4V8E=\n-----END PRIVATE KEY-----\n", + "public_key_fingerprint_md5": "6a:33:58:b4:74:02:2b:43:aa:63:c9:87:22:8b:b3:fb", + "public_key_fingerprint_sha256": "SHA256:8VmDxlC/C7xq6iAaDmm8przpdYYuyhVgeS/HsD27a8s", + "public_key_openssh": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCq5cWkI5xmeqYXURMMPKeomBdcG0aaV6UW01p5edkd9ufyW0M3N2I3ImjGkMuh1+Aa0OjsanjlSN34SlaZO75HKvNvtlF0+Aw3AT7nvoSZMc5EEYUohsMWTq/g7Yy4YD+SY98HcUDxqHXEpR5DrxJddkDTCEmRpsOmN85/ADHqaOggbgdteZE0BfG9H/chbu246ULWjD6HVhZsfDv9LolCf/YMB/HoMIT5oE7JncrlasbgCwZzHt4smWJIsvLS6Kzv0WrfH89BUlvxqBahqYoYznFju016PgJBlqzPVXmUqlkgAKz+rDOLuAkaFLFb3UeB4uZ5YkB1B8oOZYo0VF0V\n", + "public_key_pem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAquXFpCOcZnqmF1ETDDyn\nqJgXXBtGmlelFtNaeXnZHfbn8ltDNzdiNyJoxpDLodfgGtDo7Gp45Ujd+EpWmTu+\nRyrzb7ZRdPgMNwE+576EmTHORBGFKIbDFk6v4O2MuGA/kmPfB3FA8ah1xKUeQ68S\nXXZA0whJkabDpjfOfwAx6mjoIG4HbXmRNAXxvR/3IW7tuOlC1ow+h1YWbHw7/S6J\nQn/2DAfx6DCE+aBOyZ3K5WrG4AsGcx7eLJliSLLy0uis79Fq3x/PQVJb8agWoamK\nGM5xY7tNej4CQZasz1V5lKpZIACs/qwzi7gJGhSxW91HgeLmeWJAdQfKDmWKNFRd\nFQIDAQAB\n-----END PUBLIC KEY-----\n", + "rsa_bits": 2048 + }, + "sensitive_attributes": [] + } + ] + }, + { + "module": "module.vpc", + "mode": "data", + "type": "aws_vpc_endpoint_service", + "name": "ec2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "acceptance_required": false, + "arn": "arn:aws:ec2:us-east-2:401938369099:vpc-endpoint-service/vpce-svc-0e2eb2a2a072ad8d3", + "availability_zones": [ + "us-east-2a", + "us-east-2b", + "us-east-2c" + ], + "base_endpoint_dns_names": [ + "ec2.us-east-2.vpce.amazonaws.com" + ], + "filter": null, + "id": "3657514829", + "manages_vpc_endpoints": false, + "owner": "amazon", + "private_dns_name": "ec2.us-east-2.amazonaws.com", + "service": "ec2", + "service_id": "vpce-svc-0e2eb2a2a072ad8d3", + "service_name": "com.amazonaws.us-east-2.ec2", + "service_type": "Interface", + "supported_ip_address_types": [ + "ipv4" + ], + "tags": {}, + "timeouts": null, + "vpc_endpoint_policy_supported": true + }, + "sensitive_attributes": [] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_internet_gateway", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:internet-gateway/igw-0059d7a0a5121e883", + "id": "igw-0059d7a0a5121e883", + "owner_id": "401938369099", + "tags": { + "name": "internet_gateway-AI_dev_Train" + }, + "tags_all": { + "name": "internet_gateway-AI_dev_Train" + }, + "timeouts": null, + "vpc_id": "vpc-091b7225cd47190f7" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19", + "dependencies": [ + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_network_acl", + "name": "public", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:network-acl/acl-05e9efb1d4fd942df", + "egress": [], + "id": "acl-05e9efb1d4fd942df", + "ingress": [], + "owner_id": "401938369099", + "subnet_ids": [ + "subnet-084d839ec120267db" + ], + "tags": null, + "tags_all": {}, + "vpc_id": "vpc-091b7225cd47190f7" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "module.vpc.aws_subnet.public", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_network_acl_rule", + "name": "public_inbound", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "cidr_block": "0.0.0.0/0", + "egress": true, + "from_port": 0, + "icmp_code": null, + "icmp_type": null, + "id": "nacl-1489889103", + "ipv6_cidr_block": "", + "network_acl_id": "acl-05e9efb1d4fd942df", + "protocol": "-1", + "rule_action": "allow", + "rule_number": 100, + "to_port": 0 + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "module.vpc.aws_network_acl.public", + "module.vpc.aws_subnet.public", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_network_acl_rule", + "name": "public_outbound", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "cidr_block": "0.0.0.0/0", + "egress": false, + "from_port": 0, + "icmp_code": null, + "icmp_type": null, + "id": "nacl-3185922683", + "ipv6_cidr_block": "", + "network_acl_id": "acl-05e9efb1d4fd942df", + "protocol": "-1", + "rule_action": "allow", + "rule_number": 100, + "to_port": 0 + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "module.vpc.aws_network_acl.public", + "module.vpc.aws_subnet.public", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_route_table", + "name": "public", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:route-table/rtb-0bda19aa52b87bc65", + "id": "rtb-0bda19aa52b87bc65", + "owner_id": "401938369099", + "propagating_vgws": [], + "route": [ + { + "carrier_gateway_id": "", + "cidr_block": "0.0.0.0/0", + "core_network_arn": "", + "destination_prefix_list_id": "", + "egress_only_gateway_id": "", + "gateway_id": "igw-0059d7a0a5121e883", + "instance_id": "", + "ipv6_cidr_block": "", + "local_gateway_id": "", + "nat_gateway_id": "", + "network_interface_id": "", + "transit_gateway_id": "", + "vpc_endpoint_id": "", + "vpc_peering_connection_id": "" + } + ], + "tags": { + "name": "route_table-AI_dev_Train" + }, + "tags_all": { + "name": "route_table-AI_dev_Train" + }, + "timeouts": null, + "vpc_id": "vpc-091b7225cd47190f7" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "module.vpc.aws_internet_gateway.this", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_route_table_association", + "name": "rta", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "gateway_id": "", + "id": "rtbassoc-0e50da599d7de3ad9", + "route_table_id": "rtb-0bda19aa52b87bc65", + "subnet_id": "subnet-084d839ec120267db" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "module.vpc.aws_internet_gateway.this", + "module.vpc.aws_route_table.public", + "module.vpc.aws_subnet.public", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_security_group", + "name": "ec2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:security-group/sg-09560a66375f46b75", + "description": "EC2 VPC Endpoint Security Group", + "egress": [], + "id": "sg-09560a66375f46b75", + "ingress": [], + "name": "vpc-endpoint-ec2-AI_dev_Train", + "name_prefix": "", + "owner_id": "401938369099", + "revoke_rules_on_delete": false, + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-091b7225cd47190f7" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_security_group_rule", + "name": "allow_all", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": null, + "from_port": 0, + "id": "sgrule-220629022", + "ipv6_cidr_blocks": null, + "prefix_list_ids": null, + "protocol": "-1", + "security_group_id": "sg-09560a66375f46b75", + "self": false, + "source_security_group_id": null, + "timeouts": null, + "to_port": 0, + "type": "egress" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "module.vpc.aws_security_group.ec2", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_security_group_rule", + "name": "vpc_endpoint_ec2_https", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 2, + "attributes": { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": null, + "from_port": 22, + "id": "sgrule-3068443800", + "ipv6_cidr_blocks": null, + "prefix_list_ids": null, + "protocol": "tcp", + "security_group_id": "sg-09560a66375f46b75", + "self": false, + "source_security_group_id": null, + "timeouts": null, + "to_port": 22, + "type": "ingress" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjIifQ==", + "dependencies": [ + "module.vpc.aws_security_group.ec2", + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_subnet", + "name": "public", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:subnet/subnet-084d839ec120267db", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-2a", + "availability_zone_id": "use2-az1", + "cidr_block": "10.0.0.0/16", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-084d839ec120267db", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "401938369099", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": { + "name": "subnet_vcp-AI_dev_Train" + }, + "tags_all": { + "name": "subnet_vcp-AI_dev_Train" + }, + "timeouts": null, + "vpc_id": "vpc-091b7225cd47190f7" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "module.vpc.aws_vpc.this" + ] + } + ] + }, + { + "module": "module.vpc", + "mode": "managed", + "type": "aws_vpc", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-2:401938369099:vpc/vpc-091b7225cd47190f7", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-03642f749c4beb9e3", + "default_route_table_id": "rtb-0194570145d364920", + "default_security_group_id": "sg-081c8782927409346", + "dhcp_options_id": "dopt-0a98a0b91754c0a1f", + "enable_classiclink": false, + "enable_classiclink_dns_support": false, + "enable_dns_hostnames": true, + "enable_dns_support": true, + "id": "vpc-091b7225cd47190f7", + "instance_tenancy": "default", + "ipv4_ipam_pool_id": null, + "ipv4_netmask_length": null, + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "ipv6_cidr_block_network_border_group": "", + "ipv6_ipam_pool_id": "", + "ipv6_netmask_length": 0, + "main_route_table_id": "rtb-0194570145d364920", + "owner_id": "401938369099", + "tags": { + "name": "vcp-AI_dev_Train" + }, + "tags_all": { + "name": "vcp-AI_dev_Train" + } + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" + } + ] + } + ] +} diff --git a/Terraform_EC2_with_custom_install/variables.tf b/Terraform_EC2_with_custom_install/variables.tf new file mode 100755 index 0000000..4121a39 --- /dev/null +++ b/Terraform_EC2_with_custom_install/variables.tf @@ -0,0 +1,58 @@ +variable "region" { + type = string + description = "AWS region" +} + +variable "access_key" { + type = string + description = "Access key ID" +} + +variable "secret_key" { + type = string + description = "Secret access key" +} + +variable "ami" { + type = string + description = "AMI ID" +} + +variable "namespace" { + type = string + description = "Namespace (e.g. `eg` or `cp`)" +} + +variable "stage" { + type = string + description = "Stage (e.g. `prod`, `dev`, `staging`, `infra`)" +} + +variable "name" { + type = string + description = "Name (e.g. `app` or `cluster`)" +} + +variable "availability_zones" { + type = string + description = "List of availability zones" +} + +variable "associate_public_ip_address" { + type = bool + description = "Associate a public IP address with the instance" +} + +variable "assign_eip_address" { + type = bool + description = "Assign an Elastic IP address to the instance" +} + +variable "instance_type" { + type = string + description = "The type of the instance" +} +variable "volume_size" { + type = string + description = "The size of the instance" +} diff --git a/Terraform_EC2_with_custom_install/vpc/README.md b/Terraform_EC2_with_custom_install/vpc/README.md new file mode 100755 index 0000000..5e5c1e2 --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/README.md @@ -0,0 +1,297 @@ +This module is addited by Majid Geravand. Braendler Engineering +================================================================ + +# AWS VPC Terraform module + +![Build Status](https://travis-ci.com/104corp/terraform-aws-vpc.svg?branch=master) ![LicenseBadge](https://img.shields.io/github/license/104corp/terraform-aws-vpc.svg) + +Terraform module which creates VPC resources on AWS. + +These types of resources are supported: + +* [VPC](https://www.terraform.io/docs/providers/aws/r/vpc.html) +* [Subnet](https://www.terraform.io/docs/providers/aws/r/subnet.html) +* [Route](https://www.terraform.io/docs/providers/aws/r/route.html) +* [Route table](https://www.terraform.io/docs/providers/aws/r/route_table.html) +* [Internet Gateway](https://www.terraform.io/docs/providers/aws/r/internet_gateway.html) +* [NAT Gateway](https://www.terraform.io/docs/providers/aws/r/nat_gateway.html) +* [VPN Gateway](https://www.terraform.io/docs/providers/aws/r/vpn_gateway.html) +* [VPC Endpoint](https://www.terraform.io/docs/providers/aws/r/vpc_endpoint.html) (S3 and DynamoDB) +* [DHCP Options Set](https://www.terraform.io/docs/providers/aws/r/vpc_dhcp_options.html) +* [Default VPC](https://www.terraform.io/docs/providers/aws/r/default_vpc.html) + +## Usage + +```hcl +module "vpc" { + source = "104corp/vpc/aws" + + name = "my-vpc" + cidr = "10.0.0.0/16" + + azs = ["ap-northeast-1a", "ap-northeast-1c","ap-northeast-1d"] + private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] + public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] + nat_subnets = ["10.0.10.0/24", "10.0.11.0/24", "10.0.12.0/24"] + + enable_vpn_gateway = true + + tags = { + Terraform = "true" + Environment = "dev" + } +} +``` + +## External NAT Gateway IPs + +By default this module will provision new Elastic IPs for the VPC's NAT Gateways. +This means that when creating a new VPC, new IPs are allocated, and when that VPC is destroyed those IPs are released. +Sometimes it is handy to keep the same IPs even after the VPC is destroyed and re-created. +To that end, it is possible to assign existing IPs to the NAT Gateways. +This prevents the destruction of the VPC from releasing those IPs, while making it possible that a re-created VPC uses the same IPs. + +To achieve this, allocate the IPs outside the VPC module declaration. +```hcl +resource "aws_eip" "nat" { + count = 3 + + vpc = true +} +``` + +Then, pass the allocated IPs as a parameter to this module. +```hcl +module "vpc" { + source = "104corp/vpc/aws" + + # The rest of arguments are omitted for brevity + + enable_nat_gateway = true + single_nat_gateway = false + reuse_nat_ips = true # <= Skip creation of EIPs for the NAT Gateways + external_nat_ip_ids = ["${aws_eip.nat.*.id}"] # <= IPs specified here as input to the module +} +``` + +Note that in the example we allocate 3 IPs because we will be provisioning 3 NAT Gateways (due to `single_nat_gateway = false` and having 3 subnets). +If, on the other hand, `single_nat_gateway = true`, then `aws_eip.nat` would only need to allocate 1 IP. +Passing the IPs into the module is done by setting two variables `reuse_nat_ips = true` and `external_nat_ip_ids = ["${aws_eip.nat.*.id}"]`. + +## NAT Gateway Scenarios + +This module supports three scenarios for creating NAT gateways. Each will be explained in further detail in the corresponding sections. + +* One NAT Gateway per subnet (default behavior) + * `enable_nat_gateway = true` + * `single_nat_gateway = false` + * `one_nat_gateway_per_az = false` +* Single NAT Gateway + * `enable_nat_gateway = true` + * `single_nat_gateway = true` + * `one_nat_gateway_per_az = false` +* One NAT Gateway per availability zone + * `enable_nat_gateway = true` + * `single_nat_gateway = false` + * `one_nat_gateway_per_az = true` + +If both `single_nat_gateway` and `one_nat_gateway_per_az` are set to `true`, then `single_nat_gateway` takes precedence. + +### One NAT Gateway per subnet (default) + +By default, the module will determine the number of NAT Gateways to create based on the the `max()` of the private subnet lists. + +```hcl +private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24", "10.0.4.0/24", "10.0.5.0/24"] +public_subnets = ["10.0.41.0/24", "10.0.42.0/24"] +nat_subnets = ["10.0.51.0/24", "10.0.52.0/24", "10.0.53.0/24"] +``` + +Then `3` NAT Gateways will be created since `3` private subnet CIDR blocks were specified. + +### Single NAT Gateway + +If `single_nat_gateway = true`, then all private subnets will route their Internet traffic through this single NAT gateway. The NAT gateway will be placed in the first public subnet in your `public_subnets` block. + +### One NAT Gateway per availability zone + +If `one_nat_gateway_per_az = true` and `single_nat_gateway = false`, then the module will place one NAT gateway in each availability zone you specify in `var.azs`. There are some requirements around using this feature flag: + +* The variable `var.azs` **must** be specified. +* The number of public subnet CIDR blocks specified in `public_subnets` **must** be greater than or equal to the number of availability zones specified in `var.azs`. This is to ensure that each NAT Gateway has a dedicated public subnet to deploy to. + +## Conditional creation + +Sometimes you need to have a way to create VPC resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_vpc`. + +```hcl +# This VPC will not be created +module "vpc" { + source = "104corp/vpc/aws" + + create_vpc = false + # ... omitted +} +``` + +## Terraform version + +Terraform version 0.10.3 or newer is required for this module to work. + +## Examples + +* [Simple VPC](https://github.com/104corp/terraform-aws-vpc/tree/master/examples/simple-vpc) +* [Complete VPC](https://github.com/104corp/terraform-aws-vpc/tree/master/examples/complete-vpc) +* [Manage Default VPC](https://github.com/104corp/terraform-aws-vpc/tree/master/examples/manage-default-vpc) + +## Tests + +This module has been packaged with [awspec](https://github.com/k1LoW/awspec) tests through test kitchen. To run them: + +1. Install [rvm](https://rvm.io/rvm/install) and the ruby version specified in the [Gemfile](https://github.com/104corp/terraform-aws-vpc/blob/master/Gemfile). +2. Install bundler and the gems from our Gemfile: +``` +gem install bundler; bundle install +``` +3. Test using `bundle exec kitchen test` from the root of the repo. + +## Authors + +Module is maintained by [104corp](https://github.com/104corp). + +basic fork of [Anton Babenko](https://github.com/antonbabenko) + +## License + +Apache 2 Licensed. See LICENSE for full details. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| assign\_generated\_ipv6\_cidr\_block | Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block | string | `"false"` | no | +| azs | A list of availability zones in the region | list | `` | no | +| cidr | The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overriden | string | `"0.0.0.0/0"` | no | +| create\_vpc | Controls if VPC should be created (it affects almost all resources) | string | `"true"` | no | +| default\_network\_acl\_egress | List of maps of egress rules to set on the Default Network ACL | list | `` | no | +| default\_network\_acl\_ingress | List of maps of ingress rules to set on the Default Network ACL | list | `` | no | +| default\_network\_acl\_name | Name to be used on the Default Network ACL | string | `""` | no | +| default\_network\_acl\_tags | Additional tags for the Default Network ACL | map | `` | no | +| default\_vpc\_enable\_classiclink | Should be true to enable ClassicLink in the Default VPC | string | `"false"` | no | +| default\_vpc\_enable\_dns\_hostnames | Should be true to enable DNS hostnames in the Default VPC | string | `"false"` | no | +| default\_vpc\_enable\_dns\_support | Should be true to enable DNS support in the Default VPC | string | `"true"` | no | +| default\_vpc\_name | Name to be used on the Default VPC | string | `""` | no | +| default\_vpc\_tags | Additional tags for the Default VPC | map | `` | no | +| dhcp\_options\_domain\_name | Specifies DNS name for DHCP options set | string | `""` | no | +| dhcp\_options\_domain\_name\_servers | Specify a list of DNS server addresses for DHCP options set, default to AWS provided | list | `` | no | +| dhcp\_options\_netbios\_name\_servers | Specify a list of netbios servers for DHCP options set | list | `` | no | +| dhcp\_options\_netbios\_node\_type | Specify netbios node_type for DHCP options set | string | `""` | no | +| dhcp\_options\_ntp\_servers | Specify a list of NTP servers for DHCP options set | list | `` | no | +| dhcp\_options\_tags | Additional tags for the DHCP option set | map | `` | no | +| ec2\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2 endpoint | string | `"false"` | no | +| ec2\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2 endpoint | list | `` | no | +| ec2\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EC2 endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `` | no | +| ec2messages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for EC2 messages endpoint | string | `"false"` | no | +| ec2messages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for EC2 messages endpoint | list | `` | no | +| ec2messages\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for EC2 messages endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `` | no | +| enable\_dhcp\_options | Should be true if you want to specify a DHCP options set with a custom domain name, DNS servers, NTP servers, netbios servers, and/or netbios server type | string | `"false"` | no | +| enable\_dns\_hostnames | Should be true to enable DNS hostnames in the VPC | string | `"false"` | no | +| enable\_dns\_support | Should be true to enable DNS support in the VPC | string | `"true"` | no | +| enable\_dynamodb\_endpoint | Should be true if you want to provision a DynamoDB endpoint to the VPC | string | `"false"` | no | +| enable\_ec2\_endpoint | Should be true if you want to provision an EC2 endpoint to the VPC | string | `"false"` | no | +| enable\_ec2messages\_endpoint | Should be true if you want to provision an EC2 messages endpoint to the VPC | string | `"false"` | no | +| enable\_s3\_endpoint | Should be true if you want to provision an S3 endpoint to the VPC | string | `"false"` | no | +| enable\_ssm\_endpoint | Should be true if you want to provision an SSM endpoint to the VPC | string | `"false"` | no | +| enable\_ssmmessages\_endpoint | Should be true if you want to provision a SSMMESSAGES endpoint to the VPC | string | `"false"` | no | +| enable\_vpn\_gateway | Should be true if you want to create a new VPN Gateway resource and attach it to the VPC | string | `"false"` | no | +| external\_nat\_ip\_ids | List of EIP IDs to be assigned to the NAT Gateways (used in combination with reuse_nat_ips) | list | `` | no | +| igw\_tags | Additional tags for the internet gateway | map | `` | no | +| instance\_tenancy | A tenancy option for instances launched into the VPC | string | `"default"` | no | +| manage\_default\_network\_acl | Should be true to adopt and manage Default Network ACL | string | `"false"` | no | +| manage\_default\_vpc | Should be true to adopt and manage Default VPC | string | `"false"` | no | +| map\_public\_ip\_on\_launch | Should be false if you do not want to auto-assign public IP on launch | string | `"true"` | no | +| name | Name to be used on all the resources as identifier | string | `""` | no | +| nat\_acl\_tags | Additional tags for the public subnets network ACL | map | `` | no | +| nat\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for nat subnets | string | `"false"` | no | +| nat\_eip\_tags | Additional tags for the NAT EIP | map | `` | no | +| nat\_gateway\_tags | Additional tags for the NAT gateways | map | `` | no | +| nat\_inbound\_acl\_rules | NAT subnets inbound network ACLs | list | `` | no | +| nat\_outbound\_acl\_rules | NAT subnets outbound network ACLs | list | `` | no | +| nat\_route\_table\_tags | Additional tags for the intra route tables | map | `` | no | +| nat\_subnet\_suffix | Suffix to append to NAT subnets name | string | `"nat"` | no | +| nat\_subnet\_tags | Additional tags for the intra subnets | map | `` | no | +| nat\_subnets | A list of nat subnets | list | `` | no | +| one\_nat\_gateway\_per\_az | Should be true if you want only one NAT Gateway per availability zone. Requires `var.azs` to be set, and the number of `public_subnets` created to be greater than or equal to the number of availability zones specified in `var.azs`. | string | `"false"` | no | +| private\_acl\_tags | Additional tags for the public subnets network ACL | map | `` | no | +| private\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for private subnets | string | `"false"` | no | +| private\_inbound\_acl\_rules | Private subnets inbound network ACLs | list | `` | no | +| private\_outbound\_acl\_rules | Private subnets outbound network ACLs | list | `` | no | +| private\_route\_table\_tags | Additional tags for the private route tables | map | `` | no | +| private\_subnet\_suffix | Suffix to append to private subnets name | string | `"private"` | no | +| private\_subnet\_tags | Additional tags for the private subnets | map | `` | no | +| private\_subnets | A list of private subnets inside the VPC | list | `` | no | +| propagate\_private\_route\_tables\_vgw | Should be true if you want route table propagation | string | `"false"` | no | +| propagate\_public\_route\_tables\_vgw | Should be true if you want route table propagation | string | `"false"` | no | +| public\_acl\_tags | Additional tags for the public subnets network ACL | map | `` | no | +| public\_dedicated\_network\_acl | Whether to use dedicated network ACL (not default) and custom rules for public subnets | string | `"false"` | no | +| public\_inbound\_acl\_rules | Public subnets inbound network ACLs | list | `` | no | +| public\_outbound\_acl\_rules | Public subnets outbound network ACLs | list | `` | no | +| public\_route\_table\_tags | Additional tags for the public route tables | map | `` | no | +| public\_subnet\_suffix | Suffix to append to public subnets name | string | `"public"` | no | +| public\_subnet\_tags | Additional tags for the public subnets | map | `` | no | +| public\_subnets | A list of public subnets inside the VPC | list | `` | no | +| reuse\_nat\_ips | Should be true if you don't want EIPs to be created for your NAT Gateways and will instead pass them in via the 'external_nat_ip_ids' variable | string | `"false"` | no | +| secondary\_cidr\_blocks | List of secondary CIDR blocks to associate with the VPC to extend the IP Address pool | list | `` | no | +| single\_nat\_gateway | Should be true if you want to provision a single shared NAT Gateway across all of your private networks | string | `"false"` | no | +| ssm\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSM endpoint | string | `"false"` | no | +| ssm\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSM endpoint | list | `` | no | +| ssm\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SSM endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `` | no | +| ssmmessages\_endpoint\_private\_dns\_enabled | Whether or not to associate a private hosted zone with the specified VPC for SSMMESSAGES endpoint | string | `"false"` | no | +| ssmmessages\_endpoint\_security\_group\_ids | The ID of one or more security groups to associate with the network interface for SSMMESSAGES endpoint | list | `` | no | +| ssmmessages\_endpoint\_subnet\_ids | The ID of one or more subnets in which to create a network interface for SSMMESSAGES endpoint. Only a single subnet within an AZ is supported. If omitted, private subnets will be used. | list | `` | no | +| tags | A map of tags to add to all resources | map | `` | no | +| vpc\_tags | Additional tags for the VPC | map | `` | no | +| vpn\_gateway\_id | ID of VPN Gateway to attach to the VPC | string | `""` | no | +| vpn\_gateway\_tags | Additional tags for the VPN gateway | map | `` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| azs | List of AZs of the VPC | +| default\_network\_acl\_id | The ID of the default network ACL | +| default\_route\_table\_id | The ID of the default route table | +| default\_security\_group\_id | The ID of the security group created by default on VPC creation | +| default\_vpc\_cidr\_block | The CIDR block of the VPC | +| default\_vpc\_default\_network\_acl\_id | The ID of the default network ACL | +| default\_vpc\_default\_route\_table\_id | The ID of the default route table | +| default\_vpc\_default\_security\_group\_id | The ID of the security group created by default on VPC creation | +| default\_vpc\_enable\_dns\_hostnames | Whether or not the VPC has DNS hostname support | +| default\_vpc\_enable\_dns\_support | Whether or not the VPC has DNS support | +| default\_vpc\_id | The ID of the VPC | +| default\_vpc\_instance\_tenancy | Tenancy of instances spin up within VPC | +| default\_vpc\_main\_route\_table\_id | The ID of the main route table associated with this VPC | +| igw\_id | The ID of the Internet Gateway | +| nat\_ids | List of allocation ID of Elastic IPs created for AWS NAT Gateway | +| nat\_public\_ips | List of public Elastic IPs created for AWS NAT Gateway | +| nat\_route\_table\_ids | List of IDs of nat route tables | +| nat\_subnets | List of IDs of nat subnets | +| nat\_subnets\_cidr\_blocks | List of cidr_blocks of nat subnets | +| natgw\_ids | List of NAT Gateway IDs | +| private\_route\_table\_ids | List of IDs of private route tables | +| private\_subnets | List of IDs of private subnets | +| private\_subnets\_cidr\_blocks | List of cidr_blocks of private subnets | +| public\_route\_table\_ids | List of IDs of public route tables | +| public\_subnets | List of IDs of public subnets | +| public\_subnets\_cidr\_blocks | List of cidr_blocks of public subnets | +| vgw\_id | The ID of the VPN Gateway | +| vpc\_cidr\_block | The CIDR block of the VPC | +| vpc\_enable\_dns\_hostnames | Whether or not the VPC has DNS hostname support | +| vpc\_enable\_dns\_support | Whether or not the VPC has DNS support | +| vpc\_endpoint\_dynamodb\_id | The ID of VPC endpoint for DynamoDB | +| vpc\_endpoint\_dynamodb\_pl\_id | The prefix list for the DynamoDB VPC endpoint. | +| vpc\_endpoint\_s3\_id | The ID of VPC endpoint for S3 | +| vpc\_endpoint\_s3\_pl\_id | The prefix list for the S3 VPC endpoint. | +| vpc\_id | The ID of the VPC | +| vpc\_instance\_tenancy | Tenancy of instances spin up within VPC | +| vpc\_main\_route\_table\_id | The ID of the main route table associated with this VPC | diff --git a/Terraform_EC2_with_custom_install/vpc/acl.tf b/Terraform_EC2_with_custom_install/vpc/acl.tf new file mode 100755 index 0000000..2f8f75f --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/acl.tf @@ -0,0 +1,29 @@ +######################## +# Public Network ACLs +######################## +resource "aws_network_acl" "public" { + vpc_id = "${aws_vpc.this.id}" + subnet_ids = ["${aws_subnet.public.id}"] +} + +resource "aws_network_acl_rule" "public_inbound" { + network_acl_id = "${aws_network_acl.public.id}" + egress = true + rule_number = 100 + rule_action = "allow" + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_block = "0.0.0.0/0" +} + +resource "aws_network_acl_rule" "public_outbound" { + network_acl_id = "${aws_network_acl.public.id}" + egress = false + rule_number = 100 + rule_action = "allow" + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_block = "0.0.0.0/0" +} diff --git a/Terraform_EC2_with_custom_install/vpc/endpoint.tf b/Terraform_EC2_with_custom_install/vpc/endpoint.tf new file mode 100755 index 0000000..d53de7d --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/endpoint.tf @@ -0,0 +1,38 @@ +############################### +# VPC Endpoint for EC2 +############################### +data "aws_vpc_endpoint_service" "ec2" { + service = "ec2" +} + +resource "aws_security_group" "ec2" { + name = "vpc-endpoint-ec2-${var.name}" + description = "EC2 VPC Endpoint Security Group" + vpc_id = "${local.vpc_id}" +} + +#resource "aws_vpc_endpoint" "ec2" { +# vpc_id = "${local.vpc_id}" +# service_name = "${data.aws_vpc_endpoint_service.ec2.service_name}" +# vpc_endpoint_type = "Interface" + +# security_group_ids = ["${aws_security_group.ec2.id}"] +# subnet_ids = ["${aws_subnet.public.id}"] +#} + +resource "aws_security_group_rule" "vpc_endpoint_ec2_https" { + cidr_blocks = ["0.0.0.0/0"] + type = "ingress" + protocol = "tcp" + from_port = 22 + to_port = 22 + security_group_id = "${aws_security_group.ec2.id}" +} +resource "aws_security_group_rule" "allow_all" { + cidr_blocks = ["0.0.0.0/0"] + type = "egress" + to_port = 0 + protocol = "-1" + from_port = 0 + security_group_id = "${aws_security_group.ec2.id}" +} diff --git a/Terraform_EC2_with_custom_install/vpc/main.tf b/Terraform_EC2_with_custom_install/vpc/main.tf new file mode 100755 index 0000000..a3ada77 --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/main.tf @@ -0,0 +1,62 @@ +terraform { + required_version = ">= 0.10.3" # introduction of Local Values configuration language feature +} + +locals { + vpc_id = "${aws_vpc.this.id}" +} + +###### +# VPC +###### +resource "aws_vpc" "this" { + tags ={ + name = "vcp-${var.name}" + } + cidr_block = "${var.cidr}" + instance_tenancy = "${var.instance_tenancy}" + enable_dns_hostnames = true + enable_dns_support = "${var.enable_dns_support}" + assign_generated_ipv6_cidr_block = "${var.assign_generated_ipv6_cidr_block}" +} + +################### +# Internet Gateway +################### +resource "aws_internet_gateway" "this" { + tags ={ + name = "internet_gateway-${var.name}" + } + vpc_id = "${local.vpc_id}" +} + +################ +# Publiс routes +################ +resource "aws_route_table" "public" { + tags ={ + name = "route_table-${var.name}" + } + vpc_id = "${local.vpc_id}" + route { + cidr_block = "0.0.0.0/0" + gateway_id = "${aws_internet_gateway.this.id}" + } +} +resource "aws_route_table_association" "rta" { + subnet_id = "${aws_subnet.public.id}" + route_table_id = "${aws_route_table.public.id}" +} + +################ +# Public subnet +################ +resource "aws_subnet" "public" { + tags ={ + name = "subnet_vcp-${var.name}" + } + vpc_id = "${local.vpc_id}" + cidr_block = aws_vpc.this.cidr_block + availability_zone = "${var.azs}" + map_public_ip_on_launch = "${var.map_public_ip_on_launch}" +} diff --git a/Terraform_EC2_with_custom_install/vpc/outputs.tf b/Terraform_EC2_with_custom_install/vpc/outputs.tf new file mode 100755 index 0000000..3fcbc97 --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/outputs.tf @@ -0,0 +1,72 @@ +# VPC +output "vpc_id" { + description = "The ID of the VPC" + value = "${aws_vpc.this.id}" +} + +output "vpc_cidr_block" { + description = "The CIDR block of the VPC" + value = "${aws_vpc.this.cidr_block}" +} + +output "azs" { + description = "List of AZs of the VPC" + value = ["${var.azs}"] +} + +output "security_group_id" { + description = "The ID of the security group created by default on VPC creation" + value = "${aws_security_group.ec2.id}" +} + +output "network_acl_id" { + description = "The ID of the default network ACL" + value = "${aws_vpc.this.default_network_acl_id}" +} + +output "route_table_id" { + description = "The ID of the default route table" + value = "${aws_vpc.this.default_route_table_id}" +} + +output "vpc_instance_tenancy" { + description = "Tenancy of instances spin up within VPC" + value = "${aws_vpc.this.instance_tenancy}" +} + +output "vpc_enable_dns_support" { + description = "Whether or not the VPC has DNS support" + value = "${aws_vpc.this.enable_dns_support}" +} + +output "vpc_enable_dns_hostnames" { + description = "Whether or not the VPC has DNS hostname support" + value = "${aws_vpc.this.enable_dns_hostnames}" +} + +output "vpc_main_route_table_id" { + description = "The ID of the main route table associated with this VPC" + value = "${aws_vpc.this.main_route_table_id}" +} + +output "public_subnet" { + description = "ID of public subnets" + value = "${aws_subnet.public.id}" +} + +output "public_subnets_cidr_blocks" { + description = "List of cidr_blocks of public subnets" + value = ["${aws_subnet.public.cidr_block}"] +} + +# Route tables +output "public_route_table_ids" { + description = "List of IDs of public route tables" + value = ["${aws_route_table.public.id}"] +} + +# Internet Gateway +output "igw_id" { + description = "The ID of the Internet Gateway" + value = "${aws_internet_gateway.this.id}" +} diff --git a/Terraform_EC2_with_custom_install/vpc/variables.tf b/Terraform_EC2_with_custom_install/vpc/variables.tf new file mode 100755 index 0000000..dfcf6b2 --- /dev/null +++ b/Terraform_EC2_with_custom_install/vpc/variables.tf @@ -0,0 +1,44 @@ +variable "name" { + description = "Name to be used on all the resources as identifier" + default = "" +} + +variable "cidr" { + description = "The CIDR block for the VPC. Default value is a valid CIDR, but not acceptable by AWS and should be overriden" + default = "0.0.0.0/0" +} + +variable "assign_generated_ipv6_cidr_block" { + description = "Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block" + default = false +} + +variable "instance_tenancy" { + description = "A tenancy option for instances launched into the VPC" + default = "default" +} + +variable "azs" { + description = "A list of availability zones in the region" + type = string +} + +variable "enable_dns_hostnames" { + description = "Should be true to enable DNS hostnames in the VPC" + default = false +} + +variable "enable_dns_support" { + description = "Should be true to enable DNS support in the VPC" + default = true +} + +variable "single_nat_gateway" { + description = "Should be true if you want to provision a single shared NAT Gateway across all of your private networks" + default = false +} + +variable "map_public_ip_on_launch" { + description = "Should be false if you do not want to auto-assign public IP on launch" + default = true +}