├── README.md ├── docs ├── images │ ├── azure_tf_code.png │ ├── microsoft-azure.png │ ├── upandtotheright.jpg │ ├── its-dangerous-to-go-alone.png │ ├── Terraform_VerticalLogo_FullColor.png │ └── instructor.svg ├── README.md ├── remark_settings.js ├── link.js ├── style.css └── index.html ├── .gitignore ├── remote_state.tf.disabled ├── files └── setup.sh ├── outputs.tf ├── variables.tf ├── main.tf └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # azure-terraform-beginners 2 | Beginners Guide to Terraforming Azure 3 | -------------------------------------------------------------------------------- /docs/images/azure_tf_code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scarolan/azure-terraform-beginners/HEAD/docs/images/azure_tf_code.png -------------------------------------------------------------------------------- /docs/images/microsoft-azure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scarolan/azure-terraform-beginners/HEAD/docs/images/microsoft-azure.png -------------------------------------------------------------------------------- /docs/images/upandtotheright.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scarolan/azure-terraform-beginners/HEAD/docs/images/upandtotheright.jpg -------------------------------------------------------------------------------- /docs/images/its-dangerous-to-go-alone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scarolan/azure-terraform-beginners/HEAD/docs/images/its-dangerous-to-go-alone.png -------------------------------------------------------------------------------- /docs/images/Terraform_VerticalLogo_FullColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scarolan/azure-terraform-beginners/HEAD/docs/images/Terraform_VerticalLogo_FullColor.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | 8 | # .tfvars files 9 | *.tfvars 10 | -------------------------------------------------------------------------------- /remote_state.tf.disabled: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "remote" { 3 | hostname = "app.terraform.io" 4 | organization = "seancarolan" 5 | 6 | workspaces { 7 | name = "cat-demo-app" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | This directory contains an interactive slideshow that you can view in your browser. Open the index.html file in a web browser and use the arrow keys to navigate. `P` will toggle presentation mode, and `C` will launch a separate window with only slide content. 2 | 3 | -------------------------------------------------------------------------------- /docs/remark_settings.js: -------------------------------------------------------------------------------- 1 | remark.macros.scale = function (percentage) { 2 | var url = this; 3 | return ''; 4 | }; 5 | var slideshow = remark.create({ 6 | ratio: '4:3', 7 | highlightStyle: 'tomorrow-night-bright', 8 | highlightLines: 'true', 9 | }); -------------------------------------------------------------------------------- /files/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Deploys a simple Apache webpage with kittens as a service. 3 | 4 | # cd /tmp 5 | apt-get -y update > /dev/null 2>&1 6 | apt install -y apache2 > /dev/null 2>&1 7 | 8 | cat << EOM > /var/www/html/index.html 9 | 10 | Meow! 11 | 12 |
13 |

Meow World

