{"id":4041,"date":"2025-06-30T15:39:58","date_gmt":"2025-06-30T12:39:58","guid":{"rendered":"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/terraform\/"},"modified":"2025-06-30T15:48:16","modified_gmt":"2025-06-30T12:48:16","slug":"terraform","status":"publish","type":"docs","link":"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/terraform\/","title":{"rendered":"Terraform (\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b)"},"content":{"rendered":"\n<p><strong>Terraform<\/strong> \u2014 \u044d\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u043a\u0430\u043a \u043a\u043e\u0434\u043e\u043c (<a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/infrastructure-as-code\/\" data-internallinksmanager029f6b8e52c=\"353\" title=\"Infrastructure as Code (IaC)\">IaC<\/a>), \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0435\u0439 HashiCorp. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c, \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0445, \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430.<\/p>\n\n\n\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0432 Terraform \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 <strong>HCL (HashiCorp Configuration Language)<\/strong> \u2014 \u043f\u0440\u043e\u0441\u0442\u043e\u043c, \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u0431\u043b\u0438\u0437\u043a\u043e\u043c \u043a YAML, \u043d\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u043d\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438. \u041a\u043e\u0434 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 <code>.tf<\/code>-\u0444\u0430\u0439\u043b\u0430\u0445, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: \u043e\u0442 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u0448\u0438\u043d \u0438 \u0441\u0435\u0442\u0435\u0439 \u0434\u043e \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/dns\/\" data-internallinksmanager029f6b8e52c=\"199\" title=\"DNS (Domain Name System)\">DNS<\/a>-\u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u043f\u043e\u043b\u0438\u0442\u0438\u043a \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u041a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u044b \u0440\u0430\u0431\u043e\u0442\u044b Terraform:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Declarative<\/strong> \u2014 \u0442\u044b \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0448\u044c, <em>\u0447\u0442\u043e<\/em> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c, \u0430 \u043d\u0435 <em>\u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c<\/em>.<\/li>\n\n\n\n<li><strong>Plan<\/strong> \u2014 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c Terraform \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u044b.<\/li>\n\n\n\n<li><strong>Apply<\/strong> \u2014 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f.<\/li>\n\n\n\n<li><strong>State<\/strong> \u2014 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u0430 (<code>terraform.tfstate<\/code>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u0434\u0435\u043b\u044c\u0442\u044b \u043f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445.<\/li>\n\n\n\n<li><strong>Idempotent<\/strong> \u2014 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0435\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:<\/h3>\n\n\n\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Terraform \u043c\u043e\u0436\u043d\u043e \u0437\u0430 \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0441\u043e\u0437\u0434\u0430\u0442\u044c <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/virtual-private-cloud\/\" data-internallinksmanager029f6b8e52c=\"279\" title=\"Virtual Private Cloud (VPC) \u2014 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043e\u0431\u043b\u0430\u043a\u043e\">VPC<\/a> \u0438 \u043f\u043e\u0434\u0441\u0435\u0442\u0438 \u0432 AWS,<\/li>\n\n\n\n<li>\u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c EC2-\u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c,<\/li>\n\n\n\n<li>\u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/firewall\/\" data-internallinksmanager029f6b8e52c=\"198\" title=\"Firewall (\u0411\u0440\u0430\u043d\u0434\u043c\u0430\u0443\u044d\u0440)\">firewall<\/a>\u2019\u0430 (Security Groups),<\/li>\n\n\n\n<li>\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c IAM-\u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 \u0438 \u0440\u043e\u043b\u0438,<\/li>\n\n\n\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u0441\u0451 \u043a \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0443.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u043e\u0431\u043b\u0430\u043a\u043e\u0432 \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432:<\/h3>\n\n\n\n<p>Terraform \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 <strong>\u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b<\/strong> (providers), \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u043d\u0430\u0435\u0442, \u043a\u0430\u043a \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/api\/\" data-internallinksmanager029f6b8e52c=\"226\" title=\"API (Application Programming Interface)\">API<\/a>. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>AWS<\/strong>, <strong>Azure<\/strong>, <strong>Google Cloud<\/strong>, <strong>Alibaba Cloud<\/strong>;<\/li>\n\n\n\n<li><strong><a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/kubernetes\/\" data-internallinksmanager029f6b8e52c=\"259\" title=\"Kubernetes (K8s)\">Kubernetes<\/a><\/strong>, <strong><a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/helm-v-kubernetes\/\" data-internallinksmanager029f6b8e52c=\"350\" title=\"Helm (\u0432 Kubernetes)\">Helm<\/a><\/strong>, <strong><a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/cloudflare\/\" data-internallinksmanager029f6b8e52c=\"320\" title=\"Cloudflare\">Cloudflare<\/a><\/strong>, <strong>GitHub<\/strong>, <strong>Datadog<\/strong>, <strong><a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/vault\/\" data-internallinksmanager029f6b8e52c=\"377\" title=\"Vault(\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u043a\u0440\u0435\u0442\u043e\u0432)\">Vault<\/a><\/strong>, <strong>vSphere<\/strong> \u0438 \u0441\u043e\u0442\u043d\u0438 \u0434\u0440\u0443\u0433\u0438\u0445.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u041f\u043e\u0447\u0435\u043c\u0443 Terraform \u0441\u0442\u0430\u043b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043e\u043c:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\ud83d\udca1 <strong>\u041f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c<\/strong> \u2014 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u044b, \u0434\u043e \u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/li>\n\n\n\n<li>\ud83d\udd01 <strong>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u044c<\/strong> \u2014 \u0442\u0430 \u0436\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044e (dev, staging, prod).<\/li>\n\n\n\n<li>\ud83d\udd10 <strong>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0432\u0435\u0440\u0441\u0438\u0439<\/strong> \u2014 \u043a\u043e\u0434 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 Git, \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438 \u043e\u0442\u043a\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/li>\n\n\n\n<li>\ud83e\udd1d <strong>\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c<\/strong> \u0441 <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/gitlab-ci-cd\/\" data-internallinksmanager029f6b8e52c=\"372\" title=\"GitLab CI\/CD (\u041d\u0435\u043f\u0440\u0435\u0440\u044b\u0432\u043d\u0430\u044f \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0438 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0430 \u0432 GitLab)\">CI\/CD<\/a> \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u0430\u043c\u0438, <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/argo-cd\/\" data-internallinksmanager029f6b8e52c=\"352\" title=\"Argo CD\">GitOps<\/a>-\u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c, \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 (<code>tflint<\/code>, <code>checkov<\/code>, <code>OPA<\/code>).<\/li>\n<\/ul>\n\n\n\n<p>Terraform \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 DevOps, SRE \u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u0445, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u2014 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 \u043c\u0443\u043b\u044c\u0442\u0438\u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0439 \u0438\u043b\u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcc1 \u041f\u0440\u0438\u043c\u0435\u0440 Terraform-\u043c\u043e\u0434\u0443\u043b\u044f: EC2-\u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udcc1 \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>terraform-project\/\n\u251c\u2500\u2500 main.tf\n\u251c\u2500\u2500 variables.tf\n\u251c\u2500\u2500 outputs.tf\n\u251c\u2500\u2500 terraform.tfvars\n\u2514\u2500\u2500 modules\/\n    \u2514\u2500\u2500 ec2-instance\/\n        \u251c\u2500\u2500 main.tf\n        \u251c\u2500\u2500 variables.tf\n        \u2514\u2500\u2500 outputs.tf\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd27 <code>main.tf<\/code> (\u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430):<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>provider \"aws\" {\n  region = \"us-east-1\"\n}\n\nmodule \"web_server\" {\n  source        = \".\/modules\/ec2-instance\"\n  instance_name = \"frontend-<a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/node-v-kubernetes\/\" data-internallinksmanager029f6b8e52c=\"349\" title=\"Node (\u0432 Kubernetes)\">node<\/a>\"\n  instance_type = \"t3.micro\"\n  ami_id        = \"ami-0c55b159cbfafe1f0\"\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde9 <code>modules\/ec2-instance\/main.tf<\/code>:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>resource \"aws_instance\" \"this\" {\n  ami           = var.ami_id\n  instance_type = var.instance_type\n\n  tags = {\n    Name = var.instance_name\n  }\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce5 <code>modules\/ec2-instance\/variables.tf<\/code>:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>variable \"instance_name\" {\n  description = \"Name tag for the EC2 instance\"\n  type        = string\n}\n\nvariable \"instance_type\" {\n  description = \"Type of EC2 instance\"\n  type        = string\n  default     = \"t2.micro\"\n}\n\nvariable \"ami_id\" {\n  description = \"AMI ID for the instance\"\n  type        = string\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce4 <code>modules\/ec2-instance\/outputs.tf<\/code>:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>output \"instance_id\" {\n  value = aws_instance.this.id\n}\n\noutput \"public_ip\" {\n  value = aws_instance.this.public_ip\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 <code>terraform.tfvars<\/code> (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e):<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>instance_type = \"t3.micro\"\nami_id        = \"ami-0c55b159cbfafe1f0\"\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udca1 \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0420\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442 EC2-\u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 AMI \u0438 \u0442\u0438\u043f\u043e\u043c.<\/li>\n\n\n\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0438\u0437 \u043f\u043e\u0434\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430 <code>modules\/ec2-instance<\/code>.<\/li>\n\n\n\n<li>\u041f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435.<\/li>\n\n\n\n<li>\u041e\u0442\u0434\u0430\u0451\u0442 ID \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 <a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/ip-adres\/\" data-internallinksmanager029f6b8e52c=\"204\" title=\"IP-\u0430\u0434\u0440\u0435\u0441 (Internet Protocol)\">IP-\u0430\u0434\u0440\u0435\u0441<\/a> \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 outputs.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u043b\u0435\u0433\u043a\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443;<\/li>\n\n\n\n<li>\u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u0445;<\/li>\n\n\n\n<li>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 <code>.tfvars<\/code> \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f;<\/li>\n\n\n\n<li>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0432 CI\/CD \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u044b \u0438 GitOps-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2601\ufe0f \u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: <code>remote backend<\/code> (S3 + DynamoDB)<\/h3>\n\n\n\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a \u0438\u043b\u0438 CI-\u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0433\u043b\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 Terraform-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c <code>terraform.tfstate<\/code> \u0432 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u0441 AWS:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udcc4 <code>backend.tf<\/code> (\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0441 <code>main.tf<\/code>):<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>terraform {\n  backend \"s3\" {\n    bucket         = \"my-terraform-state-bucket\"\n    key            = \"envs\/dev\/terraform.tfstate\"\n    region         = \"us-east-1\"\n    dynamodb_table = \"terraform-lock-table\"\n    encrypt        = true\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udd12 <strong>DynamoDB<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 (<code>terraform apply<\/code>) \u0438\u0437 \u0434\u0432\u0443\u0445 \u043c\u0435\u0441\u0442.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udd0e \u041f\u0440\u0438\u043c\u0435\u0440 <code>data source<\/code>: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e AMI<\/h3>\n\n\n\n<p>Terraform \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0435\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>data \"aws_ami\" \"latest_amazon_linux\" {\n  most_recent = true\n  owners      = &#91;\"amazon\"]\n\n  filter {\n    name   = \"name\"\n    values = &#91;\"amzn2-ami-hvm-*-x86_64-gp2\"]\n  }\n}\n<\/code><\/pre>\n\n\n\n<p>\u041f\u043e\u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ami = data.aws_ami.latest_amazon_linux.id\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udce6 Terraform + Helm (\u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f Kubernetes)<\/h3>\n\n\n\n<p>\u0414\u043b\u044f \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f Helm-\u0447\u0430\u0440\u0442\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 Terraform \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/helm\/latest\/docs\" target=\"_blank\" rel=\"noopener\">Helm provider<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>provider \"helm\" {\n  kubernetes {\n    config_path = \"~\/.kube\/config\"\n  }\n}\n\nresource \"helm_release\" \"nginx\" {\n  name       = \"nginx\"\n  repository = \"<a href=\"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/https\/\" data-internallinksmanager029f6b8e52c=\"221\" title=\"HTTPS (Hyper Text Transfer Protocol Secure)\">https<\/a>:\/\/charts.bitnami.com\/bitnami\"\n  chart      = \"nginx\"\n  version    = \"15.2.0\"\n\n  set {\n    name  = \"service.type\"\n    value = \"LoadBalancer\"\n  }\n}\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0442\u0430\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u043a\u0438:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u041e\u0434\u0438\u043d <code>terraform apply<\/code> \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 (\u0447\u0435\u0440\u0435\u0437 <code>aws_eks_cluster<\/code>) \u0438 \u0442\u0443\u0442 \u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 Helm-\u0447\u0430\u0440\u0442\u044b.<\/li>\n\n\n\n<li>\u0412\u0441\u0451 \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0434\u043e\u043c \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/li>\n\n\n\n<li>\u041c\u043e\u0436\u043d\u043e \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0438 \u0447\u0430\u0440\u0442\u0430\u043c\u0438.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"featured_media":0,"parent":2927,"menu_order":153,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-4041","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/4041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/comments?post=4041"}],"version-history":[{"count":3,"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/4041\/revisions"}],"predecessor-version":[{"id":4049,"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/4041\/revisions\/4049"}],"up":[{"embeddable":true,"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/2927"}],"next":[{"title":"Redundancy (\u0418\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 \u0418\u0422-\u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435)","link":"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/redundancy\/","href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/4058"}],"prev":[{"title":"Cluster Autoscaler (CA)\u00a0","link":"https:\/\/cloudvps.by\/community\/docs\/glossarij\/terminy\/cluster-autoscaler\/","href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/docs\/4020"}],"wp:attachment":[{"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/media?parent=4041"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/cloudvps.by\/community\/wp-json\/wp\/v2\/doc_tag?post=4041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}