{"id":20610876,"url":"https://github.com/psmths/vultr-terraform-example","last_synced_at":"2025-09-26T11:31:16.440Z","repository":{"id":117461789,"uuid":"342120176","full_name":"Psmths/vultr-terraform-example","owner":"Psmths","description":"Example demonstrating how to deploy an Apache 2 instance on Vultr using terraform.","archived":false,"fork":false,"pushed_at":"2021-03-09T05:01:21.000Z","size":23,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-08T05:51:27.821Z","etag":null,"topics":["example","terraform","vultr"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Psmths.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-25T04:15:57.000Z","updated_at":"2025-02-16T17:43:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf7c6faf-c83f-4b5a-ba0a-3ba147b33081","html_url":"https://github.com/Psmths/vultr-terraform-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Psmths/vultr-terraform-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Psmths%2Fvultr-terraform-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Psmths%2Fvultr-terraform-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Psmths%2Fvultr-terraform-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Psmths%2Fvultr-terraform-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Psmths","download_url":"https://codeload.github.com/Psmths/vultr-terraform-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Psmths%2Fvultr-terraform-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277067666,"owners_count":25754905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-26T02:00:09.010Z","response_time":78,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","terraform","vultr"],"created_at":"2024-11-16T10:18:13.231Z","updated_at":"2025-09-26T11:31:16.158Z","avatar_url":"https://github.com/Psmths.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vultr-terraform-example\n Example demonstrating how to deploy an Apache 2 instance on Vultr using terraform. This terraform deployment will create a cheap Vultr instance complete with DNS and firewall, as well as an Apache 2 installation.\n\n Additional information can be found here:\n\n- [Terraform Registry](https://registry.terraform.io/providers/vultr/vultr/latest/docs)\n- [Official GitHub](https://github.com/vultr/terraform-provider-vultr)\n\n## Information\n\n### Startup Script\n\nBecause Vultr expects the script to be passed in Base64 encoding, we can use Terraform's `filebase64` functionality to automatically encode a file in base64 and pass it to this instance, like so:\n\n```\nresource \"vultr_startup_script\" \"standup\" {\n    name = \"apache2-deploy\"\n    script = filebase64(\"startup.sh\")\n    type = \"boot\"\n}\n```\n\nThe startup script is applied to the instance (referenced by id) with this line in the main instance resource:\n```\nscript_id = vultr_startup_script.standup.id\n```\n\n### SSH Keys\n\nThis terraform deployment will also add an authorized SSH key to the root account. The relevant provider is as follows, and is self-explanatory:\n\n```\nresource \"vultr_ssh_key\" \"my_user\" {\n  name = \"Root SSH key\"\n  ssh_key = \"${file(\"sshkey.pub\")}\"\n}\n```\n\nThe SSH key is applied to the instance in the main instance provider as follows:\n\n```\nssh_key_ids = [\"${vultr_ssh_key.my_user.id}\"]\n```\n\n### DNS Records\n\nThe provider for DNS records creates a new DNS entry and ties it to the instance's IP address. In this provider entry, `vultr_instance.web.main_ip` will become the `web` instance's IP address as soon as terraform knows what it is.\n\n```\nresource \"vultr_dns_domain\" \"my_domain\" {\n    domain = \"example.com\"\n    ip = vultr_instance.web.main_ip\n}\n```\n### tfvars\n\nThe file `terraform.tfvars` contains all of the variable assignments listed in `variable.tf`. To obtain these values, use `vultr-cli`, which can be found [here](https://github.com/vultr/vultr-cli). We see these values applied to the main instance provider as shown below:\n\n```\nplan = var.plan\nregion = var.region\nos_id = var.os\nlabel = var.label\nhostname = var.hostname\n```\n\n### Firewall\n\nThis deployment creates a firewall group, adds rules to this group, and assigns the group to the instance. It first creates the group as follows:\n\n```\nresource \"vultr_firewall_group\" \"my_firewall_grp\" {\n    description = \"Webserver Firewall\"\n}\n```\n\nThis group is then applied to the main instance:\n```\nfirewall_group_id = vultr_firewall_group.my_firewall_grp.id\n```\n\n### Output\n\nThe output provider in `output.tf` simply prints the instance's final IP address after the deployment is complete.\n\n## Deploying\nTo deploy this instance, simply issue the following commands:\n```\nterraform init\nterraform plan\nterraform apply\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsmths%2Fvultr-terraform-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsmths%2Fvultr-terraform-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsmths%2Fvultr-terraform-example/lists"}