linux_wiki:terraform

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:terraform [2018/06/14 22:40]
billdozor [File Contents: Root Files]
linux_wiki:terraform [2019/05/25 23:50] (current)
Line 5: Line 5:
 "Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned." "Terraform enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned."
  
-Site+Sites
   * Official Site: https://www.terraform.io/   * Official Site: https://www.terraform.io/
   * Downloads: https://www.terraform.io/downloads.html   * Downloads: https://www.terraform.io/downloads.html
   * Getting started: https://www.terraform.io/intro/getting-started/install.html   * Getting started: https://www.terraform.io/intro/getting-started/install.html
 +  * AWS Provider Reference Doc: https://www.terraform.io/docs/providers/aws/index.html
  
 +\\
 **Checklist** **Checklist**
   * AWS Account   * AWS Account
Line 174: Line 176:
 }</code> }</code>
  
-<code bash outputs.tf>Title: outputs.tf+<code bash outputs.tf> Title: outputs.tf
 # Description: Outputs from resources saved as variables # Description: Outputs from resources saved as variables
 +#              If terraform apply is run within this directory, these variables
 +#              are displayed at the end of the run.
  
 # Pull the VPC ID from the site module # Pull the VPC ID from the site module
Line 188: Line 192:
 Files in the site/ module directory. Ordered in a way that is easier to follow. Files in the site/ module directory. Ordered in a way that is easier to follow.
  
-<code bash variables.tf># Title: site/variables.tf +<code bash variables.tf># Title: site/variables.tf                                                                                            
-# Description: Required input variables from the parent file (../main.tf)+# Description: Variables for the module 'site' 
 +#              Unset variables are expected to be passed in from the calling parent
  
-# Availability Zones: Pass in from main variables+# Availability Zones: Inherit from main variables
 variable "availability_zones" { type = "list" } variable "availability_zones" { type = "list" }
  
-# VPC CIDR: Pass in from main variables+# VPC CIDR: Inherit from main variables
 variable "vpc_cidr" {} variable "vpc_cidr" {}
  
-# Public Subnets (with IGW): Pass in from main+# Public Subnets (with IGW): Inherit from main
 variable "public_subnet01_cidr" {} variable "public_subnet01_cidr" {}
 variable "public_subnet02_cidr" {} variable "public_subnet02_cidr" {}
 variable "public_subnet03_cidr" {} variable "public_subnet03_cidr" {}
  
-# Private Subnets (no IGW): Pass in from main+# Private Subnets (no IGW): Inherit from main
 variable "private_subnet01_cidr" {} variable "private_subnet01_cidr" {}
 variable "private_subnet02_cidr" {} variable "private_subnet02_cidr" {}
 variable "private_subnet03_cidr" {}</code> variable "private_subnet03_cidr" {}</code>
  
-<code bash vpc.tf># Title: vpc.tf+<code bash vpc.tf># Title: site/vpc.tf
 # Description: Create a VPC and attach an internet gateway # Description: Create a VPC and attach an internet gateway
  
Line 229: Line 234:
 }</code> }</code>
  
-<code bash subnets.tf># Title: subnets.tf                                                                                                  +<code bash subnets.tf># Title: site/subnets.tf                                                                                                  
 # Description: Create subnets                                                                                         # Description: Create subnets                                                                                        
                                                                                                                                                                                                                                            
Line 294: Line 299:
 }</code> }</code>
  
-<code bash nat_gateway.tf># Title: nat_gateway.tf+<code bash nat_gateway.tf># Title: site/nat_gateway.tf
 # Description: Create a NAT gateway for private subnets # Description: Create a NAT gateway for private subnets
  
Line 344: Line 349:
 # Route to the NAT Gateway provided elsewhere (in private route table)</code> # Route to the NAT Gateway provided elsewhere (in private route table)</code>
  
-<code bash routes.tf>#Title: routes.tf                                                                                                   +<code bash routes.tf>#Title: site/routes.tf                                                                                                   
 # Description: Route tables for subnets                                                                               # Description: Route tables for subnets                                                                              
                                                                                                                                                                                                                                            
Line 443: Line 448:
 }</code> }</code>
  
-<code bash security_groups.tf># Title: security_groups.tf                                                                                          +<code bash security_groups.tf># Title: site/security_groups.tf                                                                                          
 # Description: Security groups for resources in subnets.                                                              # Description: Security groups for resources in subnets.                                                             
                                                                                                                                                                                                                                            
Line 506: Line 511:
 }</code> }</code>
  
-<code bash outputs.tf># Title: outputs.tf+<code bash outputs.tf># Title: site/outputs.tf
 # Description: Outputs from resources saved as variables # Description: Outputs from resources saved as variables
 +#              Accessible via "${module.site.variable_name}"
  
-# Store the VPC ID - pulled from here in main's output.tf+# Set output variable from resource format                                                                            
 +# output "variable_name"
 +#   value = "${aws_resource.name.attribute}" 
 +# } 
 + 
 +# Store the VPC ID
 output "vpc_id" { output "vpc_id" {
   value = "${aws_vpc.myvpc.id}"   value = "${aws_vpc.myvpc.id}"
 +}
 +
 +# Store the Public Subnet ID
 +output "subnet01_public_id" {
 +  value = "${aws_subnet.subnet01-public.id}"
 +}
 +
 +# Store the Public Security Group ID
 +output "sg_public_default_id" {
 +  value = "${aws_security_group.sg_public_default.id}"
 }</code> }</code>
  
 ---- ----
  
  • linux_wiki/terraform.1529030438.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)