From 3dc8a37cc3a47110ac9f5b06db976118bd81e2a0 Mon Sep 17 00:00:00 2001 From: Hugo Fonseca <1098293+fonsecas72@users.noreply.github.com> Date: Fri, 4 Sep 2020 22:04:40 +0100 Subject: [PATCH] Adding terraform / hcl samples --- test/samples-all.generated.js | 4 +++ test/samples/sample.hcl.txt | 48 ++++++++++++++++++++++++++++ website/index/samples/sample.hcl.txt | 48 ++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 test/samples/sample.hcl.txt create mode 100644 website/index/samples/sample.hcl.txt diff --git a/test/samples-all.generated.js b/test/samples-all.generated.js index a1f53e244e..82e41440d9 100644 --- a/test/samples-all.generated.js +++ b/test/samples-all.generated.js @@ -100,6 +100,10 @@ define([], function() { return[ "name": "sample.handlebars.txt", "content": "\n
\n\t

{{title}}

\n\t{{#if author}}\n\t

{{author.firstName}} {{author.lastName}}

\n\t{{else}}\n\t

Unknown Author

\n\t{{/if}}\n\t{{contentBody}}\n
\n\n{{#unless license}}\n

WARNING: This entry does not have a license!

\n{{/unless}}\n\n
\n\t\n
\n\n

Comments

\n\n
\n\t{{#each comments}}\n\t

{{title}}

\n\t
{{body}}
\n\t{{/each}}\n
\n" }, + { + "name": "sample.hcl.txt", + "content": "terraform {\r\n required_providers {\r\n aws = {\r\n source = \"hashicorp/aws\"\r\n version = \"~> 1.0.4\"\r\n }\r\n }\r\n}\r\n\r\nvariable \"aws_region\" {}\r\n\r\nvariable \"base_cidr_block\" {\r\n description = \"A /16 CIDR range definition, such as 10.1.0.0/16, that the VPC will use\"\r\n default = \"10.1.0.0/16\"\r\n}\r\n\r\nvariable \"availability_zones\" {\r\n description = \"A list of availability zones in which to create subnets\"\r\n type = list(string)\r\n}\r\n\r\nprovider \"aws\" {\r\n region = var.aws_region\r\n}\r\n\r\nresource \"aws_vpc\" \"main\" {\r\n # Referencing the base_cidr_block variable allows the network address\r\n # to be changed without modifying the configuration.\r\n cidr_block = var.base_cidr_block\r\n}\r\n\r\nresource \"aws_subnet\" \"az\" {\r\n # Create one subnet for each given availability zone.\r\n count = length(var.availability_zones)\r\n\r\n # For each subnet, use one of the specified availability zones.\r\n availability_zone = var.availability_zones[count.index]\r\n\r\n # By referencing the aws_vpc.main object, Terraform knows that the subnet\r\n # must be created only after the VPC is created.\r\n vpc_id = aws_vpc.main.id\r\n\r\n # Built-in functions and operators can be used for simple transformations of\r\n # values, such as computing a subnet address. Here we create a /20 prefix for\r\n # each subnet, using consecutive addresses for each availability zone,\r\n # such as 10.1.16.0/20 .\r\n cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 4, count.index+1)\r\n}\r\n" + }, { "name": "sample.html.txt", "content": "\r\n\r\n\r\n\r\n\t\r\n\tHTML Sample\r\n\t\r\n\r\n\t\r\n\t\r\n\r\n\t\r\n\t\r\n\r\n\r\n\t\r\n\t
\r\n\t\t

NAME OF SITE

\r\n\t
\r\n\t
\r\n\t\t\t

I'm h2 Header! Edit me in <h2>

\r\n\t\t\t

\r\n\t\t\t\tI'm a paragraph! Edit me in <p>\r\n\t\t\t\tto add your own content and make changes to the style and font.\r\n\t\t\t\tIt's easy! Just change the text between <p> ... </p> and change the style in <style>.\r\n\t\t\t\tYou can make it as long as you wish. The browser will automatically wrap the lines to accommodate the\r\n\t\t\t\tsize of the browser window.\r\n\t\t\t

\r\n\t\t\t\r\n\t
\r\n\r\n\r\n" diff --git a/test/samples/sample.hcl.txt b/test/samples/sample.hcl.txt new file mode 100644 index 0000000000..2eb16136c6 --- /dev/null +++ b/test/samples/sample.hcl.txt @@ -0,0 +1,48 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 1.0.4" + } + } +} + +variable "aws_region" {} + +variable "base_cidr_block" { + description = "A /16 CIDR range definition, such as 10.1.0.0/16, that the VPC will use" + default = "10.1.0.0/16" +} + +variable "availability_zones" { + description = "A list of availability zones in which to create subnets" + type = list(string) +} + +provider "aws" { + region = var.aws_region +} + +resource "aws_vpc" "main" { + # Referencing the base_cidr_block variable allows the network address + # to be changed without modifying the configuration. + cidr_block = var.base_cidr_block +} + +resource "aws_subnet" "az" { + # Create one subnet for each given availability zone. + count = length(var.availability_zones) + + # For each subnet, use one of the specified availability zones. + availability_zone = var.availability_zones[count.index] + + # By referencing the aws_vpc.main object, Terraform knows that the subnet + # must be created only after the VPC is created. + vpc_id = aws_vpc.main.id + + # Built-in functions and operators can be used for simple transformations of + # values, such as computing a subnet address. Here we create a /20 prefix for + # each subnet, using consecutive addresses for each availability zone, + # such as 10.1.16.0/20 . + cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 4, count.index+1) +} diff --git a/website/index/samples/sample.hcl.txt b/website/index/samples/sample.hcl.txt new file mode 100644 index 0000000000..2eb16136c6 --- /dev/null +++ b/website/index/samples/sample.hcl.txt @@ -0,0 +1,48 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 1.0.4" + } + } +} + +variable "aws_region" {} + +variable "base_cidr_block" { + description = "A /16 CIDR range definition, such as 10.1.0.0/16, that the VPC will use" + default = "10.1.0.0/16" +} + +variable "availability_zones" { + description = "A list of availability zones in which to create subnets" + type = list(string) +} + +provider "aws" { + region = var.aws_region +} + +resource "aws_vpc" "main" { + # Referencing the base_cidr_block variable allows the network address + # to be changed without modifying the configuration. + cidr_block = var.base_cidr_block +} + +resource "aws_subnet" "az" { + # Create one subnet for each given availability zone. + count = length(var.availability_zones) + + # For each subnet, use one of the specified availability zones. + availability_zone = var.availability_zones[count.index] + + # By referencing the aws_vpc.main object, Terraform knows that the subnet + # must be created only after the VPC is created. + vpc_id = aws_vpc.main.id + + # Built-in functions and operators can be used for simple transformations of + # values, such as computing a subnet address. Here we create a /20 prefix for + # each subnet, using consecutive addresses for each availability zone, + # such as 10.1.16.0/20 . + cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 4, count.index+1) +}