Terraform module to create Azure App Insights resource on AZURE.
We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.
This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.
We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.
This module has a few dependencies:
- Terraform 1.x.x
- Go
- github.com/stretchr/testify/assert
- github.com/gruntwork-io/terratest/modules/terraform
IMPORTANT: Since the master
branch used in source
varies based on new modifications, we suggest that you use the release versions here.
Here are some examples of how you can use this module in your inventory structure:
# Basic
module "app-insights" {
source = "terraform/app-insights/azure"
version = "1.0.0"
name = "app"
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
# workspace_id = module.log-analytics.workspace_id
application_type = "web"
##web test
web_test_enable = true
kind = "ping"
frequency = 300
timeout = 60
list_of_test_urls = ["https://www.google.com", ]
web_test_name = ["google", ]
#### enable diagnostic setting
log_analytics_workspace_id = module.log-analytics.workspace_id
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
Metric_enable | Is this Diagnostic Metric enabled? Defaults to true. | bool |
true |
no |
application_insights_config | 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. Please note these values are case sensitive; unmatched values are treated as ASP.NET by Azure. Changing this forces a new resource to be created. | string |
"web" |
no |
application_type | Required) 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. Please note these values are case sensitive; unmatched values are treated as ASP.NET by Azure. Changing this forces a new resource to be created. | string |
"web" |
no |
attributes | Additional attributes (e.g. 1 ). |
list(string) |
[] |
no |
business_unit | Top-level division of your company that owns the subscription or workload that the resource belongs to. In smaller organizations, this tag might represent a single corporate or shared top-level organizational element. | string |
"Corp" |
no |
category | The name of a Diagnostic Log Category Group for this Resource. | string |
null |
no |
daily_data_cap_in_gb | Specifies the Application Insights component daily data volume cap in GB. | number |
30 |
no |
daily_data_cap_notifications_disabled | Optional) Specifies if a notification email will be send when the daily data volume cap is met. | bool |
false |
no |
description | Purpose/user defined descriptive test for this WebTest. | string |
"" |
no |
diagnostic_log_days | The number of days for which this Retention Policy should apply. | number |
"90" |
no |
diagnostic_setting_enable | n/a | bool |
true |
no |
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. | bool |
false |
no |
enabled | Set to false to prevent the module from creating any resources. | bool |
true |
no |
environment | Environment (e.g. prod , dev , staging ). |
string |
"" |
no |
eventhub_authorization_rule_id | Specifies the ID of an Event Hub Namespace Authorization Rule used to send Diagnostics Data. | string |
null |
no |
eventhub_name | Specifies the name of the Event Hub where Diagnostics Data should be sent. | string |
null |
no |
extra_tags | Additional tags (e.g. map(BusinessUnit ,XYZ ). |
map(string) |
{} |
no |
footer | n/a | string |
"</Items></WebTest>" |
no |
force_customer_storage_for_profiler | Should the Application Insights component force users to create their own storage account for profiling? Defaults to false. | bool |
false |
no |
frequency | Interval in seconds between test runs for this WebTest. Default is 300. | number |
300 |
no |
geo_locations | Specifies a list of where to physically run the tests from to give global coverage for accessibility of your application. | list(string) |
[ |
no |
header | n/a | string |
"<WebTest Name=\"WebTest1\" Id=\"%s\" Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"0\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"%s\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\"><Items>" |
no |
internet_ingestion_enabled | (Optional) Should the Application Insights component support ingestion over the Public Internet? Defaults to true. | bool |
false |
no |
internet_query_enabled | (Optional) Should the Application Insights component support querying over the Public Internet? Defaults to true. | bool |
false |
no |
kind | n/a | string |
"" |
no |
label_order | Label order, e.g. sequence of application name and environment name ,environment ,'attribute' [webserver ,qa ,devops ,public ,] . |
list(any) |
[ |
no |
list_of_test_urls | List of URLs to put in the availability tests. Example: ["https://test1.example.com", "https://test2.example.com/app"] | list(string) |
[] |
no |
local_authentication_disabled | (Optional) Disable Non-Azure AD based Auth. Defaults to false. | bool |
false |
no |
location | (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. | string |
"" |
no |
log_analytics_destination_type | Possible values are AzureDiagnostics and Dedicated, default to AzureDiagnostics. When set to Dedicated, logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table. | string |
"AzureDiagnostics" |
no |
log_analytics_workspace_id | n/a | string |
null |
no |
log_enabled | Is this Diagnostic Log enabled? Defaults to true. | string |
true |
no |
managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string |
"[email protected]" |
no |
monitored_enabled | n/a | bool |
true |
no |
name | Name (e.g. app or cluster ). |
string |
"" |
no |
parse_deps | Retrieve resources that are linked to by the test URL as part of the web test. Valid values are "True" or "False". Default value is "False". | string |
"false" |
no |
repository | Terraform current module repo | string |
"" |
no |
resource_group_name | The name of the resource group in which to create the network security group. | string |
n/a | yes |
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. | number |
90 |
no |
retention_policy_enabled | Is this Retention Policy enabled? | bool |
false |
no |
retry_enabled | Allow for retries should this WebTest fail. | bool |
true |
no |
sampling_percentage | Specifies the percentage of the data produced by the monitored application that is sampled for Application Insights telemetry. | number |
100 |
no |
storage_account_id | The ID of the Storage Account where logs should be sent. | string |
null |
no |
tags | A mapping of tags to assign to the resource. | map(string) |
{} |
no |
test_body | WebTest XML Request body. If overridden, make sure to retain all the string format() parameters needed by the local variable calculations. | string |
"<Request Method=\"GET\" Guid=\"%s\" Version=\"1.1\" Url=\"%s\" ThinkTime=\"0\" Timeout=\"300\" ParseDependentRequests=\"PARSEDEPS\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"True\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"200\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" />" |
no |
timeout | Seconds until this WebTest will timeout and fail. Default is 30. | number |
30 |
no |
web_test_enable | n/a | bool |
false |
no |
web_test_name | n/a | list(string) |
[] |
no |
workspace_id | (Optional) Specifies the id of a log analytics workspace resource. Changing this forces a new resource to be created. | string |
null |
no |
Name | Description |
---|---|
app_insights_app_id | The App ID associated with this Application Insights component. |
app_insights_id | The ID of the Application Insights component. |
connection_string | The Connection String for this Application Insights component. (Sensitive) |
instrumentation_key | The Instrumentation Key for this Application Insights component. (Sensitive) |
In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.
You need to run the following command in the testing folder:
go test -run Test
If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].
If you have found it worth your time, go ahead and give us a ★ on our GitHub!
At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.
We are The Cloud Experts!
We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.