14 | 15 | 16 | EOM 17 | 18 | echo "Your demo is now ready." -------------------------------------------------------------------------------- /docs/link.js: -------------------------------------------------------------------------------- 1 | var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65"; 2 | $(document).keydown(function(e) { 3 | kkeys.push( e.keyCode ); 4 | if ( kkeys.toString().indexOf( konami ) >= 0 ) { 5 | $(document).unbind('keydown',arguments.callee); 6 | // do something awesome 7 | $('body').append(` 8 |
9 | 11 |
12 | `) 13 | // $('body').append("

Hello world

") 14 | } 15 | }); -------------------------------------------------------------------------------- /outputs.tf: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Outputs File 3 | # 4 | # Expose the outputs you want your users to see after a successful 5 | # `terraform apply` or `terraform output` command. You can add your own text 6 | # and include any data from the state file. Outputs are sorted alphabetically; 7 | # use an underscore _ to move things to the bottom. 8 | 9 | output "_instructions" { 10 | value = "This output contains plain text. You can add variables too." 11 | } 12 | 13 | output "public_dns" { 14 | value = "${azurerm_public_ip.tf-guide-pip.fqdn}" 15 | } 16 | 17 | output "App_Server_URL" { 18 | value = "http://${azurerm_public_ip.tf-guide-pip.fqdn}" 19 | } -------------------------------------------------------------------------------- /docs/images/instructor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Roboto); 2 | @import url(https://fonts.googleapis.com/css?family=Uncial+Antiqua); 3 | @import url(https://fonts.googleapis.com/css?family=Noto+Serif:400,700,400italic); 4 | @import url(https://fonts.googleapis.com/css?family=Inconsolata:400,700,400italic); 5 | 6 | body { 7 | font-family: 'Noto Serif'; 8 | } 9 | 10 | h1, h2, h3, h4, h5, h6 { 11 | font-weight: normal; 12 | margin-bottom: 0; 13 | font-family: Roboto; 14 | } 15 | 16 | .remark-slide-content h1 { font-size: 2.4em; } 17 | .remark-slide-content h2 { font-size: 2.0em; } 18 | .remark-slide-content h3 { font-size: 1.6em; } 19 | 20 | .remark-code, .remark-inline-code { font-family: 'Inconsolata'; } 21 | 22 | .remark-container { 23 | background-color: #5C4EE5; 24 | } 25 | 26 | .title-slide .remark-slide-number { 27 | visibility: hidden; 28 | } 29 | 30 | .section { 31 | font-family: 'Uncial Antiqua'; 32 | text-shadow: -1px 1px 2px rgb(56, 79, 122); 33 | font-weight: normal; 34 | font-size: 2.0em; 35 | margin-bottom: 15px; 36 | margin-top: 15px; 37 | border-top: 3px dotted #e5e5e5; 38 | border-bottom: 3px dotted #e5e5e5; 39 | box-shadow: inset 0 -1px 0 0 #e5e5e5, inset 0 1px 0 0 #e5e5e5, 0 1px 0 0 #e5e5e5, 0 -1px 0 0 #e5e5e5; 40 | } 41 | 42 | .titletext { 43 | font-size: 2.0em; 44 | margin-bottom: 0em; 45 | margin-top: 0em; 46 | font-family: Roboto; 47 | } 48 | 49 | .contents { 50 | display: inline-block; 51 | font-size: 1.6em; 52 | list-style-position: outside; 53 | text-align: left; 54 | } 55 | 56 | .review { 57 | font-size: 2.0em; 58 | font-family: Roboto; 59 | } 60 | 61 | .darkgreen { 62 | color: darkgreen; 63 | } 64 | 65 | .smalltext { 66 | font-size: 0.8em; 67 | } 68 | 69 | .red { 70 | color: red; 71 | } 72 | 73 | #legend { 74 | border: 0px none; 75 | height: 450px; 76 | position: absolute; 77 | width: 600px; 78 | overflow: hidden; 79 | z-index: 100; 80 | top: 50%; 81 | left: 50%; 82 | -webkit-transform: translate(-50%, -50%); 83 | transform: translate(-50%, -50%); 84 | } -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Variables File 3 | # 4 | # Here is where we store the default values for all the variables used in our 5 | # Terraform code. If you create a variable with no default, the user will be 6 | # prompted to enter it (or define it via config file or command line flags.) 7 | 8 | variable "resource_group" { 9 | description = "The name of your Azure Resource Group." 10 | default = "Terraform-Azure-Beginners" 11 | } 12 | 13 | variable "prefix" { 14 | description = "This prefix will be included in the name of some resources." 15 | default = "tfguide" 16 | } 17 | 18 | variable "hostname" { 19 | description = "Virtual machine hostname. Used for local hostname, DNS, and storage-related names." 20 | default = "catapp" 21 | } 22 | 23 | variable "location" { 24 | description = "The region where the virtual network is created." 25 | default = "centralus" 26 | } 27 | 28 | variable "virtual_network_name" { 29 | description = "The name for your virtual network." 30 | default = "vnet" 31 | } 32 | 33 | variable "address_space" { 34 | description = "The address space that is used by the virtual network. You can supply more than one address space. Changing this forces a new resource to be created." 35 | default = "10.0.0.0/16" 36 | } 37 | 38 | variable "subnet_prefix" { 39 | description = "The address prefix to use for the subnet." 40 | default = "10.0.10.0/24" 41 | } 42 | 43 | variable "storage_account_tier" { 44 | description = "Defines the storage tier. Valid options are Standard and Premium." 45 | default = "Standard" 46 | } 47 | 48 | variable "storage_replication_type" { 49 | description = "Defines the replication type to use for this storage account. Valid options include LRS, GRS etc." 50 | default = "LRS" 51 | } 52 | 53 | variable "vm_size" { 54 | description = "Specifies the size of the virtual machine." 55 | default = "Standard_A0" 56 | } 57 | 58 | variable "image_publisher" { 59 | description = "Name of the publisher of the image (az vm image list)" 60 | default = "Canonical" 61 | } 62 | 63 | variable "image_offer" { 64 | description = "Name of the offer (az vm image list)" 65 | default = "UbuntuServer" 66 | } 67 | 68 | variable "image_sku" { 69 | description = "Image SKU to apply (az vm image list)" 70 | default = "16.04-LTS" 71 | } 72 | 73 | variable "image_version" { 74 | description = "Version of the image to apply (az vm image list)" 75 | default = "latest" 76 | } 77 | 78 | variable "admin_username" { 79 | description = "Administrator user name" 80 | default = "adminuser" 81 | } 82 | 83 | variable "admin_password" { 84 | description = "Administrator password" 85 | default = "Adminpassword123!" 86 | } 87 | 88 | variable "source_network" { 89 | description = "Allow access from this network prefix. Defaults to '*'." 90 | default = "*" 91 | } -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # * HashiCorp Beginner's Guide to Using Terraform on Azure 3 | # 4 | # This Terraform configuration will create the following: 5 | # 6 | # Resource group with a virtual network and subnet 7 | # An Ubuntu Linux server running Apache 8 | 9 | ############################################################################## 10 | # * Shared infrastructure resources 11 | 12 | # The latest version of the Azure provider breaks backward compatibility. 13 | # TODO: Update this code to use the latest provider. 14 | provider "azurerm" { 15 | version = "=1.44.0" 16 | } 17 | 18 | # First we'll create a resource group. In Azure every resource belongs to a 19 | # resource group. Think of it as a container to hold all your resources. 20 | # You can find a complete list of Azure resources supported by Terraform here: 21 | # https://www.terraform.io/docs/providers/azurerm/ 22 | resource "azurerm_resource_group" "tf_azure_guide" { 23 | name = "${var.resource_group}" 24 | location = "${var.location}" 25 | } 26 | 27 | # The next resource is a Virtual Network. We can dynamically place it into the 28 | # resource group without knowing its name ahead of time. Terraform handles all 29 | # of that for you, so everything is named consistently every time. Say goodbye 30 | # to weirdly-named mystery resources in your Azure Portal. To see how all this 31 | # works visually, run `terraform graph` and copy the output into the online 32 | # GraphViz tool: http://www.webgraphviz.com/ 33 | resource "azurerm_virtual_network" "vnet" { 34 | name = "${var.virtual_network_name}" 35 | location = "${azurerm_resource_group.tf_azure_guide.location}" 36 | address_space = ["${var.address_space}"] 37 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 38 | } 39 | 40 | # Next we'll build a subnet to run our VMs in. These variables can be defined 41 | # via environment variables, a config file, or command line flags. Default 42 | # values will be used if the user does not override them. You can find all the 43 | # default variables in the variables.tf file. You can customize this demo by 44 | # making a copy of the terraform.tfvars.example file. 45 | resource "azurerm_subnet" "subnet" { 46 | name = "${var.prefix}subnet" 47 | virtual_network_name = "${azurerm_virtual_network.vnet.name}" 48 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 49 | address_prefix = "${var.subnet_prefix}" 50 | } 51 | 52 | ############################################################################## 53 | # * Build an Ubuntu 16.04 Linux VM 54 | # 55 | # Now that we have a network, we'll deploy an Ubuntu 16.04 Linux server. 56 | # An Azure Virtual Machine has several components. In this example we'll build 57 | # a security group, a network interface, a public ip address, a storage 58 | # account and finally the VM itself. Terraform handles all the dependencies 59 | # automatically, and each resource is named with user-defined variables. 60 | 61 | # Security group to allow inbound access on port 80 (http) and 22 (ssh) 62 | resource "azurerm_network_security_group" "tf-guide-sg" { 63 | name = "${var.prefix}-sg" 64 | location = "${var.location}" 65 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 66 | 67 | security_rule { 68 | name = "HTTP" 69 | priority = 100 70 | direction = "Inbound" 71 | access = "Allow" 72 | protocol = "Tcp" 73 | source_port_range = "*" 74 | destination_port_range = "80" 75 | source_address_prefix = "${var.source_network}" 76 | destination_address_prefix = "*" 77 | } 78 | 79 | security_rule { 80 | name = "SSH" 81 | priority = 101 82 | direction = "Inbound" 83 | access = "Allow" 84 | protocol = "Tcp" 85 | source_port_range = "*" 86 | destination_port_range = "22" 87 | source_address_prefix = "${var.source_network}" 88 | destination_address_prefix = "*" 89 | } 90 | } 91 | 92 | # A network interface. This is required by the azurerm_virtual_machine 93 | # resource. Terraform will let you know if you're missing a dependency. 94 | resource "azurerm_network_interface" "tf-guide-nic" { 95 | name = "${var.prefix}tf-guide-nic" 96 | location = "${var.location}" 97 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 98 | network_security_group_id = "${azurerm_network_security_group.tf-guide-sg.id}" 99 | 100 | ip_configuration { 101 | name = "${var.prefix}ipconfig" 102 | subnet_id = "${azurerm_subnet.subnet.id}" 103 | private_ip_address_allocation = "Dynamic" 104 | public_ip_address_id = "${azurerm_public_ip.tf-guide-pip.id}" 105 | } 106 | } 107 | 108 | # Every Azure Virtual Machine comes with a private IP address. You can also 109 | # optionally add a public IP address for Internet-facing applications and 110 | # demo environments like this one. 111 | resource "azurerm_public_ip" "tf-guide-pip" { 112 | name = "${var.prefix}-ip" 113 | location = "${var.location}" 114 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 115 | public_ip_address_allocation = "Dynamic" 116 | domain_name_label = "${var.hostname}" 117 | } 118 | 119 | # And finally we build our virtual machine. This is a standard Ubuntu instance. 120 | # We use the shell provisioner to run a Bash script that configures Apache for 121 | # the demo environment. Terraform supports several different types of 122 | # provisioners including Bash, Powershell and Chef. 123 | resource "azurerm_virtual_machine" "site" { 124 | name = "${var.hostname}-site" 125 | location = "${var.location}" 126 | resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 127 | vm_size = "${var.vm_size}" 128 | 129 | network_interface_ids = ["${azurerm_network_interface.tf-guide-nic.id}"] 130 | delete_os_disk_on_termination = "true" 131 | 132 | storage_image_reference { 133 | publisher = "${var.image_publisher}" 134 | offer = "${var.image_offer}" 135 | sku = "${var.image_sku}" 136 | version = "${var.image_version}" 137 | } 138 | 139 | storage_os_disk { 140 | name = "${var.hostname}-osdisk" 141 | managed_disk_type = "Standard_LRS" 142 | caching = "ReadWrite" 143 | create_option = "FromImage" 144 | } 145 | 146 | os_profile { 147 | computer_name = "${var.hostname}" 148 | admin_username = "${var.admin_username}" 149 | admin_password = "${var.admin_password}" 150 | } 151 | 152 | os_profile_linux_config { 153 | disable_password_authentication = false 154 | } 155 | 156 | # It's easy to transfer files or templates using Terraform. 157 | provisioner "file" { 158 | source = "files/setup.sh" 159 | destination = "/home/${var.admin_username}/setup.sh" 160 | 161 | connection { 162 | type = "ssh" 163 | user = "${var.admin_username}" 164 | password = "${var.admin_password}" 165 | host = "${azurerm_public_ip.tf-guide-pip.fqdn}" 166 | } 167 | } 168 | 169 | # This shell script starts our Apache server and prepares the demo environment. 170 | provisioner "remote-exec" { 171 | inline = [ 172 | "chmod +x /home/${var.admin_username}/setup.sh", 173 | "sudo /home/${var.admin_username}/setup.sh", 174 | ] 175 | 176 | connection { 177 | type = "ssh" 178 | user = "${var.admin_username}" 179 | password = "${var.admin_password}" 180 | host = "${azurerm_public_ip.tf-guide-pip.fqdn}" 181 | } 182 | } 183 | } 184 | 185 | ############################################################################## 186 | # * Azure MySQL Database 187 | 188 | # Terraform can build any type of infrastructure, not just virtual machines. 189 | # Azure offers managed MySQL database servers and a whole host of other 190 | # resources. Each resource is documented with all the available settings: 191 | # https://www.terraform.io/docs/providers/azurerm/r/mysql_server.html 192 | 193 | # Uncomment the code below to add a MySQL server to your resource group. 194 | 195 | # resource "azurerm_mysql_server" "mysql" { 196 | # name = "${var.mysql_hostname}" 197 | # location = "${azurerm_resource_group.tf_azure_guide.location}" 198 | # resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 199 | # ssl_enforcement = "Disabled" 200 | 201 | # sku { 202 | # name = "MYSQLB50" 203 | # capacity = 50 204 | # tier = "Basic" 205 | # } 206 | 207 | # administrator_login = "mysqladmin" 208 | # administrator_login_password = "Everything-is-bananas-010101" 209 | # version = "5.7" 210 | # storage_mb = "51200" 211 | # ssl_enforcement = "Disabled" 212 | # } 213 | 214 | # # This is a sample database that we'll populate with the MySQL sample data 215 | # # set provided here: https://github.com/datacharmer/test_db. With Terraform, 216 | # # everything is Infrastructure as Code. No more manual steps, aging runbooks, 217 | # # tribal knowledge or outdated wiki instructions. Terraform is your executable 218 | # # documentation, and it will build infrastructure correctly every time. 219 | # resource "azurerm_mysql_database" "employees" { 220 | # name = "employees" 221 | # resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 222 | # server_name = "${azurerm_mysql_server.mysql.name}" 223 | # charset = "utf8" 224 | # collation = "utf8_unicode_ci" 225 | # } 226 | 227 | # # This firewall rule allows database connections from anywhere and is suited 228 | # # for demo environments. Don't do this in production. 229 | # resource "azurerm_mysql_firewall_rule" "demo" { 230 | # name = "tf-guide-demo" 231 | # resource_group_name = "${azurerm_resource_group.tf_azure_guide.name}" 232 | # server_name = "${azurerm_mysql_server.mysql.name}" 233 | # start_ip_address = "0.0.0.0" 234 | # end_ip_address = "0.0.0.0" 235 | # } 236 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Private Terraform Enterprise Lab 5 | 6 | 7 | 8 | 9 | 10 | 11 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------