this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Restructure infra and add virtual machine module

+197 -43
+2 -1
.gitignore
··· 1 - .terragrunt-cache/ 1 + .terraform* 2 + *.auto.tfvars
+9 -26
README.md
··· 41 41 - A credit/debit card to register for the accounts. 42 42 - Basic knowledge on Terraform and Ansible (optional, but will help a lot) 43 43 44 - Create initial configurations, it will prompt you for the information. 44 + Configuration files: 45 45 46 - ```sh 47 - make prereqs 48 - ``` 46 + <details> <summary>Terraform Cloud (`~/.terraform.d/credentials.tfrc.json`)</summary> 49 47 50 - Continue reading to see what to fill in. 48 + - Create a Terraform account 49 + - Run `terraform login` and follow the instruction 51 50 52 - <details> <summary>Oracle Cloud</summary> 51 + </details> 52 + 53 + <details> <summary>Oracle Cloud (`~/.oci/config` and `~/.oci/private.pem`)</summary> 53 54 54 55 - Create an Oracle Cloud account 55 56 - Generate an API signing key: 56 57 - Profile menu (User menu icon) -> User Settings -> API Keys -> Add API Key 57 - - Select Generate API Key Pair, download the private key and click Add 58 - - Check the Configuration File Preview for the values 59 - 60 - </details> 61 - 62 - <details> <summary>Google Cloud</summary> 63 - 64 - No resource on GCP yet 65 - 66 - </details> 67 - 68 - <details> <summary>AWS</summary> 69 - 70 - No resource on AWS yet 71 - 72 - </details> 73 - 74 - <details> <summary>Azure</summary> 75 - 76 - No resource on Azure yet 58 + - Select Generate API Key Pair, download the private key to `~/.oci/private.pem` and click Add 59 + - Copy the Configuration File Preview to `~/.oci/config` and change `key_file` to `~/.oci/private.pem` 77 60 78 61 </details> 79 62
+6 -3
infra/Makefile
··· 1 - default: apply 1 + default: init apply 2 + 3 + init: 4 + terraform init 2 5 3 6 plan: 4 - terragrunt run-all plan 7 + terraform plan 5 8 6 9 apply: 7 - terragrunt run-all apply 10 + terraform apply
-3
infra/config.hcl
··· 1 - # remote_state { 2 - # backend = "s3" 3 - # }
-10
infra/mail-server/terragrunt.hcl
··· 1 - include { 2 - path = find_in_parent_folders("config.hcl") 3 - } 4 - 5 - terraform { 6 - source = "../modules//vm" 7 - } 8 - 9 - inputs = { 10 - }
+3
infra/main.tf
··· 1 + module "virtual_machine" { 2 + source = "./modules/virtual-machine" 3 + }
infra/modules/README.md

This is a binary file and will not be displayed.

