{"id":1383,"date":"2019-08-26T14:10:54","date_gmt":"2019-08-26T11:10:54","guid":{"rendered":"https:\/\/artem.services\/?p=1378"},"modified":"2019-08-26T14:21:41","modified_gmt":"2019-08-26T11:21:41","slug":"1383","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1383&lang=en","title":{"rendered":"\u00a0Terraform &#8212; Generate files based on existing infrastructure"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-99 aligncenter\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform.png\" alt=\"\" width=\"1210\" height=\"418\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform.png 1210w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-300x104.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-768x265.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-1024x354.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/terraform-954x330.png 954w\" sizes=\"(max-width: 1210px) 100vw, 1210px\" \/><\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">To create <strong>Terraform<\/strong> files based on the existing infrastructure, we will use<\/span><\/span> <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/terraformer\" target=\"_blank\" rel=\"noopener noreferrer\">Terraformer<\/a><\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">In this example, the <strong>macOS<\/strong> system will be used, so we install terraformer using <strong>homebrew<\/strong>:<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nbrew install terraformer\r\n<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Installation for other OSs can be found on the project page.<\/span><\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create a directory for storing plugins (for working with providers)<\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmkdir -p ~\/.terraform.d\/plugins\/darwin_amd64\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Terraform file generation examples<\/span><\/span><\/h3>\n<h4>AWS<\/h4>\n<div class=\"text-wrap tlid-copy-target\">\n<div class=\"result-shield-container tlid-copy-target\" tabindex=\"0\"><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">We find the most current version of the <strong>darwin<\/strong> version, download, unzip and move the contents of the archive to the previously created directory<\/span><\/span><\/div>\n<\/div>\n<div class=\"tlid-result-transliteration-container result-transliteration-container transliteration-container\">\n<div class=\"tlid-transliteration-content transliteration-content full\"><\/div>\n<\/div>\n<pre>https:\/\/releases.hashicorp.com\/terraform-provider-aws\/<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create <strong>Terraform<\/strong> files for all <strong>S3<\/strong> buckets and <strong>EC2<\/strong> instances in the region: <strong>us-east-1<\/strong><\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nterraformer import aws --resources=s3,ec2_instance --regions=us-east-1\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4>Kubernetes<\/h4>\n<p>&nbsp;<\/p>\n<blockquote><p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">kubectl must be installed and configured<\/span><\/span><\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">We find the most current version of the <strong>darwin<\/strong> version, download, unzip and move the contents of the archive to the previously created directory<\/span><\/span><\/p>\n<pre>https:\/\/releases.hashicorp.com\/terraform-provider-kubernetes\/<\/pre>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Create <strong>Terraform<\/strong> files for all <strong>deployments<\/strong>, <strong>services<\/strong> and <strong>storageclasses<\/strong><\/span><\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nterraformer import kubernetes --resources=deployments,services,storageclasses\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><span class=\"tlid-translation translation\" lang=\"en\"><span class=\"\" title=\"\">Lists of supported providers and resources can be found in more detail<\/span><\/span> <a href=\"https:\/\/github.com\/GoogleCloudPlatform\/terraformer\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To create Terraform files based on the existing infrastructure, we will use Terraformer &nbsp; In this example, the macOS system will be used, so we install terraformer using homebrew: &nbsp; Installation for other OSs can be found on the project page. &nbsp; Create a directory for storing plugins (for working with providers) &nbsp; &nbsp; Terraform &hellip; <a href=\"https:\/\/artem.services\/?p=1383&#038;lang=en\" class=\"more-link\">\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u044c<span class=\"screen-reader-text\"> &quot;\u00a0Terraform &#8212; Generate files based on existing infrastructure&quot;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[541],"tags":[555,1105],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1383"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1383"}],"version-history":[{"count":3,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1383\/revisions"}],"predecessor-version":[{"id":1386,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1383\/revisions\/1386"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}