├── .github └── FUNDING.yml ├── .gitignore ├── LICENSE ├── README.md ├── examples ├── README.md ├── app-service-with-vnet-integration │ ├── README.md │ ├── main.tf │ └── output.tf └── simple-app-service │ ├── README.md │ ├── main.tf │ └── output.tf ├── graph.png ├── main.tf ├── output.tf ├── variables.tf └── versions.tf /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # repo:     https://github.com/kumarvna/terraform-azurerm-app-service 2 | # filename: FUNDING.YML 3 | 4 | github: https://github.com/kumarvna 5 | 6 | # These are supported funding model platforms 7 | 8 | # github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 9 | # patreon: # Replace with a single Patreon username 10 | # open_collective: # Replace with a single Open Collective username 11 | # ko_fi: # Replace with a single Ko-fi username 12 | # tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 13 | # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 14 | # liberapay: # Replace with a single Liberapay username 15 | # issuehunt: # Replace with a single IssueHunt username 16 | # otechie: # Replace with a single Otechie username 17 | # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 18 | # custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Local .terraform directories 2 | **/.terraform/* 3 | 4 | # .tfstate files 5 | *.tfstate 6 | *.tfstate.* 7 | *.terraform.lock.hcl 8 | 9 | # Crash log files 10 | crash.log 11 | 12 | # Ignore any .tfvars files that are generated automatically for each Terraform run. Most 13 | # .tfvars files are managed as part of configuration and so should be included in 14 | # version control. 15 | # 16 | # example.tfvars 17 | 18 | # Ignore override files as they are usually used to override resources locally and so 19 | # are not checked in 20 | override.tf 21 | override.tf.json 22 | *_override.tf 23 | *_override.tf.json 24 | 25 | # Include override files you do wish to add to version control using negated pattern 26 | # 27 | # !example_override.tf 28 | 29 | # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan 30 | # example: *tfplan* 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure App Service (Web Apps) Terraform Module 2 | 3 | Azure App Service is a fully managed web hosting service for building web apps, mobile back ends and RESTful APIs. This terraform module helps you create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points. 4 | 5 | > **[!NOTE]** 6 | > **This module supports the meta arguments including `providers`, `depends_on`, `count`, and `for_each`.** 7 | 8 | ## Module Usage 9 | 10 | ```hcl 11 | # Azurerm Provider configuration 12 | provider "azurerm" { 13 | features {} 14 | } 15 | 16 | module "app-service" { 17 | source = "kumarvna/app-service/azurerm" 18 | version = "1.1.0" 19 | 20 | # By default, this module will not create a resource group. Location will be same as existing RG. 21 | # proivde a name to use an existing resource group, specify the existing resource group name, 22 | # set the argument to `create_resource_group = true` to create new resrouce group. 23 | resource_group_name = "rg-shared-westeurope-01" 24 | 25 | # App service plan setttings and supported arguments. Default name used by module 26 | # To specify custom name use `app_service_plan_name` with a valid name. 27 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 28 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 29 | service_plan = { 30 | kind = "Windows" 31 | size = "P1v2" 32 | tier = "PremiumV2" 33 | } 34 | 35 | # App Service settings and supported arguments 36 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 37 | app_service_name = "mypocproject" 38 | enable_client_affinity = true 39 | 40 | # A `site_config` block to setup the application environment. 41 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 42 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 43 | site_config = { 44 | always_on = true 45 | dotnet_framework_version = "v2.0" 46 | ftps_state = "FtpsOnly" 47 | managed_pipeline_mode = "Integrated" 48 | use_32_bit_worker_process = true 49 | windows_fx_version = "DOTNETCORE|2.1" 50 | } 51 | 52 | # (Optional) A key-value pair of Application Settings 53 | app_settings = { 54 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 55 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 56 | DiagnosticServices_EXTENSION_VERSION = "~3" 57 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 58 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 59 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 60 | XDT_MicrosoftApplicationInsights_Java = "1" 61 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 62 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 63 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 64 | } 65 | 66 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 67 | # You can configure the backups to be retained up to an indefinite amount of time. 68 | # Azure storage account and container in the same subscription as the app that you want to back up. 69 | # This module creates a Storage Container to keep the all backup items. 70 | # Backup items - App configuration , File content, Database connected to your app 71 | enable_backup = true 72 | storage_account_name = "stdiagfortesting" 73 | backup_settings = { 74 | enabled = true 75 | name = "DefaultBackup" 76 | frequency_interval = 1 77 | frequency_unit = "Day" 78 | retention_period_in_days = 90 79 | } 80 | 81 | # By default App Insight resource is created by this module. 82 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 83 | # Specifies the type of Application by setting up `application_insights_type` with valid string 84 | # Specifies the retention period in days using `retention_in_days`. Default 90. 85 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 86 | app_insights_name = "otkpocshared" 87 | 88 | # Adding TAG's to your Azure resources 89 | tags = { 90 | ProjectName = "demo-internal" 91 | Env = "dev" 92 | Owner = "user@example.com" 93 | BusinessUnit = "CORP" 94 | ServiceClass = "Gold" 95 | } 96 | } 97 | ``` 98 | 99 | ## App Service Plan 100 | 101 | An App Service plan defines a set of computing resources for a web app to run. These compute resources are analogous to the server farm in conventional web hosting. One or more apps can be configured to run on the same computing resources. 102 | 103 | The pricing tier (`Free`, `Shared`, `Basic`, `Standard`, `Premium`, `PremiumV2`, `PremiumV3`, `Isolated`) of an App Service plan determines what App Service features you get and how much you pay for the plan. There are a few categories of pricing tiers: 104 | 105 | - **Shared compute**: `Free` and `Shared`, the two base tiers, runs an app on the same Azure VM as other App Service apps, including apps of other customers. These tiers allocate CPU quotas to each app that runs on the shared resources, and the resources cannot scale out. 106 | - **Dedicated compute**: The Basic, Standard, Premium, PremiumV2, and PremiumV3 tiers run apps on dedicated Azure VMs. Only apps in the same App Service plan share the same compute resources. The higher the tier, the more VM instances are available to you for scale-out. 107 | - **Isolated**: This tier runs dedicated Azure VMs on dedicated Azure Virtual Networks. It provides network isolation on top of compute isolation to your apps. It provides the maximum scale-out capabilities. 108 | 109 | The **`service_paln`** object accept following keys: 110 | 111 | | Name | Description 112 | |--|-- 113 | kind|The kind of the App Service Plan to create. Possible values are `Windows` (also available as App), `Linux`, `elastic`(for Premium Consumption) and `FunctionApp` (for a Consumption Plan) 114 | size|Size specifier of the resource SKU. Available sizes are F1(Free), D1(Shared), B1(Basic Small), B2(Basic Medium), B3(Basic Large), S1(Standard Small), P1V2(Premium V2 Small), P1V3(Premium V3 Small), P2V3(Premium V3 Medium), P3V3(Premium V3 Large), PC2 (Premium Container Small), PC3 (Premium Container Medium), PC4 (Premium Container Large), I1 (Isolated Small), I2 (Isolated Medium), I3 (Isolated Large), I1v2 (Isolated V2 Small), I2v2 (Isolated V2 Medium), I3v2 (Isolated V2 Large). Valid accepted values are: `B1`, `B2`, `B3`, `D1`, `F1`, `FREE`, `I1`, `I1v2`, `I2`, `I2v2`, `I3`, `I3v2`, `P1V2`, `P1V3`, `P2V2`, `P2V3`, `P3V2`, `P3V3`, `PC2`, `PC3`, `PC4`, `S1`, `S2`, `S3`, `SHARED` 115 | capacity|Specifies the number of workers associated with this App Service Plan.|number|`1` 116 | tier|Specifies the plan's pricing tier. Valid option are `Free`, `Shared`, `Basic`, `Standard`, `PremiumV2` and `Isolated` 117 | per_site_scaling| Can Apps assigned to this App Service Plan be scaled independently? If set to false apps assigned to this plan will scale to all instances of the plan 118 | 119 | ## **`app_settings`** - Configure an App Service 120 | 121 | In App Service, app settings are variables passed as environment variables to the application code. For Linux apps and custom containers, App Service passes app settings to the container using the --env flag to set the environment variable in the container. 122 | 123 | `app_settings` object key-value pair examples: 124 | 125 | | Name | Description 126 | |--|-- 127 | APPINSIGHTS_PROFILERFEATURE_VERSION|"1.0.0" 128 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION|"1.0.0" 129 | DiagnosticServices_EXTENSION_VERSION|"~3" 130 | InstrumentationEngine_EXTENSION_VERSION|"disabled" 131 | SnapshotDebugger_EXTENSION_VERSION|"disabled" 132 | XDT_MicrosoftApplicationInsights_BaseExtensions|"disabled" 133 | XDT_MicrosoftApplicationInsights_Java|"1" 134 | XDT_MicrosoftApplicationInsights_Mode|"recommended" 135 | XDT_MicrosoftApplicationInsights_NodeJS|"1" 136 | XDT_MicrosoftApplicationInsights_PreemptSdk|"disabled" 137 | 138 | ## **`Site_Config`** - App Service general settings 139 | 140 | `site_config` block helps you setup the application environment and accept following Keys 141 | | Name | Description 142 | |--|-- 143 | always_on|Should the app be loaded at all times? Defaults to `false` 144 | app_command_line| App command line to launch, e.g. /sbin/myserver -b 0.0.0.0. 145 | default_documents|The ordering of default documents to load, if an address isn't specified. 146 | dotnet_framework_version|The version of the .net framework's CLR used in this App Service. Possible values are `v2.0` (which will use the latest version of the .net framework for the .net CLR v2 - currently `.net 3.5`), `v4.0` (which corresponds to the latest version of the .net CLR v4 - which at the time of writing is `.net 4.7.1`) and `v5.0`. [For more information on which .net CLR version to use based on the .net framework you're targeting - please see this table](https://en.wikipedia.org/wiki/.NET_Framework_version_history#Overview). Defaults to `v4.0`. 147 | ftps_state|State of FTP / FTPS service for this App Service. Possible values include: `AllAllowed`, `FtpsOnly` and `Disabled`. Defaults to `FtpsOnly` 148 | health_check_path|The health check path to be pinged by App Service. For more information - [please see App Service health check announcement](https://azure.github.io/AppService/2020/08/24/healthcheck-on-app-service.html). 149 | number_of_workers|The scaled number of workers (for per site scaling) of this App Service. Requires that `per_site_scaling` is enabled on the `azurerm_app_service_plan`. [For more information - please see Microsoft documentation on high-density hosting](https://docs.microsoft.com/en-us/azure/app-service/manage-scale-per-app). 150 | http2_enabled|Is HTTP2 Enabled on this App Service? Defaults to `false`. 151 | ip_restriction|A List of objects representing ip restrictions. User has to explicitly set `ip_restriction` to empty slice `( [] )` to remove it. 152 | scm_use_main_ip_restriction|IP security restrictions for scm to use main. Defaults to `false`. Any `scm_ip_restriction` blocks configured are ignored by the service when `scm_use_main_ip_restriction` is set to `true`. Any scm restrictions will become active if this is subsequently set to `false` or removed 153 | scm_ip_restriction|A List of objects representing ip restrictions. User has to explicitly set `ip_restriction` to empty slice `( [] )` to remove it. 154 | java_container|The Java Container to use. If specified `java_version` and `java_container_version` must also be specified. Possible values are `JAVA`, `JETTY`, and `TOMCAT`. 155 | java_container_version|The version of the Java Container to use. If specified `java_version` and `java_container` must also be specified. 156 | java_version| The version of Java to use. If specified `java_container` and `java_container_version` must also be specified. Possible values are `1.7`, `1.8` and `11` and their specific versions - except for Java 11 (e.g. `1.7.0_80`, `1.8.0_181`, `11`) 157 | local_mysql_enabled|Is "MySQL In App" Enabled? This runs a local MySQL instance with your app and shares resources from the App Service plan. **MySQL In App is not intended for production environments and will not scale beyond a single instance. Instead you may wish to use [Azure Database for MySQL](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mysql_database).** 158 | linux_fx_version|Linux App Framework and version for the App Service. Possible options are a Docker container `(DOCKER|)`, a base-64 encoded Docker Compose file `(COMPOSE|${filebase64("compose.yml")})` or a base-64 encoded Kubernetes Manifest `(KUBE|${filebase64("kubernetes.yml")})`. To find runtime stacks for Linux (`linux_fx_version`) based web apps run `az webapp list-runtimes --linux`. To set this property the App Service Plan to which the App belongs must be configured with `kind = "Linux"`, and `reserved = true` or the API will reject any value supplied. 159 | windows_fx_version| (Optional) The Windows Docker container image `(DOCKER|)`. To find built-in stacks (windows_fx_version) for web apps run `az webapp list-runtimes`. 160 | managed_pipeline_mode|The Managed Pipeline Mode. Possible values are `Integrated` and `Classic`. Defaults to `Integrated` 161 | min_tls_version|The minimum supported TLS version for the app service. Possible values are `1.0`, `1.1`, and `1.2`. Defaults to `1.2` for new app services. 162 | php_version|The version of PHP to use in this App Service. Possible values are `5.5`, `5.6`, `7.0`, `7.1`, `7.2`, `7.3` and `7.4`. 163 | python_version|The version of Python to use in this App Service. Possible values are `2.7` and `3.4`. 164 | remote_debugging_enabled|Is Remote Debugging Enabled? Defaults to `false`. 165 | remote_debugging_version|Which version of Visual Studio should the Remote Debugger be compatible with? Possible values are `VS2012`, `VS2013`, `VS2015` and `VS2017`. 166 | scm_type|The type of Source Control enabled for this App Service. Defaults to `None`. Possible values are: `BitbucketGit`, `BitbucketHg`, `CodePlexGit`, `CodePlexHg`, `Dropbox`, `ExternalGit`, `ExternalHg`, `GitHub`, `LocalGit`, `None`, `OneDrive`, `Tfs`, `VSO`, and `VSTSRM` 167 | use_32_bit_worker_process| Should the App Service run in 32 bit mode, rather than 64 bit mode? **when using an App Service Plan in the `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`.** 168 | websockets_enabled|Should WebSockets be enabled? 169 | 170 | ### A **`cors`** block - part of `site_config` supports the following 171 | 172 | Since App Service CORS lets you specify one set of accepted origins for all API routes and methods, you would want to use your own CORS code. See how ASP.NET Core does it at Enabling Cross-Origin Requests (CORS). Don't try to use App Service CORS and your own CORS code together. 173 | | Name | Description 174 | |--|-- 175 | allowed_origins|A list of origins which should be able to make cross-origin calls. `*` can be used to allow all calls. 176 | support_credentials|Are credentials supported? 177 | 178 | ### **`ip_restriction`** and **`scm_ip_restriction`** - App Service access restrictions 179 | 180 | By setting up access restrictions, you can define a priority-ordered allow/deny list that controls network access to your app. The list can include IP addresses or Azure Virtual Network subnets. When there are one or more entries, an implicit deny all exists at the end of the list. 181 | 182 | The access restriction capability is implemented in the App Service front-end roles, which are upstream of the worker hosts where your code runs. Therefore, access restrictions are effectively network access-control lists (ACLs). 183 | 184 | The ability to restrict access to your web app from an Azure virtual network is enabled by service endpoints. With service endpoints, you can restrict access to a multi-tenant service from selected subnets. It doesn't work to restrict traffic to apps that are hosted in an App Service Environment. If you're in an App Service Environment, you can control access to your app by applying IP address rules. 185 | 186 | A `ip_restriction` or `scm_ip_restriction` block supports the following and managed by `ips_allowed`, `subnet_ids_allowed`, `service_tags_allowed`, `scm_ips_allowed`, `scm_subnet_ids_allowed`, `scm_service_tags_allowed` variables. You can specify any of these variable with valid list of strings to manage the requird access. 187 | 188 | > If enabled, one of either ip_address, service_tag or virtual_network_subnet_id must be specified. 189 | 190 | | Name | Description 191 | |--|-- 192 | ip_address|The IP Address used for this IP Restriction in `CIDR` notation. 193 | service_tag|The `Service Tag` used for this IP Restriction. 194 | virtual_network_subnet_id|The `Virtual Network Subnet ID` used for this IP Restriction. 195 | name|The name for this IP Restriction. 196 | priority|The priority for this IP Restriction. Restrictions are enforced in priority order. By default, priority is set to `65000` if not specified. 197 | action|Does this restriction `Allow` or `Deny` access for this IP range. Defaults to `Allow`. 198 | 199 | ## **`auth_settings`** - Authentication and authorization in Azure App Service 200 | 201 | Azure App Service provides built-in authentication and authorization capabilities (sometimes referred to as "Easy Auth"), so you can sign in users and access data by writing minimal or no code in your web app, RESTful API, and mobile back end, and also Azure Functions. 202 | 203 | App Service uses federated identity, in which a third-party identity provider manages the user identities and authentication flow for you. `Microsoft Identity Platform`, `Facebook`, `Google`, `Twitter`, Any `OpenID Connect` Provider are available by default. 204 | 205 | This Module support `Azure Active Directory Integration` and needs following keys. 206 | 207 | | Name | Description 208 | |--|-- 209 | client_id|The Client ID of this relying party application. Enables OpenIDConnection authentication with Azure Active Directory. 210 | client_secret|The Client Secret of this relying party application. If no secret is provided, implicit flow will be used. 211 | allowed_audiences| Allowed audience values to consider when validating JSON Web Tokens issued by Azure Active Directory. 212 | 213 | ## **`backup`** - Backup and Restore feature in Azure App Service 214 | 215 | The Backup and Restore feature in Azure App Service lets you easily create app backups manually or on a schedule. You can configure the backups to be retained up to an indefinite amount of time. You can restore the app to a snapshot of a previous state by overwriting the existing app or restoring to another app. 216 | 217 | ### What gets backed up 218 | 219 | - App configuration 220 | - File content 221 | - Database connected to your app 222 | 223 | ### Requirements and restrictions 224 | 225 | - The Backup and Restore feature requires the App Service plan to be in the `Standard`, `Premium` or `Isolated`. **`Premium`** and **`Isolated`** tiers allow a greater number of daily back ups than `Standard` tier. 226 | - You need an Azure storage account and container in the same subscription as the app that you want to back up. 227 | - Backups can be up to 10 GB of app and database content. If the backup size exceeds this limit, you get an error. 228 | - Backups of TLS enabled Azure Database for MySQL is not supported. 229 | - Backups of TLS enabled Azure Database for PostgreSQL is not supported. 230 | - In-app MySQL databases are automatically backed up without any configuration. If you make manually settings for in-app MySQL databases, such as adding connection strings, the backups may not work correctly. 231 | - Using a firewall enabled storage account as the destination for your backups is not supported. 232 | - Currently, you can't use the Backup and Restore feature with the Azure App Service VNet Integration feature. 233 | - Currently, you can't use the Backup and Restore feature with Azure storage accounts that are configured to use Private Endpoint. 234 | 235 | > Each backup is a complete offline copy of your app, not an incremental update. 236 | 237 | `backup` object accepct following keys: 238 | | Name | Description 239 | |--|-- 240 | enable_backup | condition to enable backup functionality to this module and can be enabled by setting up the variable `enable_backup = true`. Defaults to `false` 241 | name|Specifies the name for this Backup. 242 | enabled|Is backup enabled? Depends on `enable_backup` variable 243 | storage_account_url|The SAS URL to a Storage Container where Backups should be saved. 244 | frequency_interval|Sets how often the backup should be executed. 245 | frequency_unit|Sets the unit of time for how often the backup should be executed. Possible values are `Day` or `Hour`. 246 | retention_period_in_days|Specifies the number of days after which Backups should be deleted. 247 | start_time|Sets when the schedule should start working 248 | 249 | ## **`connection_string`** - Configure connection strings 250 | 251 | For ASP.NET and ASP.NET Core developers, setting connection strings in App Service are like setting them in `` in `Web.config`, but the values you set in App Service override the ones in `Web.config`. You can keep development settings in Web.config and SQL Database credentials safely in App Service. The same code uses your development settings when you debug locally, and it uses your production secrets when deployed to Azure. 252 | 253 | At runtime, connection strings are available as environment variables, prefixed with the following connection types: 254 | 255 | - SQLServer: SQLCONNSTR_ 256 | - MySQL: MYSQLCONNSTR_ 257 | - SQLAzure: SQLAZURECONNSTR_ 258 | - Custom: CUSTOMCONNSTR_ 259 | - PostgreSQL: POSTGRESQLCONNSTR_ 260 | 261 | For example, a MySql connection string named connectionstring1 can be accessed as the environment variable MYSQLCONNSTR_connectionString1. 262 | 263 | `connection_string` object accepts following keys: 264 | 265 | | Name | Description 266 | |--|-- 267 | name|The name of the Connection String 268 | type|The type of the Connection String. Possible values are `APIHub`, `Custom`, `DocDb`, `EventHub`, `MySQL`, `NotificationHub`, `PostgreSQL`, `RedisCache`, `ServiceBus`, `SQLAzure` and `SQLServer`. 269 | value|The value for the Connection String 270 | 271 | ## **`storage_account`** - Access Azure Storage from a web app 272 | 273 | > Azure Storage in App Service is in preview for App Service on Linux and Web App for Containers. It's not supported for production scenarios. 274 | 275 | ### Limitations 276 | 277 | - Azure Storage in App Service supports mounting Azure Files containers (Read / Write) and Azure Blob containers (Read Only) 278 | - Azure Storage in App Service lets you specify up to five mount points per app. 279 | - Azure Storage mounted to an app is not accessible through App Service FTP/FTPs endpoints. Use Azure Storage Explorer. 280 | 281 | `storage_account` object accepts following keys: 282 | 283 | | Name | Description 284 | |--|-- 285 | name|The name of the storage account identifier. 286 | type|The type of storage. Possible values are AzureBlob and AzureFiles. 287 | account_name|The name of the storage account. 288 | share_name|The name of the file share (container name, for Blob storage). 289 | access_key|The access key for the storage account. 290 | mount_path|The path to mount the storage within the site's runtime environment. 291 | 292 | ## **`identity`** - managed identities for App Service 293 | 294 | A managed identity from Azure Active Directory (Azure AD) allows your app to easily access other Azure AD-protected resources such as Azure Key Vault. The identity is managed by the Azure platform and does not require you to provision or rotate any secrets. 295 | 296 | Your application can be granted two types of identities: 297 | 298 | - **A system-assigned identity**is tied to your application and is deleted if your app is deleted. An app can only have one system-assigned identity. 299 | - **A user-assigned identity** is a standalone Azure resource that can be assigned to your app. An app can have multiple user-assigned identities. 300 | 301 | > An application can have both system-assigned and user-assigned identities at the same time. In this case, the property would be `SystemAssigned, UserAssigned` 302 | 303 | `identity` object requires following keys: 304 | 305 | | Name | Description 306 | |--|-- 307 | type| Specifies the identity type of the App Service. Possible values are `SystemAssigned` (where Azure will generate a Service Principal for you), `UserAssigned` where you can specify the Service Principal IDs in the `identity_ids` field, and `SystemAssigned, UserAssigned` which assigns both a system managed identity as well as the specified user assigned identities. When `type` is set to `SystemAssigned`, The assigned `principal_id` and `tenant_id` can be retrieved after the App Service has been created. 308 | identity_ids|Specifies a list of user managed identity ids to be assigned. Required if `type` is `UserAssigned`. 309 | 310 | ## VNet Integration - Integrate app with an Azure virtual network 311 | 312 | VNet integration gives your app access to resources in your VNet, but it doesn't grant inbound private access to your app from the VNet. Private site access refers to making an app accessible only from a private network, such as from within an Azure virtual network. VNet integration is used only to make outbound calls from your app into your VNet. This feature requires a `Standard`, `Premium`, `PremiumV2`, `PremiumV3`, or `Elastic Premium` App Service pricing tier. 313 | 314 | This feature can be enabled by setting up `enable_vnet_integration` varaible to `true` and providing a valid `subnet_id`. The subnet must have a `service_delegation` configured for `Microsoft.Web/serverFarms` 315 | 316 | [Example usage of App service with VNet Integration](examples/app-service-with-vnet-integration/) 317 | 318 | ## App Insights 319 | 320 | Application Insights, a feature of Azure Monitor, is an extensible Application Performance Management (APM) service for developers and DevOps professionals. Use it to monitor your live applications. It will automatically detect performance anomalies, and includes powerful analytics tools to help you diagnose issues and to understand what users actually do with your app. It's designed to help you continuously improve performance and usability. It works for apps on a wide variety of platforms including .NET, Node.js, Java, and Python hosted on-premises, hybrid, or any public cloud. It integrates with your DevOps process, and has connection points to a variety of development tools. It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center. 321 | 322 | By default, this module creates App Insight and enables monitoring integration for app service. You can also specify existing App Insight in case you want to use one. See the following table for various options to customize the experience. 323 | 324 | | Name | Description 325 | |--|-- 326 | application_insights_enabled| Specify the Application Insights use for this App Service. Defaults to `true` 327 | application_insights_id| Resource ID of the existing Application Insights. Defaults to `false` 328 | app_insights_name|The Name of the application insights if you are creating the new resource with this module. 329 | application_insights_type|Specifies the type of Application Insights to create. Valid values are `ios` for iOS, `java` for Java web, `MobileCenter` for App Center, `Node.JS` for Node.js, `other` for General, `phone` for Windows Phone, `store` for Windows Store and `web` for ASP.NET. Defaults to `web` 330 | retention_in_days|Specifies the retention period in days. Possible values are `30`, `60`, `90`, `120`, `180`, `270`, `365`, `550` or `730`. Defaults to `90` 331 | disable_ip_masking|By default the real client ip is masked as `0.0.0.0` in the logs. Use this argument to disable masking and log the real client ip. Defaults to `false` 332 | 333 | ## Recommended naming and tagging conventions 334 | 335 | Applying tags to your Azure resources, resource groups, and subscriptions to logically organize them into a taxonomy. Each tag consists of a name and a value pair. For example, you can apply the name `Environment` and the value `Production` to all the resources in production. 336 | For recommendations on how to implement a tagging strategy, see Resource naming and tagging decision guide. 337 | 338 | > **Important** : 339 | Tag names are case-insensitive for operations. A tag with a tag name, regardless of the casing, is updated or retrieved. However, the resource provider might keep the casing you provide for the tag name. You'll see that casing in cost reports. **Tag values are case-sensitive.** 340 | 341 | An effective naming convention assembles resource names by using important resource information as parts of a resource's name. For example, using these [recommended naming conventions](https://docs.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/naming-and-tagging#example-names), a public IP resource for a production SharePoint workload is named like this: `pip-sharepoint-prod-westus-001`. 342 | 343 | ## Requirements 344 | 345 | | Name | Version | 346 | | --------- | --------- | 347 | | terraform | >= 0.13 | 348 | | azurerm | >= 2.59.0 | 349 | 350 | ## Providers 351 | 352 | | Name | Version | 353 | | ------- | --------- | 354 | | azurerm | >= 2.59.0 | 355 | 356 | ## Inputs 357 | 358 | | Name | Description | Type | Default | 359 | |--|--|--|--| 360 | `create_resource_group` | Whether to create resource group and use it for all networking resources | string | `"false"` 361 | `resource_group_name` | The name of the resource group in which resources are created | string | `""` 362 | `location` | The location of the resource group in which resources are created | string | `""` 363 | `subnet_id`|The resource id of the subnet for regional vnet integration|string|`""` 364 | `app_service_plan_name` | Specifies the name of the App Service Plan component | string | `""` 365 | `service_plan` | Definition of the dedicated plan to use | object({}) | `{}` 366 | `app_service_name` | Specifies the name of the App Service | string | `""` 367 | `app_settings` | A key-value pair of App Settings | map(string) | `{}` 368 | `site_config` | Site configuration for Application Service | any | `{}` 369 | `ips_allowed` | IPs restriction for App Service to allow specific IP addresses or ranges | list(string) | `[]` 370 | `subnet_ids_allowed` | Allow Specific Subnets for App Service | list(string) | `[]` 371 | `service_tags_allowed` | Restrict Service Tags for App Service | list(string) | `[]` 372 | `scm_ips_allowed` | SCM IP restrictions for App service | list(string) | `[]` 373 | `scm_subnet_ids_allowed` | Restrict SCM Subnets for App Service | list(string) | `[]` 374 | `scm_service_tags_allowed` | Restrict SCM Service Tags for App Service | list(string) | `[]` 375 | `enable_auth_settings` | Specifies the Authenication enabled or not | string | `false` 376 | `default_auth_provider` | The default provider to use when multiple providers have been set up. Possible values are `AzureActiveDirectory`, `Facebook`, `Google`, `MicrosoftAccount` and `Twitter`" | string | `"AzureActiveDirectory"` 377 | `unauthenticated_client_action` | The action to take when an unauthenticated client attempts to access the app. Possible values are `AllowAnonymous` and `RedirectToLoginPage` |string | `"RedirectToLoginPage"` 378 | `token_store_enabled` | If enabled the module will durably store platform-specific security tokens that are obtained during login flows | string | `false` 379 | `active_directory_auth_setttings` | Acitve directory authentication provider settings for app service | any | `{}` 380 | `enable_client_affinity` | Should the App Service send session affinity cookies, which route client requests in the same session to the same instance? | string | `false` 381 | `enable_client_certificate` | Does the App Service require client certificates for incoming requests | string | `false` 382 | `enable_https` | Can the App Service only be accessed via HTTPS? | string | `false` 383 | `enable_backup` | bool to to setup backup for app service | string | `false` 384 | `backup_settings` | Backup settings for App service | object({}) | `{}` 385 | `connection_strings` | Connection strings for App Service | list(map(string)) | `[]` 386 | `identity_ids` | Specifies a list of user managed identity ids to be assigned | string | `null` 387 | `storage_mounts` | Storage account mount points for App Service | list(map(string)) | `[]` 388 | `custom_domains` | Custom domains with SSL binding and SSL certificates for the App Service. Getting the SSL certificate from an Azure Keyvault Certificate Secret or a file is possible | map(map(string)) | `null` 389 | `application_insights_enabled` | Specify the Application Insights use for this App Service | string | `true` 390 | `application_insights_id` | Resource ID of the existing Application Insights | string | `null` 391 | `app_insights_name` | The Name of the application insights | string | `""` 392 | `application_insights_type` | Specifies the type of Application Insights to create. Valid values are `ios` for iOS, `java` for Java web, `MobileCenter` for App Center, `Node.JS` for Node.js, `other` for General, `phone` for Windows Phone, `store` for Windows Store and `web` for ASP.NET | string | `"web"` 393 | `retention_in_days` | Specifies the retention period in days. Possible values are `30`, `60`, `90`, `120`, `180`, `270`, `365`, `550` or `730` | number | `90` 394 | `disable_ip_masking` | By default the real client ip is masked as `0.0.0.0` in the logs. Use this argument to disable masking and log the real client ip | string | `false` 395 | `enable_vnet_integration`|Manages an App Service Virtual Network Association|string|`false` 396 | `Tags` | A map of tags to add to all resources | map | `{}` 397 | 398 | ## Outputs 399 | 400 | | Name | Description | 401 | |--|--| 402 | `app_service_plan_id` | The resource ID of the App Service Plan component 403 | `maximum_number_of_workers` | The maximum number of workers supported with the App Service Plan's sku 404 | `app_service_id` | The resource ID of the App Service component 405 | `default_site_hostname` | The Default Hostname associated with the App Service 406 | `outbound_ip_addresses` | A comma separated list of outbound IP addresses 407 | `outbound_ip_address_list` | A list of outbound IP addresses 408 | `possible_outbound_ip_addresses` | A comma separated list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_addresses`. 409 | `possible_outbound_ip_address_list` | A list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_address_list` 410 | `identity` | An identity block, which contains the Managed Service Identity information for this App Service 411 | `application_insights_id` | The ID of the Application Insights component 412 | `application_insights_app_id` | The App ID associated with this Application Insights component 413 | `application_insights_instrumentation_key` | The Instrumentation Key for this Application Insights component 414 | `application_insights_connection_string` | The Connection String for this Application Insights component 415 | `app_service_virtual_network_swift_connection_id`|The ID of the App Service Virtual Network integration 416 | 417 | ## Resource Graph 418 | 419 | ![Resource Graph](graph.png) 420 | 421 | ## Authors 422 | 423 | Originally created by [Kumaraswamy Vithanala](mailto:kumarvna@gmail.com) 424 | 425 | ## Other resources 426 | 427 | - [App Service(Web Apps)](https://docs.microsoft.com/en-us/azure/app-service/) 428 | - [Terraform AzureRM Provider Documentation](https://www.terraform.io/docs/providers/azurerm/index.html) 429 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # Azure App Service (Web Apps) Terraform Module 2 | 3 | Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points. 4 | 5 | ## Module Usage to create simple app service with optional resoruces 6 | 7 | ```hcl 8 | # Azurerm Provider configuration 9 | provider "azurerm" { 10 | features {} 11 | } 12 | 13 | module "app-service" { 14 | source = "kumarvna/app-service/azurerm" 15 | version = "1.1.0" 16 | 17 | # By default, this module will not create a resource group. Location will be same as existing RG. 18 | # proivde a name to use an existing resource group, specify the existing resource group name, 19 | # set the argument to `create_resource_group = true` to create new resrouce group. 20 | resource_group_name = "rg-shared-westeurope-01" 21 | 22 | # App service plan setttings and supported arguments. Default name used by module 23 | # To specify custom name use `app_service_plan_name` with a valid name. 24 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 25 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 26 | service_plan = { 27 | kind = "Windows" 28 | size = "P1v2" 29 | tier = "PremiumV2" 30 | } 31 | 32 | # App Service settings and supported arguments 33 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 34 | app_service_name = "myapp-poc-project" 35 | enable_client_affinity = true 36 | 37 | # A `site_config` block to setup the application environment. 38 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 39 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 40 | site_config = { 41 | always_on = true 42 | dotnet_framework_version = "v2.0" 43 | ftps_state = "FtpsOnly" 44 | managed_pipeline_mode = "Integrated" 45 | use_32_bit_worker_process = true 46 | windows_fx_version = "DOTNETCORE|2.1" 47 | } 48 | 49 | # (Optional) A key-value pair of Application Settings 50 | app_settings = { 51 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 52 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 53 | DiagnosticServices_EXTENSION_VERSION = "~3" 54 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 55 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 56 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 57 | XDT_MicrosoftApplicationInsights_Java = "1" 58 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 59 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 60 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 61 | } 62 | 63 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 64 | # You can configure the backups to be retained up to an indefinite amount of time. 65 | # Azure storage account and container in the same subscription as the app that you want to back up. 66 | # This module creates a Storage Container to keep the all backup items. 67 | # Backup items - App configuration , File content, Database connected to your app 68 | enable_backup = true 69 | storage_account_name = "stdiagfortesting1" 70 | backup_settings = { 71 | enabled = true 72 | name = "DefaultBackup" 73 | frequency_interval = 1 74 | frequency_unit = "Day" 75 | retention_period_in_days = 90 76 | } 77 | 78 | # By default App Insight resource is created by this module. 79 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 80 | # Specifies the type of Application by setting up `application_insights_type` with valid string 81 | # Specifies the retention period in days using `retention_in_days`. Default 90. 82 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 83 | app_insights_name = "otkpocshared" 84 | 85 | # Adding TAG's to your Azure resources 86 | tags = { 87 | ProjectName = "demo-internal" 88 | Env = "dev" 89 | Owner = "user@example.com" 90 | BusinessUnit = "CORP" 91 | ServiceClass = "Gold" 92 | } 93 | } 94 | ``` 95 | 96 | ## Module Usage to create app service and optional resoruces with VNet integration 97 | 98 | ```hcl 99 | # Azurerm Provider configuration 100 | provider "azurerm" { 101 | features {} 102 | } 103 | 104 | locals { 105 | tags = { 106 | ProjectName = "demo-internal" 107 | Env = "dev" 108 | Owner = "user@example.com" 109 | BusinessUnit = "CORP" 110 | ServiceClass = "Gold" 111 | } 112 | } 113 | 114 | module "vnet" { 115 | source = "kumarvna/vnet/azurerm" 116 | version = "2.1.0" 117 | 118 | create_resource_group = false 119 | resource_group_name = "rg-shared-westeurope-01" 120 | vnetwork_name = "vnet-shared-hub-westeurope-002" 121 | location = "westeurope" 122 | vnet_address_space = ["10.2.0.0/16"] 123 | create_network_watcher = false 124 | 125 | subnets = { 126 | web_subnet = { 127 | subnet_name = "snet-webapp" 128 | subnet_address_prefix = ["10.2.1.0/24"] 129 | delegation = { 130 | name = "testdelegation" 131 | service_delegation = { 132 | name = "Microsoft.Web/serverFarms" 133 | actions = ["Microsoft.Network/virtualNetworks/subnets/action"] 134 | } 135 | } 136 | } 137 | } 138 | tags = local.tags 139 | } 140 | 141 | module "app-service" { 142 | source = "kumarvna/app-service/azurerm" 143 | version = "1.1.0" 144 | 145 | # By default, this module will not create a resource group. Location will be same as existing RG. 146 | # proivde a name to use an existing resource group, specify the existing resource group name, 147 | # set the argument to `create_resource_group = true` to create new resrouce group. 148 | resource_group_name = "rg-shared-westeurope-01" 149 | 150 | # App service plan setttings and supported arguments. Default name used by module 151 | # To specify custom name use `app_service_plan_name` with a valid name. 152 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 153 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 154 | service_plan = { 155 | kind = "Windows" 156 | size = "P1v2" 157 | tier = "PremiumV2" 158 | } 159 | 160 | # App Service settings and supported arguments 161 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 162 | app_service_name = "kumarsmypocproject" 163 | enable_client_affinity = true 164 | 165 | # A `site_config` block to setup the application environment. 166 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 167 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 168 | site_config = { 169 | always_on = true 170 | dotnet_framework_version = "v2.0" 171 | ftps_state = "FtpsOnly" 172 | managed_pipeline_mode = "Integrated" 173 | use_32_bit_worker_process = true 174 | windows_fx_version = "DOTNETCORE|2.1" 175 | } 176 | 177 | # (Optional) A key-value pair of Application Settings 178 | app_settings = { 179 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 180 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 181 | DiagnosticServices_EXTENSION_VERSION = "~3" 182 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 183 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 184 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 185 | XDT_MicrosoftApplicationInsights_Java = "1" 186 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 187 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 188 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 189 | } 190 | 191 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 192 | # You can configure the backups to be retained up to an indefinite amount of time. 193 | # Azure storage account and container in the same subscription as the app that you want to back up. 194 | # This module creates a Storage Container to keep the all backup items. 195 | # Backup items - App configuration , File content, Database connected to your app 196 | enable_backup = true 197 | storage_account_name = "stdiagfortesting1" 198 | backup_settings = { 199 | enabled = true 200 | name = "DefaultBackup" 201 | frequency_interval = 1 202 | frequency_unit = "Day" 203 | retention_period_in_days = 90 204 | } 205 | 206 | # Regional VNet integration configuration 207 | # Enables you to place the back end of app in a subnet in virtual network in the same region 208 | enable_vnet_integration = true 209 | subnet_id = element(module.vnet.subnet_ids, 0) 210 | 211 | # By default App Insight resource is created by this module. 212 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 213 | # Specifies the type of Application by setting up `application_insights_type` with valid string 214 | # Specifies the retention period in days using `retention_in_days`. Default 90. 215 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 216 | app_insights_name = "otkpocshared" 217 | 218 | # Adding TAG's to your Azure resources 219 | tags = local.tags 220 | } 221 | ``` 222 | 223 | ## Terraform Usage 224 | 225 | To run this example you need to execute following Terraform commands 226 | 227 | ```hcl 228 | terraform init 229 | terraform plan 230 | terraform apply 231 | ``` 232 | 233 | Run `terraform destroy` when you don't need these resources. 234 | -------------------------------------------------------------------------------- /examples/app-service-with-vnet-integration/README.md: -------------------------------------------------------------------------------- 1 | # Azure App Service (Web Apps) Terraform Module 2 | 3 | Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points. 4 | 5 | ## Module Usage 6 | 7 | ```hcl 8 | # Azurerm Provider configuration 9 | provider "azurerm" { 10 | features {} 11 | } 12 | 13 | locals { 14 | tags = { 15 | ProjectName = "demo-internal" 16 | Env = "dev" 17 | Owner = "user@example.com" 18 | BusinessUnit = "CORP" 19 | ServiceClass = "Gold" 20 | } 21 | } 22 | 23 | module "vnet" { 24 | source = "kumarvna/vnet/azurerm" 25 | version = "2.1.0" 26 | 27 | create_resource_group = false 28 | resource_group_name = "rg-shared-westeurope-01" 29 | vnetwork_name = "vnet-shared-hub-westeurope-002" 30 | location = "westeurope" 31 | vnet_address_space = ["10.2.0.0/16"] 32 | create_network_watcher = false 33 | 34 | subnets = { 35 | web_subnet = { 36 | subnet_name = "snet-webapp" 37 | subnet_address_prefix = ["10.2.1.0/24"] 38 | delegation = { 39 | name = "testdelegation" 40 | service_delegation = { 41 | name = "Microsoft.Web/serverFarms" 42 | actions = ["Microsoft.Network/virtualNetworks/subnets/action"] 43 | } 44 | } 45 | } 46 | } 47 | tags = local.tags 48 | } 49 | 50 | module "app-service" { 51 | source = "kumarvna/app-service/azurerm" 52 | version = "1.1.0" 53 | 54 | # By default, this module will not create a resource group. Location will be same as existing RG. 55 | # proivde a name to use an existing resource group, specify the existing resource group name, 56 | # set the argument to `create_resource_group = true` to create new resrouce group. 57 | resource_group_name = "rg-shared-westeurope-01" 58 | 59 | # App service plan setttings and supported arguments. Default name used by module 60 | # To specify custom name use `app_service_plan_name` with a valid name. 61 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 62 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 63 | service_plan = { 64 | kind = "Windows" 65 | size = "P1v2" 66 | tier = "PremiumV2" 67 | } 68 | 69 | # App Service settings and supported arguments 70 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 71 | app_service_name = "kumarsmypocproject" 72 | enable_client_affinity = true 73 | 74 | # A `site_config` block to setup the application environment. 75 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 76 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 77 | site_config = { 78 | always_on = true 79 | dotnet_framework_version = "v2.0" 80 | ftps_state = "FtpsOnly" 81 | managed_pipeline_mode = "Integrated" 82 | use_32_bit_worker_process = true 83 | windows_fx_version = "DOTNETCORE|2.1" 84 | } 85 | 86 | # (Optional) A key-value pair of Application Settings 87 | app_settings = { 88 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 89 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 90 | DiagnosticServices_EXTENSION_VERSION = "~3" 91 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 92 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 93 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 94 | XDT_MicrosoftApplicationInsights_Java = "1" 95 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 96 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 97 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 98 | } 99 | 100 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 101 | # You can configure the backups to be retained up to an indefinite amount of time. 102 | # Azure storage account and container in the same subscription as the app that you want to back up. 103 | # This module creates a Storage Container to keep the all backup items. 104 | # Backup items - App configuration , File content, Database connected to your app 105 | enable_backup = true 106 | storage_account_name = "stdiagfortesting1" 107 | backup_settings = { 108 | enabled = true 109 | name = "DefaultBackup" 110 | frequency_interval = 1 111 | frequency_unit = "Day" 112 | retention_period_in_days = 90 113 | } 114 | 115 | # Regional VNet integration configuration 116 | # Enables you to place the back end of app in a subnet in virtual network in the same region 117 | enable_vnet_integration = true 118 | subnet_id = element(module.vnet.subnet_ids, 0) 119 | 120 | # By default App Insight resource is created by this module. 121 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 122 | # Specifies the type of Application by setting up `application_insights_type` with valid string 123 | # Specifies the retention period in days using `retention_in_days`. Default 90. 124 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 125 | app_insights_name = "otkpocshared" 126 | 127 | # Adding TAG's to your Azure resources 128 | tags = local.tags 129 | } 130 | ``` 131 | 132 | ## Terraform Usage 133 | 134 | To run this example you need to execute following Terraform commands 135 | 136 | ```hcl 137 | terraform init 138 | terraform plan 139 | terraform apply 140 | ``` 141 | 142 | Run `terraform destroy` when you don't need these resources. 143 | -------------------------------------------------------------------------------- /examples/app-service-with-vnet-integration/main.tf: -------------------------------------------------------------------------------- 1 | # Azurerm Provider configuration 2 | provider "azurerm" { 3 | features {} 4 | } 5 | 6 | locals { 7 | tags = { 8 | ProjectName = "demo-internal" 9 | Env = "dev" 10 | Owner = "user@example.com" 11 | BusinessUnit = "CORP" 12 | ServiceClass = "Gold" 13 | } 14 | } 15 | 16 | module "vnet" { 17 | source = "kumarvna/vnet/azurerm" 18 | version = "2.1.0" 19 | 20 | create_resource_group = false 21 | resource_group_name = "rg-shared-westeurope-01" 22 | vnetwork_name = "vnet-shared-hub-westeurope-002" 23 | location = "westeurope" 24 | vnet_address_space = ["10.2.0.0/16"] 25 | create_network_watcher = false 26 | 27 | subnets = { 28 | web_subnet = { 29 | subnet_name = "snet-webapp" 30 | subnet_address_prefix = ["10.2.1.0/24"] 31 | delegation = { 32 | name = "testdelegation" 33 | service_delegation = { 34 | name = "Microsoft.Web/serverFarms" 35 | actions = ["Microsoft.Network/virtualNetworks/subnets/action"] 36 | } 37 | } 38 | } 39 | } 40 | tags = local.tags 41 | } 42 | 43 | module "app-service" { 44 | source = "kumarvna/app-service/azurerm" 45 | version = "1.1.0" 46 | 47 | # By default, this module will not create a resource group. Location will be same as existing RG. 48 | # proivde a name to use an existing resource group, specify the existing resource group name, 49 | # set the argument to `create_resource_group = true` to create new resrouce group. 50 | resource_group_name = "rg-shared-westeurope-01" 51 | 52 | # App service plan setttings and supported arguments. Default name used by module 53 | # To specify custom name use `app_service_plan_name` with a valid name. 54 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 55 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 56 | service_plan = { 57 | kind = "Windows" 58 | size = "P1v2" 59 | tier = "PremiumV2" 60 | } 61 | 62 | # App Service settings and supported arguments 63 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 64 | app_service_name = "kumarsmypocproject" 65 | enable_client_affinity = true 66 | 67 | # A `site_config` block to setup the application environment. 68 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 69 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 70 | site_config = { 71 | always_on = true 72 | dotnet_framework_version = "v2.0" 73 | ftps_state = "FtpsOnly" 74 | managed_pipeline_mode = "Integrated" 75 | use_32_bit_worker_process = true 76 | windows_fx_version = "DOTNETCORE|2.1" 77 | } 78 | 79 | # (Optional) A key-value pair of Application Settings 80 | app_settings = { 81 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 82 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 83 | DiagnosticServices_EXTENSION_VERSION = "~3" 84 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 85 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 86 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 87 | XDT_MicrosoftApplicationInsights_Java = "1" 88 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 89 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 90 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 91 | } 92 | 93 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 94 | # You can configure the backups to be retained up to an indefinite amount of time. 95 | # Azure storage account and container in the same subscription as the app that you want to back up. 96 | # This module creates a Storage Container to keep the all backup items. 97 | # Backup items - App configuration , File content, Database connected to your app 98 | enable_backup = true 99 | storage_account_name = "stdiagfortesting1" 100 | backup_settings = { 101 | enabled = true 102 | name = "DefaultBackup" 103 | frequency_interval = 1 104 | frequency_unit = "Day" 105 | retention_period_in_days = 90 106 | } 107 | 108 | # Regional VNet integration configuration 109 | # Enables you to place the back end of app in a subnet in virtual network in the same region 110 | enable_vnet_integration = true 111 | subnet_id = element(module.vnet.subnet_ids, 0) 112 | 113 | # By default App Insight resource is created by this module. 114 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 115 | # Specifies the type of Application by setting up `application_insights_type` with valid string 116 | # Specifies the retention period in days using `retention_in_days`. Default 90. 117 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 118 | app_insights_name = "otkpocshared" 119 | 120 | # Adding TAG's to your Azure resources 121 | tags = local.tags 122 | } 123 | -------------------------------------------------------------------------------- /examples/app-service-with-vnet-integration/output.tf: -------------------------------------------------------------------------------- 1 | output "app_service_plan_id" { 2 | description = "The resource ID of the App Service Plan component" 3 | value = module.app-service.app_service_plan_id 4 | } 5 | 6 | output "maximum_number_of_workers" { 7 | description = " The maximum number of workers supported with the App Service Plan's sku" 8 | value = module.app-service.maximum_number_of_workers 9 | } 10 | 11 | output "app_service_id" { 12 | description = "The resource ID of the App Service component" 13 | value = module.app-service.app_service_id 14 | } 15 | 16 | output "default_site_hostname" { 17 | description = "The Default Hostname associated with the App Service" 18 | value = module.app-service.default_site_hostname 19 | } 20 | 21 | output "outbound_ip_addresses" { 22 | description = "A comma separated list of outbound IP addresses" 23 | value = module.app-service.outbound_ip_addresses 24 | } 25 | 26 | output "outbound_ip_address_list" { 27 | description = "A list of outbound IP addresses" 28 | value = module.app-service.outbound_ip_address_list 29 | } 30 | 31 | output "possible_outbound_ip_addresses" { 32 | description = "A comma separated list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_addresses`." 33 | value = module.app-service.possible_outbound_ip_addresses 34 | } 35 | 36 | output "possible_outbound_ip_address_list" { 37 | description = "A list of outbound IP addresses - not all of which are necessarily in use. Superset of outbound_ip_address_list." 38 | value = module.app-service.possible_outbound_ip_address_list 39 | } 40 | 41 | output "identity" { 42 | description = "An identity block, which contains the Managed Service Identity information for this App Service." 43 | value = module.app-service.identity 44 | } 45 | 46 | output "application_insights_id" { 47 | description = "The ID of the Application Insights component" 48 | value = module.app-service.application_insights_id 49 | } 50 | 51 | output "application_insights_app_id" { 52 | description = "The App ID associated with this Application Insights component" 53 | value = module.app-service.application_insights_app_id 54 | } 55 | 56 | output "application_insights_instrumentation_key" { 57 | description = "The Instrumentation Key for this Application Insights component" 58 | value = module.app-service.application_insights_instrumentation_key 59 | sensitive = true 60 | } 61 | 62 | output "application_insights_connection_string" { 63 | description = "The Connection String for this Application Insights component" 64 | value = module.app-service.application_insights_connection_string 65 | sensitive = true 66 | } 67 | 68 | output "sas_url_query_string" { 69 | value = module.app-service.sas_url_query_string 70 | sensitive = true 71 | } 72 | 73 | output "app_service_virtual_network_swift_connection_id" { 74 | description = "The ID of the App Service Virtual Network integration" 75 | value = module.app-service.app_service_virtual_network_swift_connection_id 76 | } 77 | -------------------------------------------------------------------------------- /examples/simple-app-service/README.md: -------------------------------------------------------------------------------- 1 | # Azure App Service (Web Apps) Terraform Module 2 | 3 | Terraform module to create Azure App Service with optional site_config, backup, connection_string, auth_settings and Storage for mount points. 4 | 5 | ## Module Usage 6 | 7 | ```hcl 8 | # Azurerm Provider configuration 9 | provider "azurerm" { 10 | features {} 11 | } 12 | 13 | module "app-service" { 14 | source = "kumarvna/app-service/azurerm" 15 | version = "1.1.0" 16 | 17 | # By default, this module will not create a resource group. Location will be same as existing RG. 18 | # proivde a name to use an existing resource group, specify the existing resource group name, 19 | # set the argument to `create_resource_group = true` to create new resrouce group. 20 | resource_group_name = "rg-shared-westeurope-01" 21 | 22 | # App service plan setttings and supported arguments. Default name used by module 23 | # To specify custom name use `app_service_plan_name` with a valid name. 24 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 25 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 26 | service_plan = { 27 | kind = "Windows" 28 | size = "P1v2" 29 | tier = "PremiumV2" 30 | } 31 | 32 | # App Service settings and supported arguments 33 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 34 | app_service_name = "myapp-poc-project" 35 | enable_client_affinity = true 36 | 37 | # A `site_config` block to setup the application environment. 38 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 39 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 40 | site_config = { 41 | always_on = true 42 | dotnet_framework_version = "v2.0" 43 | ftps_state = "FtpsOnly" 44 | managed_pipeline_mode = "Integrated" 45 | use_32_bit_worker_process = true 46 | windows_fx_version = "DOTNETCORE|2.1" 47 | } 48 | 49 | # (Optional) A key-value pair of Application Settings 50 | app_settings = { 51 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 52 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 53 | DiagnosticServices_EXTENSION_VERSION = "~3" 54 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 55 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 56 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 57 | XDT_MicrosoftApplicationInsights_Java = "1" 58 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 59 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 60 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 61 | } 62 | 63 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 64 | # You can configure the backups to be retained up to an indefinite amount of time. 65 | # Azure storage account and container in the same subscription as the app that you want to back up. 66 | # This module creates a Storage Container to keep the all backup items. 67 | # Backup items - App configuration , File content, Database connected to your app 68 | enable_backup = true 69 | storage_account_name = "stdiagfortesting1" 70 | backup_settings = { 71 | enabled = true 72 | name = "DefaultBackup" 73 | frequency_interval = 1 74 | frequency_unit = "Day" 75 | retention_period_in_days = 90 76 | } 77 | 78 | # By default App Insight resource is created by this module. 79 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 80 | # Specifies the type of Application by setting up `application_insights_type` with valid string 81 | # Specifies the retention period in days using `retention_in_days`. Default 90. 82 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 83 | app_insights_name = "otkpocshared" 84 | 85 | # Adding TAG's to your Azure resources 86 | tags = { 87 | ProjectName = "demo-internal" 88 | Env = "dev" 89 | Owner = "user@example.com" 90 | BusinessUnit = "CORP" 91 | ServiceClass = "Gold" 92 | } 93 | } 94 | ``` 95 | 96 | ## Terraform Usage 97 | 98 | To run this example you need to execute following Terraform commands 99 | 100 | ```hcl 101 | terraform init 102 | terraform plan 103 | terraform apply 104 | ``` 105 | 106 | Run `terraform destroy` when you don't need these resources. 107 | -------------------------------------------------------------------------------- /examples/simple-app-service/main.tf: -------------------------------------------------------------------------------- 1 | # Azurerm Provider configuration 2 | provider "azurerm" { 3 | features {} 4 | } 5 | 6 | module "app-service" { 7 | source = "kumarvna/app-service/azurerm" 8 | version = "1.1.0" 9 | 10 | # By default, this module will not create a resource group. Location will be same as existing RG. 11 | # proivde a name to use an existing resource group, specify the existing resource group name, 12 | # set the argument to `create_resource_group = true` to create new resrouce group. 13 | resource_group_name = "rg-shared-westeurope-01" 14 | 15 | # App service plan setttings and supported arguments. Default name used by module 16 | # To specify custom name use `app_service_plan_name` with a valid name. 17 | # for Service Plans, see https://azure.microsoft.com/en-us/pricing/details/app-service/windows/ 18 | # App Service Plan for `Free` or `Shared` Tiers `use_32_bit_worker_process` must be set to `true`. 19 | service_plan = { 20 | kind = "Windows" 21 | size = "P1v2" 22 | tier = "PremiumV2" 23 | } 24 | 25 | # App Service settings and supported arguments 26 | # Backup, connection_string, auth_settings, Storage for mounts are optional configuration 27 | app_service_name = "myapp-poc-project" 28 | enable_client_affinity = true 29 | 30 | # A `site_config` block to setup the application environment. 31 | # Available built-in stacks (windows_fx_version) for web apps `az webapp list-runtimes` 32 | # Runtime stacks for Linux (linux_fx_version) based web apps `az webapp list-runtimes --linux` 33 | site_config = { 34 | always_on = true 35 | dotnet_framework_version = "v2.0" 36 | ftps_state = "FtpsOnly" 37 | managed_pipeline_mode = "Integrated" 38 | use_32_bit_worker_process = true 39 | windows_fx_version = "DOTNETCORE|2.1" 40 | } 41 | 42 | # (Optional) A key-value pair of Application Settings 43 | app_settings = { 44 | APPINSIGHTS_PROFILERFEATURE_VERSION = "1.0.0" 45 | APPINSIGHTS_SNAPSHOTFEATURE_VERSION = "1.0.0" 46 | DiagnosticServices_EXTENSION_VERSION = "~3" 47 | InstrumentationEngine_EXTENSION_VERSION = "disabled" 48 | SnapshotDebugger_EXTENSION_VERSION = "disabled" 49 | XDT_MicrosoftApplicationInsights_BaseExtensions = "disabled" 50 | XDT_MicrosoftApplicationInsights_Java = "1" 51 | XDT_MicrosoftApplicationInsights_Mode = "recommended" 52 | XDT_MicrosoftApplicationInsights_NodeJS = "1" 53 | XDT_MicrosoftApplicationInsights_PreemptSdk = "disabled" 54 | } 55 | 56 | # The Backup feature in Azure App Service easily create app backups manually or on a schedule. 57 | # You can configure the backups to be retained up to an indefinite amount of time. 58 | # Azure storage account and container in the same subscription as the app that you want to back up. 59 | # This module creates a Storage Container to keep the all backup items. 60 | # Backup items - App configuration , File content, Database connected to your app 61 | enable_backup = true 62 | storage_account_name = "stdiagfortesting1" 63 | backup_settings = { 64 | enabled = true 65 | name = "DefaultBackup" 66 | frequency_interval = 1 67 | frequency_unit = "Day" 68 | retention_period_in_days = 90 69 | } 70 | 71 | # By default App Insight resource is created by this module. 72 | # Specify valid resource Id to `application_insights_id` to use existing App Insight 73 | # Specifies the type of Application by setting up `application_insights_type` with valid string 74 | # Specifies the retention period in days using `retention_in_days`. Default 90. 75 | # By default the real client ip is masked in the logs, to enable set `disable_ip_masking` to `true` 76 | app_insights_name = "otkpocshared" 77 | 78 | # Adding TAG's to your Azure resources 79 | tags = { 80 | ProjectName = "demo-internal" 81 | Env = "dev" 82 | Owner = "user@example.com" 83 | BusinessUnit = "CORP" 84 | ServiceClass = "Gold" 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /examples/simple-app-service/output.tf: -------------------------------------------------------------------------------- 1 | output "app_service_plan_id" { 2 | description = "The resource ID of the App Service Plan component" 3 | value = module.app-service.app_service_plan_id 4 | } 5 | 6 | output "maximum_number_of_workers" { 7 | description = " The maximum number of workers supported with the App Service Plan's sku" 8 | value = module.app-service.maximum_number_of_workers 9 | } 10 | 11 | output "app_service_id" { 12 | description = "The resource ID of the App Service component" 13 | value = module.app-service.app_service_id 14 | } 15 | 16 | output "default_site_hostname" { 17 | description = "The Default Hostname associated with the App Service" 18 | value = module.app-service.default_site_hostname 19 | } 20 | 21 | output "outbound_ip_addresses" { 22 | description = "A comma separated list of outbound IP addresses" 23 | value = module.app-service.outbound_ip_addresses 24 | } 25 | 26 | output "outbound_ip_address_list" { 27 | description = "A list of outbound IP addresses" 28 | value = module.app-service.outbound_ip_address_list 29 | } 30 | 31 | output "possible_outbound_ip_addresses" { 32 | description = "A comma separated list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_addresses`." 33 | value = module.app-service.possible_outbound_ip_addresses 34 | } 35 | 36 | output "possible_outbound_ip_address_list" { 37 | description = "A list of outbound IP addresses - not all of which are necessarily in use. Superset of outbound_ip_address_list." 38 | value = module.app-service.possible_outbound_ip_address_list 39 | } 40 | 41 | output "identity" { 42 | description = "An identity block, which contains the Managed Service Identity information for this App Service." 43 | value = module.app-service.identity 44 | } 45 | 46 | output "application_insights_id" { 47 | description = "The ID of the Application Insights component" 48 | value = module.app-service.application_insights_id 49 | } 50 | 51 | output "application_insights_app_id" { 52 | description = "The App ID associated with this Application Insights component" 53 | value = module.app-service.application_insights_app_id 54 | } 55 | 56 | output "application_insights_instrumentation_key" { 57 | description = "The Instrumentation Key for this Application Insights component" 58 | value = module.app-service.application_insights_instrumentation_key 59 | sensitive = true 60 | } 61 | 62 | output "application_insights_connection_string" { 63 | description = "The Connection String for this Application Insights component" 64 | value = module.app-service.application_insights_connection_string 65 | sensitive = true 66 | } 67 | 68 | output "sas_url_query_string" { 69 | value = module.app-service.sas_url_query_string 70 | sensitive = true 71 | } 72 | 73 | output "app_service_virtual_network_swift_connection_id" { 74 | description = "The ID of the App Service Virtual Network integration" 75 | value = module.app-service.app_service_virtual_network_swift_connection_id 76 | } 77 | -------------------------------------------------------------------------------- /graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kumarvna/terraform-azurerm-app-service/e17219e9e3fa0a34c2b9a006b18c676fb2c355db/graph.png -------------------------------------------------------------------------------- /main.tf: -------------------------------------------------------------------------------- 1 | #--------------------------------- 2 | # Local declarations 3 | #--------------------------------- 4 | locals { 5 | resource_group_name = element(coalescelist(data.azurerm_resource_group.rgrp.*.name, azurerm_resource_group.rg.*.name, [""]), 0) 6 | location = element(coalescelist(data.azurerm_resource_group.rgrp.*.location, azurerm_resource_group.rg.*.location, [""]), 0) 7 | 8 | # Default configuration for Site config block 9 | default_site_config = { 10 | always_on = "true" 11 | } 12 | 13 | # Enabling the App Insights on app service - default configuration for agent 14 | app_insights = try(data.azurerm_application_insights.main.0, try(azurerm_application_insights.main.0, {})) 15 | 16 | default_app_settings = var.application_insights_enabled ? { 17 | APPLICATION_INSIGHTS_IKEY = try(local.app_insights.instrumentation_key, "") 18 | APPINSIGHTS_INSTRUMENTATIONKEY = try(local.app_insights.instrumentation_key, "") 19 | APPLICATIONINSIGHTS_CONNECTION_STRING = try(local.app_insights.connection_string, "") 20 | ApplicationInsightsAgent_EXTENSION_VERSION = "~2" 21 | } : {} 22 | 23 | # App service IP Address, Subnet_ids and Service_Tag restrictions 24 | ip_address = [for ip_address in var.ips_allowed : { 25 | name = "ip_restriction_cidr_${join("", [1, index(var.ips_allowed, ip_address)])}" 26 | ip_address = ip_address 27 | virtual_network_subnet_id = null 28 | service_tag = null 29 | subnet_id = null 30 | priority = join("", [1, index(var.ips_allowed, ip_address)]) 31 | action = "Allow" 32 | }] 33 | 34 | subnets = [for subnet in var.subnet_ids_allowed : { 35 | name = "ip_restriction_subnet_${join("", [1, index(var.subnet_ids_allowed, subnet)])}" 36 | ip_address = null 37 | virtual_network_subnet_id = subnet 38 | service_tag = null 39 | subnet_id = subnet 40 | priority = join("", [1, index(var.subnet_ids_allowed, subnet)]) 41 | action = "Allow" 42 | }] 43 | 44 | service_tags = [for service_tag in var.service_tags_allowed : { 45 | name = "service_tag_restriction_${join("", [1, index(var.service_tags_allowed, service_tag)])}" 46 | ip_address = null 47 | virtual_network_subnet_id = null 48 | service_tag = service_tag 49 | subnet_id = null 50 | priority = join("", [1, index(var.service_tags_allowed, service_tag)]) 51 | action = "Allow" 52 | }] 53 | 54 | # App service SCM IP Address, SCM Subnet_ids andSCM Service_Tag restrictions 55 | scm_ip_address = [for ip_address in var.scm_ips_allowed : { 56 | name = "scm_ip_restriction_cidr_${join("", [1, index(var.scm_ips_allowed, ip_address)])}" 57 | ip_address = ip_address 58 | virtual_network_subnet_id = null 59 | service_tag = null 60 | subnet_id = null 61 | priority = join("", [1, index(var.scm_ips_allowed, ip_address)]) 62 | action = "Allow" 63 | }] 64 | 65 | scm_subnets = [for subnet in var.scm_subnet_ids_allowed : { 66 | name = "scm_ip_restriction_subnet_${join("", [1, index(var.scm_subnet_ids_allowed, subnet)])}" 67 | ip_address = null 68 | virtual_network_subnet_id = subnet 69 | service_tag = null 70 | subnet_id = subnet 71 | priority = join("", [1, index(var.scm_subnet_ids_allowed, subnet)]) 72 | action = "Allow" 73 | }] 74 | 75 | scm_service_tags = [for service_tag in var.scm_service_tags_allowed : { 76 | name = "scm_service_tag_restriction_${join("", [1, index(var.scm_service_tags_allowed, service_tag)])}" 77 | ip_address = null 78 | virtual_network_subnet_id = null 79 | service_tag = service_tag 80 | subnet_id = null 81 | priority = join("", [1, index(var.scm_service_tags_allowed, service_tag)]) 82 | action = "Allow" 83 | }] 84 | 85 | } 86 | 87 | #--------------------------------------------------------- 88 | # Resource Group Creation or selection - Default is "true" 89 | #---------------------------------------------------------- 90 | data "azurerm_resource_group" "rgrp" { 91 | count = var.create_resource_group ? 0 : 1 92 | name = var.resource_group_name 93 | } 94 | 95 | data "azurerm_client_config" "main" {} 96 | 97 | resource "azurerm_resource_group" "rg" { 98 | count = var.create_resource_group ? 1 : 0 99 | name = lower(var.resource_group_name) 100 | location = var.location 101 | tags = merge({ "ResourceName" = format("%s", var.resource_group_name) }, var.tags, ) 102 | } 103 | 104 | #--------------------------------------------------------- 105 | # Generating Storage SAS URL - Default is "false" 106 | #---------------------------------------------------------- 107 | data "azurerm_storage_account" "storeacc" { 108 | count = var.enable_backup ? 1 : 0 109 | name = var.storage_account_name 110 | resource_group_name = local.resource_group_name 111 | } 112 | 113 | resource "azurerm_storage_container" "storcont" { 114 | count = var.enable_backup ? 1 : 0 115 | name = var.storage_container_name == null ? "appservice-backup" : var.storage_container_name 116 | storage_account_name = data.azurerm_storage_account.storeacc.0.name 117 | container_access_type = "private" 118 | } 119 | 120 | resource "time_rotating" "main" { 121 | count = var.enable_backup ? 1 : 0 122 | rotation_rfc3339 = var.password_end_date 123 | rotation_years = var.password_rotation_in_years 124 | 125 | triggers = { 126 | end_date = var.password_end_date 127 | years = var.password_rotation_in_years 128 | } 129 | } 130 | 131 | data "azurerm_storage_account_blob_container_sas" "main" { 132 | count = var.enable_backup ? 1 : 0 133 | connection_string = data.azurerm_storage_account.storeacc.0.primary_connection_string 134 | container_name = azurerm_storage_container.storcont.0.name 135 | https_only = true 136 | 137 | start = timestamp() 138 | expiry = time_rotating.main.0.rotation_rfc3339 139 | 140 | permissions { 141 | read = true 142 | add = true 143 | create = true 144 | write = true 145 | delete = true 146 | list = true 147 | } 148 | 149 | cache_control = "max-age=5" 150 | content_disposition = "inline" 151 | content_encoding = "deflate" 152 | content_language = "en-US" 153 | content_type = "application/json" 154 | } 155 | 156 | #--------------------------------------------------------- 157 | # App Service Plan definition - Default is "true" 158 | #---------------------------------------------------------- 159 | resource "azurerm_app_service_plan" "main" { 160 | name = var.app_service_plan_name == "" ? format("plan-%s", lower(replace(var.app_service_name, "/[[:^alnum:]]/", ""))) : var.app_service_plan_name 161 | resource_group_name = local.resource_group_name 162 | location = local.location 163 | kind = var.service_plan.kind 164 | reserved = var.service_plan.kind == "Linux" ? true : false 165 | is_xenon = var.service_plan.kind == "xenon" ? true : false 166 | per_site_scaling = var.service_plan.per_site_scaling 167 | tags = merge({ "ResourceName" = format("%s", var.app_service_plan_name) }, var.tags, ) 168 | 169 | sku { 170 | tier = var.service_plan.tier 171 | size = var.service_plan.size 172 | capacity = var.service_plan.capacity 173 | } 174 | } 175 | 176 | #--------------------------------------------------------- 177 | # App Service Definitions - Default is "true" 178 | #---------------------------------------------------------- 179 | resource "azurerm_app_service" "main" { 180 | name = lower(format("app-%s", var.app_service_name)) 181 | resource_group_name = local.resource_group_name 182 | location = local.location 183 | app_service_plan_id = azurerm_app_service_plan.main.id 184 | client_affinity_enabled = var.enable_client_affinity 185 | https_only = var.enable_https 186 | client_cert_enabled = var.enable_client_certificate 187 | tags = merge({ "ResourceName" = lower(format("app-%s", var.app_service_name)) }, var.tags, ) 188 | app_settings = merge(local.default_app_settings, var.app_settings) 189 | 190 | dynamic "site_config" { 191 | for_each = [merge(local.default_site_config, var.site_config)] 192 | 193 | content { 194 | always_on = lookup(site_config.value, "always_on", false) 195 | app_command_line = lookup(site_config.value, "app_command_line", null) 196 | default_documents = lookup(site_config.value, "default_documents", null) 197 | dotnet_framework_version = lookup(site_config.value, "dotnet_framework_version", "v2.0") 198 | ftps_state = lookup(site_config.value, "ftps_state", "FtpsOnly") 199 | health_check_path = lookup(site_config.value, "health_check_path", null) 200 | number_of_workers = var.service_plan.per_site_scaling == true ? lookup(site_config.value, "number_of_workers") : null 201 | http2_enabled = lookup(site_config.value, "http2_enabled", false) 202 | ip_restriction = concat(local.subnets, local.ip_address, local.service_tags) 203 | scm_use_main_ip_restriction = var.scm_ips_allowed != [] || var.scm_subnet_ids_allowed != null ? false : true 204 | scm_ip_restriction = concat(local.scm_subnets, local.scm_ip_address, local.service_tags) 205 | java_container = lookup(site_config.value, "java_container", null) 206 | java_container_version = lookup(site_config.value, "java_container_version", null) 207 | java_version = lookup(site_config.value, "java_version", null) 208 | local_mysql_enabled = lookup(site_config.value, "local_mysql_enabled", null) 209 | linux_fx_version = lookup(site_config.value, "linux_fx_version", null) 210 | windows_fx_version = lookup(site_config.value, "windows_fx_version", null) 211 | managed_pipeline_mode = lookup(site_config.value, "managed_pipeline_mode", "Integrated") 212 | min_tls_version = lookup(site_config.value, "min_tls_version", "1.2") 213 | php_version = lookup(site_config.value, "php_version", null) 214 | python_version = lookup(site_config.value, "python_version", null) 215 | remote_debugging_enabled = lookup(site_config.value, "remote_debugging_enabled", null) 216 | remote_debugging_version = lookup(site_config.value, "remote_debugging_version", null) 217 | scm_type = lookup(site_config.value, "scm_type", null) 218 | use_32_bit_worker_process = lookup(site_config.value, "use_32_bit_worker_process", true) 219 | websockets_enabled = lookup(site_config.value, "websockets_enabled", null) 220 | 221 | 222 | dynamic "cors" { 223 | for_each = lookup(site_config.value, "cors", []) 224 | content { 225 | allowed_origins = cors.value.allowed_origins 226 | support_credentials = lookup(cors.value, "support_credentials", null) 227 | } 228 | } 229 | } 230 | } 231 | 232 | auth_settings { 233 | enabled = var.enable_auth_settings 234 | default_provider = var.default_auth_provider 235 | allowed_external_redirect_urls = [] 236 | issuer = format("https://sts.windows.net/%s/", data.azurerm_client_config.main.tenant_id) 237 | unauthenticated_client_action = var.unauthenticated_client_action 238 | token_store_enabled = var.token_store_enabled 239 | 240 | dynamic "active_directory" { 241 | for_each = var.active_directory_auth_setttings 242 | content { 243 | client_id = lookup(active_directory_auth_setttings.value, "client_id", null) 244 | client_secret = lookup(active_directory_auth_setttings.value, "client_secret", null) 245 | allowed_audiences = concat(formatlist("https://%s", [format("%s.azurewebsites.net", var.app_service_name)]), []) 246 | } 247 | } 248 | } 249 | 250 | dynamic "backup" { 251 | for_each = var.enable_backup ? [{}] : [] 252 | content { 253 | name = coalesce(var.backup_settings.name, "DefaultBackup") 254 | enabled = var.backup_settings.enabled 255 | storage_account_url = format("https://${data.azurerm_storage_account.storeacc.0.name}.blob.core.windows.net/${azurerm_storage_container.storcont.0.name}%s", data.azurerm_storage_account_blob_container_sas.main.0.sas) 256 | schedule { 257 | frequency_interval = var.backup_settings.frequency_interval 258 | frequency_unit = var.backup_settings.frequency_unit 259 | retention_period_in_days = var.backup_settings.retention_period_in_days 260 | start_time = var.backup_settings.start_time 261 | } 262 | } 263 | } 264 | 265 | dynamic "connection_string" { 266 | for_each = var.connection_strings 267 | content { 268 | name = lookup(connection_string.value, "name", null) 269 | type = lookup(connection_string.value, "type", null) 270 | value = lookup(connection_string.value, "value", null) 271 | } 272 | } 273 | 274 | identity { 275 | type = var.identity_ids != null ? "SystemAssigned, UserAssigned" : "SystemAssigned" 276 | identity_ids = var.identity_ids 277 | } 278 | 279 | dynamic "storage_account" { 280 | for_each = var.storage_mounts 281 | content { 282 | name = lookup(storage_account.value, "name") 283 | type = lookup(storage_account.value, "type", "AzureFiles") 284 | account_name = lookup(storage_account.value, "account_name", null) 285 | share_name = lookup(storage_account.value, "share_name", null) 286 | access_key = lookup(storage_account.value, "access_key", null) 287 | mount_path = lookup(storage_account.value, "mount_path", null) 288 | } 289 | } 290 | 291 | lifecycle { 292 | ignore_changes = [ 293 | tags, 294 | site_config, 295 | backup, 296 | auth_settings, 297 | storage_account, 298 | identity, 299 | connection_string, 300 | ] 301 | } 302 | } 303 | 304 | #--------------------------------------------------------- 305 | # Custom domain and Certificate config - Default is "true" 306 | #---------------------------------------------------------- 307 | resource "azurerm_app_service_certificate" "main" { 308 | for_each = var.custom_domains != null ? { for k, v in var.custom_domains : k => v if v != null } : {} 309 | name = each.key 310 | resource_group_name = local.resource_group_name 311 | location = local.location 312 | pfx_blob = contains(keys(each.value), "certificate_file") ? filebase64(each.value.certificate_file) : null 313 | password = contains(keys(each.value), "certificate_file") ? each.value.certificate_password : null 314 | key_vault_secret_id = contains(keys(each.value), "certificate_keyvault_certificate_id") ? each.value.certificate_keyvault_certificate_id : null 315 | } 316 | 317 | resource "azurerm_app_service_custom_hostname_binding" "cust-host-bind" { 318 | for_each = var.custom_domains != null ? var.custom_domains : {} 319 | hostname = each.key 320 | app_service_name = azurerm_app_service.main.name 321 | resource_group_name = local.resource_group_name 322 | ssl_state = lookup(azurerm_app_service_certificate.main, each.key, false) != false ? "SniEnabled" : null 323 | thumbprint = lookup(azurerm_app_service_certificate.main, each.key, false) != false ? azurerm_app_service_certificate.main[each.key].thumbprint : null 324 | } 325 | 326 | 327 | #--------------------------------------------------------- 328 | # Application Insights resoruces - Default is "false" 329 | #---------------------------------------------------------- 330 | data "azurerm_application_insights" "main" { 331 | count = var.application_insights_enabled && var.application_insights_id != null ? 1 : 0 332 | name = split("/", var.application_insights_id)[8] 333 | resource_group_name = split("/", var.application_insights_id)[4] 334 | } 335 | 336 | resource "azurerm_application_insights" "main" { 337 | count = var.application_insights_enabled && var.application_insights_id == null ? 1 : 0 338 | name = lower(format("appi-%s", var.app_insights_name)) 339 | location = local.location 340 | resource_group_name = local.resource_group_name 341 | application_type = var.application_insights_type 342 | retention_in_days = var.retention_in_days 343 | disable_ip_masking = var.disable_ip_masking 344 | tags = merge({ "ResourceName" = "${var.app_insights_name}" }, var.tags, ) 345 | } 346 | 347 | #------------------------------------------------------------- 348 | # App Service Virtual Network Association - Default is "false" 349 | #------------------------------------------------------------- 350 | resource "azurerm_app_service_virtual_network_swift_connection" "main" { 351 | count = var.enable_vnet_integration == true ? 1 : 0 352 | app_service_id = azurerm_app_service.main.id 353 | subnet_id = var.subnet_id 354 | } 355 | -------------------------------------------------------------------------------- /output.tf: -------------------------------------------------------------------------------- 1 | output "app_service_plan_id" { 2 | description = "The resource ID of the App Service Plan component" 3 | value = azurerm_app_service_plan.main.id 4 | } 5 | 6 | output "maximum_number_of_workers" { 7 | description = " The maximum number of workers supported with the App Service Plan's sku" 8 | value = azurerm_app_service_plan.main.maximum_number_of_workers 9 | } 10 | 11 | output "app_service_id" { 12 | description = "The resource ID of the App Service component" 13 | value = azurerm_app_service.main.id 14 | } 15 | 16 | output "default_site_hostname" { 17 | description = "The Default Hostname associated with the App Service" 18 | value = format("https://%s/", azurerm_app_service.main.default_site_hostname) 19 | } 20 | 21 | output "outbound_ip_addresses" { 22 | description = "A comma separated list of outbound IP addresses" 23 | value = azurerm_app_service.main.outbound_ip_addresses 24 | } 25 | 26 | output "outbound_ip_address_list" { 27 | description = "A list of outbound IP addresses" 28 | value = azurerm_app_service.main.outbound_ip_address_list 29 | } 30 | 31 | output "possible_outbound_ip_addresses" { 32 | description = "A comma separated list of outbound IP addresses - not all of which are necessarily in use. Superset of `outbound_ip_addresses`." 33 | value = azurerm_app_service.main.possible_outbound_ip_addresses 34 | } 35 | 36 | output "possible_outbound_ip_address_list" { 37 | description = "A list of outbound IP addresses - not all of which are necessarily in use. Superset of outbound_ip_address_list." 38 | value = azurerm_app_service.main.possible_outbound_ip_address_list 39 | } 40 | 41 | output "identity" { 42 | description = "An identity block, which contains the Managed Service Identity information for this App Service." 43 | value = azurerm_app_service.main.identity 44 | } 45 | 46 | output "application_insights_id" { 47 | description = "The ID of the Application Insights component" 48 | value = var.application_insights_enabled ? azurerm_application_insights.main.*.id : null 49 | } 50 | 51 | output "application_insights_app_id" { 52 | description = "The App ID associated with this Application Insights component" 53 | value = var.application_insights_enabled ? azurerm_application_insights.main.*.app_id : null 54 | } 55 | 56 | output "application_insights_instrumentation_key" { 57 | description = "The Instrumentation Key for this Application Insights component" 58 | value = var.application_insights_enabled ? azurerm_application_insights.main.*.instrumentation_key : null 59 | sensitive = true 60 | } 61 | 62 | output "application_insights_connection_string" { 63 | description = "The Connection String for this Application Insights component" 64 | value = var.application_insights_enabled ? azurerm_application_insights.main.*.connection_string : null 65 | sensitive = true 66 | } 67 | 68 | output "sas_url_query_string" { 69 | description = "The computed Blob Container Shared Access Signature (SAS)" 70 | value = var.enable_backup ? format("https://${data.azurerm_storage_account.storeacc.0.name}.blob.core.windows.net/${azurerm_storage_container.storcont.0.name}%s", data.azurerm_storage_account_blob_container_sas.main.0.sas) : null 71 | sensitive = true 72 | } 73 | 74 | output "app_service_virtual_network_swift_connection_id" { 75 | description = "The ID of the App Service Virtual Network integration" 76 | value = var.enable_vnet_integration ? azurerm_app_service_virtual_network_swift_connection.main.*.id : null 77 | } 78 | -------------------------------------------------------------------------------- /variables.tf: -------------------------------------------------------------------------------- 1 | variable "create_resource_group" { 2 | description = "Whether to create resource group and use it for all networking resources" 3 | default = false 4 | } 5 | 6 | variable "resource_group_name" { 7 | description = "A container that holds related resources for an Azure solution" 8 | default = "" 9 | } 10 | 11 | variable "location" { 12 | description = "The location/region to keep all your network resources. To get the list of all locations with table format from azure cli, run 'az account list-locations -o table'" 13 | default = "" 14 | } 15 | 16 | variable "subnet_id" { 17 | description = "The resource id of the subnet for vnet association" 18 | default = null 19 | } 20 | 21 | variable "app_service_plan_name" { 22 | description = "Specifies the name of the App Service Plan component" 23 | default = "" 24 | } 25 | 26 | variable "service_plan" { 27 | description = "Definition of the dedicated plan to use" 28 | type = object({ 29 | kind = string 30 | size = string 31 | capacity = optional(number) 32 | tier = string 33 | per_site_scaling = optional(bool) 34 | }) 35 | } 36 | 37 | 38 | variable "app_service_name" { 39 | description = "Specifies the name of the App Service." 40 | default = "" 41 | } 42 | 43 | variable "app_settings" { 44 | description = "A key-value pair of App Settings." 45 | type = map(string) 46 | default = {} 47 | } 48 | 49 | variable "site_config" { 50 | description = "Site configuration for Application Service" 51 | type = any 52 | default = {} 53 | } 54 | 55 | variable "ips_allowed" { 56 | description = "IPs restriction for App Service to allow specific IP addresses or ranges" 57 | type = list(string) 58 | default = [] 59 | } 60 | 61 | variable "subnet_ids_allowed" { 62 | description = "Allow Specific Subnets for App Service" 63 | type = list(string) 64 | default = [] 65 | } 66 | 67 | variable "service_tags_allowed" { 68 | description = "Restrict Service Tags for App Service" 69 | type = list(string) 70 | default = [] 71 | } 72 | 73 | variable "scm_ips_allowed" { 74 | description = "SCM IP restrictions for App service" 75 | type = list(string) 76 | default = [] 77 | } 78 | 79 | variable "scm_subnet_ids_allowed" { 80 | description = "Restrict SCM Subnets for App Service" 81 | type = list(string) 82 | default = [] 83 | } 84 | 85 | variable "scm_service_tags_allowed" { 86 | description = "Restrict SCM Service Tags for App Service" 87 | type = list(string) 88 | default = [] 89 | } 90 | 91 | variable "enable_auth_settings" { 92 | description = "Specifies the Authenication enabled or not" 93 | default = false 94 | } 95 | 96 | variable "default_auth_provider" { 97 | description = "The default provider to use when multiple providers have been set up. Possible values are `AzureActiveDirectory`, `Facebook`, `Google`, `MicrosoftAccount` and `Twitter`" 98 | default = "AzureActiveDirectory" 99 | } 100 | 101 | variable "unauthenticated_client_action" { 102 | description = "The action to take when an unauthenticated client attempts to access the app. Possible values are `AllowAnonymous` and `RedirectToLoginPage`" 103 | default = "RedirectToLoginPage" 104 | } 105 | 106 | variable "token_store_enabled" { 107 | description = "If enabled the module will durably store platform-specific security tokens that are obtained during login flows" 108 | default = false 109 | } 110 | 111 | variable "active_directory_auth_setttings" { 112 | description = "Acitve directory authentication provider settings for app service" 113 | type = any 114 | default = {} 115 | } 116 | 117 | variable "enable_client_affinity" { 118 | description = "Should the App Service send session affinity cookies, which route client requests in the same session to the same instance?" 119 | default = false 120 | } 121 | 122 | variable "enable_client_certificate" { 123 | description = "Does the App Service require client certificates for incoming requests" 124 | default = false 125 | } 126 | 127 | variable "enable_https" { 128 | description = "Can the App Service only be accessed via HTTPS?" 129 | default = false 130 | } 131 | 132 | variable "enable_backup" { 133 | description = "bool to to setup backup for app service " 134 | default = false 135 | } 136 | 137 | variable "storage_container_name" { 138 | description = "The name of the storage container to keep backups" 139 | default = null 140 | } 141 | 142 | variable "backup_settings" { 143 | description = "Backup settings for App service" 144 | type = object({ 145 | name = string 146 | enabled = bool 147 | storage_account_url = optional(string) 148 | frequency_interval = number 149 | frequency_unit = optional(string) 150 | retention_period_in_days = optional(number) 151 | start_time = optional(string) 152 | }) 153 | default = { 154 | enabled = false 155 | name = "DefaultBackup" 156 | frequency_interval = 1 157 | frequency_unit = "Day" 158 | retention_period_in_days = 1 159 | } 160 | } 161 | 162 | variable "connection_strings" { 163 | description = "Connection strings for App Service" 164 | type = list(map(string)) 165 | default = [] 166 | } 167 | 168 | variable "identity_ids" { 169 | description = "Specifies a list of user managed identity ids to be assigned" 170 | default = null 171 | } 172 | 173 | variable "storage_mounts" { 174 | description = "Storage account mount points for App Service" 175 | type = list(map(string)) 176 | default = [] 177 | } 178 | 179 | variable "custom_domains" { 180 | description = "Custom domains with SSL binding and SSL certificates for the App Service. Getting the SSL certificate from an Azure Keyvault Certificate Secret or a file is possible." 181 | type = map(map(string)) 182 | default = null 183 | } 184 | 185 | variable "storage_account_name" { 186 | description = "The name of the azure storage account" 187 | default = "" 188 | } 189 | 190 | variable "password_end_date" { 191 | description = "The relative duration or RFC3339 rotation timestamp after which the password expire" 192 | default = null 193 | } 194 | 195 | variable "password_rotation_in_years" { 196 | description = "Number of years to add to the base timestamp to configure the password rotation timestamp. Conflicts with password_end_date and either one is specified and not the both" 197 | default = 2 198 | } 199 | 200 | variable "application_insights_enabled" { 201 | description = "Specify the Application Insights use for this App Service" 202 | default = true 203 | } 204 | 205 | variable "application_insights_id" { 206 | description = "Resource ID of the existing Application Insights" 207 | default = null 208 | } 209 | 210 | variable "app_insights_name" { 211 | description = "The Name of the application insights" 212 | default = "" 213 | } 214 | 215 | variable "application_insights_type" { 216 | description = "Specifies the type of Application Insights to create. Valid values are `ios` for iOS, `java` for Java web, `MobileCenter` for App Center, `Node.JS` for Node.js, `other` for General, `phone` for Windows Phone, `store` for Windows Store and `web` for ASP.NET." 217 | default = "web" 218 | } 219 | 220 | variable "retention_in_days" { 221 | description = "Specifies the retention period in days. Possible values are `30`, `60`, `90`, `120`, `180`, `270`, `365`, `550` or `730`" 222 | default = 90 223 | } 224 | 225 | variable "disable_ip_masking" { 226 | description = "By default the real client ip is masked as `0.0.0.0` in the logs. Use this argument to disable masking and log the real client ip" 227 | default = false 228 | } 229 | 230 | variable "enable_vnet_integration" { 231 | description = "Manages an App Service Virtual Network Association" 232 | default = false 233 | } 234 | 235 | variable "tags" { 236 | description = "A map of tags to add to all resources" 237 | type = map(string) 238 | default = {} 239 | } 240 | -------------------------------------------------------------------------------- /versions.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | experiments = [module_variable_optional_attrs] 3 | required_providers { 4 | azurerm = { 5 | source = "hashicorp/azurerm" 6 | version = ">= 2.59.0" 7 | } 8 | time = { 9 | source = "hashicorp/time" 10 | version = ">= 0.7.1" 11 | } 12 | } 13 | required_version = ">= 0.13" 14 | } 15 | --------------------------------------------------------------------------------