+17
infra/modules/virtual-machine/cloud-init.yaml
··· 1 + #cloud-config 2 + 3 + package_update: true 4 + 5 + packages: 6 + - apt-transport-https 7 + - ca-certificates 8 + - curl 9 + - gnupg 10 + - lsb-release 11 + 12 + runcmd: 13 + - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 14 + - echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 15 + - apt-get update 16 + - apt-get install -y docker-ce docker-ce-cli containerd.io python3-docker 17 + - systemctl enable --now docker
+122
infra/modules/virtual-machine/main.tf
··· 1 + resource "tls_private_key" "ssh" { 2 + algorithm = "ECDSA" 3 + ecdsa_curve = "P256" 4 + } 5 + 6 + resource "local_file" "ssh_private_key" { 7 + content = tls_private_key.ssh.private_key_pem 8 + filename = "${path.module}/private.pem" 9 + file_permission = "0600" 10 + } 11 + 12 + resource "oci_core_instance" "instance" { 13 + availability_domain = "gHLA:US-SANJOSE-1-AD-1" # TODO 14 + compartment_id = var.compartment_id 15 + shape = var.instance_shape 16 + 17 + instance_options { 18 + are_legacy_imds_endpoints_disabled = true 19 + } 20 + 21 + create_vnic_details { 22 + assign_public_ip = "true" 23 + subnet_id = oci_core_subnet.subnet.id 24 + } 25 + 26 + source_details { 27 + source_type = "image" 28 + source_id = var.instance_image_id 29 + } 30 + 31 + metadata = { 32 + ssh_authorized_keys = tls_private_key.ssh.public_key_openssh 33 + user_data = filebase64("${path.module}/cloud-init.yaml") 34 + } 35 + } 36 + 37 + resource "oci_core_vcn" "vcn" { 38 + cidr_block = var.vcn_cidr_blocks[0] # TODO deprecated, use cidr_blocks instead 39 + compartment_id = var.compartment_id 40 + } 41 + 42 + resource "oci_core_security_list" "security_list" { 43 + compartment_id = var.compartment_id 44 + vcn_id = oci_core_vcn.vcn.id 45 + 46 + ingress_security_rules { 47 + description = "Wireguard" 48 + protocol = "17" # UDP 49 + source = "0.0.0.0/0" 50 + stateless = false 51 + 52 + udp_options { 53 + source_port_range { 54 + min = 1 55 + max = 65535 56 + } 57 + 58 + min = 51820 59 + max = 51820 60 + } 61 + } 62 + 63 + ingress_security_rules { 64 + description = "HTTP" 65 + protocol = "6" # TCP 66 + source = "0.0.0.0/0" 67 + stateless = false 68 + 69 + tcp_options { 70 + source_port_range { 71 + min = 1 72 + max = 65535 73 + } 74 + 75 + min = 80 76 + max = 80 77 + } 78 + } 79 + 80 + ingress_security_rules { 81 + description = "HTTPS" 82 + protocol = "6" # TCP 83 + source = "0.0.0.0/0" 84 + stateless = false 85 + 86 + tcp_options { 87 + source_port_range { 88 + min = 1 89 + max = 65535 90 + } 91 + 92 + min = 443 93 + max = 443 94 + } 95 + } 96 + } 97 + 98 + resource "oci_core_subnet" "subnet" { 99 + cidr_block = var.subnet_cidr_block 100 + compartment_id = var.compartment_id 101 + route_table_id = oci_core_vcn.vcn.default_route_table_id 102 + vcn_id = oci_core_vcn.vcn.id 103 + 104 + security_list_ids = [ 105 + oci_core_vcn.vcn.default_security_list_id, 106 + oci_core_security_list.security_list.id 107 + ] 108 + } 109 + 110 + resource "oci_core_internet_gateway" "internet_gateway" { 111 + compartment_id = var.compartment_id 112 + vcn_id = oci_core_vcn.vcn.id 113 + } 114 + 115 + resource "oci_core_default_route_table" "default_route_table" { 116 + route_rules { 117 + destination = "0.0.0.0/0" 118 + destination_type = "CIDR_BLOCK" 119 + network_entity_id = oci_core_internet_gateway.internet_gateway.id 120 + } 121 + manage_default_resource_id = oci_core_vcn.vcn.default_route_table_id 122 + }
+8
infra/modules/virtual-machine/terraform.tf
··· 1 + terraform { 2 + required_providers { 3 + oci = { 4 + source = "hashicorp/oci" 5 + version = "4.43.0" 6 + } 7 + } 8 + }
+21
infra/modules/virtual-machine/variables.tf
··· 1 + variable "instance_shape" { 2 + default = "VM.Standard.E2.1.Micro" 3 + } 4 + 5 + variable "compartment_id" { 6 + default = "ocid1.compartment.oc1..aaaaaaaasvkl7yw6gj2pytybimo6ax7fg2jq7m4t5aueig3xrnfxwo7xwulq" 7 + } 8 + 9 + variable "instance_image_id" { 10 + default = "ocid1.image.oc1.us-sanjose-1.aaaaaaaan4g4q527bljtyczck6xrsutbzps6h7mut2xcfhnbzw66sbbsvwoq" 11 + } 12 + 13 + variable "vcn_cidr_blocks" { 14 + default = [ 15 + "10.0.0.0/16" 16 + ] 17 + } 18 + 19 + variable "subnet_cidr_block" { 20 + default = "10.0.0.0/24" 21 + }
infra/modules/vm/main.tf

This is a binary file and will not be displayed.

infra/modules/vm/terraform.tf

This is a binary file and will not be displayed.

infra/modules/vm/variables.tf infra/variables.tf
+9
infra/terraform.tf
··· 1 + terraform { 2 + backend "remote" { 3 + organization = "khuedoan" 4 + 5 + workspaces { 6 + name = "freecloud" 7 + } 8 + } 9 + }