diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 458c9c2..7332bc0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @lukiffer +* @lukiffer @deepanshumarwah diff --git a/.gitignore b/.gitignore index 70b4599..7fa7ea2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,22 @@ -# Terraform -.terraform -terraform.tfvars -*.tfstate -*.tfstate.backup - -# OS X -.history -.DS_Store - -# IntelliJ -.idea_modules -*.iml -*.iws -*.ipr -.idea/ -build/ -*/build/ -out/ -node_modules -*.keystore -*.lic +# Terraform +.terraform +terraform.tfvars +*.tfstate +*.tfstate.backup + +# OS X +.history +.DS_Store + +# IntelliJ +.idea_modules +*.iml +*.iws +*.ipr +.idea/ +build/ +*/build/ +out/ +node_modules +*.keystore +*.lic diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f39423a..5a11e2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,22 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 - hooks: - - id: check-added-large-files - - id: check-byte-order-marker - - id: check-case-conflict - - id: check-executables-have-shebangs - - id: check-json - - id: check-merge-conflict - - id: check-symlinks - - id: check-yaml - - id: detect-private-key - - id: end-of-file-fixer - - id: mixed-line-ending - args: [--fix=no] - - id: trailing-whitespace - - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.21.0 - hooks: - - id: terraform_fmt - - id: terraform_validate +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.4.0 + hooks: + - id: check-added-large-files + - id: check-byte-order-marker + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + args: [--fix=no] + - id: trailing-whitespace + - repo: git://github.com/antonbabenko/pre-commit-terraform + rev: v1.21.0 + hooks: + - id: terraform_fmt + - id: terraform_validate diff --git a/.releaserc.json b/.releaserc.json index f36dda1..3764018 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -1,3 +1,3 @@ -{ - "extends": "@quantum-sec/semantic-release-config/base" -} +{ + "extends": "@quantum-sec/semantic-release-config/base" +} diff --git a/.terraform-version b/.terraform-version index a740c89..2fa6558 100644 --- a/.terraform-version +++ b/.terraform-version @@ -1 +1 @@ -latest:^0.12 +latest:^0.12 diff --git a/LICENSE b/LICENSE index cee4363..b28ed81 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1 @@ -© 2020 Quantum Security Pte. Ltd. All Rights Reserved. +© 2020 Quantum Security Pte. Ltd. All Rights Reserved. diff --git a/README.md b/README.md index 4267661..18d9817 100644 --- a/README.md +++ b/README.md @@ -1,38 +1,38 @@ -# package- log-analytics - -This repository contains modules for deploying and managing Azure Log Analytics Workspace that are shared across other modules or instances. - -## Using a Terraform Module - -To use a module in your Terraform templates, create a `module` resource and set its `source` field to the Git URL of -this repo. You should also set the `ref` parameter so you're fixed to a specific version of this repo, as the `master` -branch may have backwards incompatible changes (see [module sources](https://www.terraform.io/docs/modules/sources.html)). - -For example, to use `1.0.0` of the `azure-function-app` module, you would add the following: - -```hcl -module "function_app" { - source = "git::git@github.com:quantum-sec/package-azure-functions.git//modules/azure-function-app?ref=1.0.0" - - // set the parameters for the azure-function-app module -} -``` - -_Note: the double slash (`//`) is intentional and required. It's part of Terraform's Git syntax (see [module sources](https://www.terraform.io/docs/modules/sources.html))._ - -See the module's documentation and `vars.tf` file for all the parameters you can set. Run `terraform get -update` to -pull the latest version of this module from this repo before running the standard `terraform plan` and -`terraform apply` commands. - - -## Using Scripts & Binaries - -You can install the scripts and binaries in the `modules` folder of any repo using the [Gruntwork Installer](https://github.com/gruntwork-io/gruntwork-installer). -For example, if the scripts you want to install are in the `modules/ecs-scripts` folder of the -https://github.com/gruntwork-io/module-ecs repo, you could install them as follows: - -```bash -gruntwork-install --module-name "ecs-scripts" --repo "https://github.com/gruntwork-io/module-ecs" --tag "0.0.1" -``` - -See the docs for each script & binary for detailed instructions on how to use them. +# package- log-analytics + +This repository contains modules for deploying and managing Azure Log Analytics Workspace that are shared across other modules or instances. + +## Using a Terraform Module + +To use a module in your Terraform templates, create a `module` resource and set its `source` field to the Git URL of +this repo. You should also set the `ref` parameter so you're fixed to a specific version of this repo, as the `master` +branch may have backwards incompatible changes (see [module sources](https://www.terraform.io/docs/modules/sources.html)). + +For example, to use `1.0.0` of the `azure-function-app` module, you would add the following: + +```hcl +module "function_app" { + source = "git::git@github.com:quantum-sec/package-azure-functions.git//modules/azure-function-app?ref=1.0.0" + + // set the parameters for the azure-function-app module +} +``` + +_Note: the double slash (`//`) is intentional and required. It's part of Terraform's Git syntax (see [module sources](https://www.terraform.io/docs/modules/sources.html))._ + +See the module's documentation and `vars.tf` file for all the parameters you can set. Run `terraform get -update` to +pull the latest version of this module from this repo before running the standard `terraform plan` and +`terraform apply` commands. + + +## Using Scripts & Binaries + +You can install the scripts and binaries in the `modules` folder of any repo using the [Gruntwork Installer](https://github.com/gruntwork-io/gruntwork-installer). +For example, if the scripts you want to install are in the `modules/ecs-scripts` folder of the +https://github.com/gruntwork-io/module-ecs repo, you could install them as follows: + +```bash +gruntwork-install --module-name "ecs-scripts" --repo "https://github.com/gruntwork-io/module-ecs" --tag "0.0.1" +``` + +See the docs for each script & binary for detailed instructions on how to use them. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index befde5f..ebdd566 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,18 +1,18 @@ -trigger: - branches: - include: - - master - - feature/* - - fix/* - -resources: - repositories: - - repository: pipeline-library - type: github - endpoint: quantum-sec-github - name: quantum-sec/pipeline-library - -jobs: - - template: templates/jobs/default.yml@pipeline-library - parameters: - containerImage: quantumdev.azurecr.io/quantum-ci-terragrunt:latest +trigger: + branches: + include: + - master + - feature/* + - fix/* + +resources: + repositories: + - repository: pipeline-library + type: github + endpoint: quantum-sec-github + name: quantum-sec/pipeline-library + +jobs: + - template: templates/jobs/default.yml@pipeline-library + parameters: + containerImage: quantumci.azurecr.io/quantum-ci-terragrunt:latest diff --git a/modules/log-analytics-workspace/main.tf b/modules/log-analytics-workspace/main.tf index 3f58323..42cfc13 100644 --- a/modules/log-analytics-workspace/main.tf +++ b/modules/log-analytics-workspace/main.tf @@ -12,5 +12,9 @@ resource "azurerm_log_analytics_workspace" "la" { location = var.location sku = var.sku retention_in_days = var.retention_in_days - tags = var.tags + tags = merge({ + "terraform-managed" = "true" + }, + var.tags + ) } diff --git a/modules/log-analytics-workspace/outputs.tf b/modules/log-analytics-workspace/outputs.tf index 2649aa9..719e194 100644 --- a/modules/log-analytics-workspace/outputs.tf +++ b/modules/log-analytics-workspace/outputs.tf @@ -9,3 +9,11 @@ output "workspace_id" { output "portal_url" { value = azurerm_log_analytics_workspace.la.portal_url } + +output "primary_shared_key" { + value = azurerm_log_analytics_workspace.la.primary_shared_key +} + +output "secondary_shared_key" { + value = azurerm_log_analytics_workspace.la.primary_shared_key +} diff --git a/modules/log-analytics-workspace/vars.tf b/modules/log-analytics-workspace/vars.tf index 90771f5..44070bc 100644 --- a/modules/log-analytics-workspace/vars.tf +++ b/modules/log-analytics-workspace/vars.tf @@ -4,12 +4,12 @@ variable "location" { } variable "name" { - description = "The name to assign to the LA workspace." + description = "The name to assign to the Log Analytics workspace." type = string } variable "resource_group_name" { - description = "The name of the resource group in which this LA workspace will be provisioned." + description = "The name of the resource group in which this Log Analytics workspace will be provisioned." type = string } @@ -20,13 +20,13 @@ variable "sku" { } variable "retention_in_days" { - description = "(Optional) The workspace data retention in days. Possible values are either 7 (Free Tier only) or range between 30 and 730." - type = string + description = "The workspace data retention in days. Possible values are either 7 (Free Tier only) or range between 30 and 730." + type = number default = 7 } variable "tags" { - description = "(Optional) A mapping of tags to assign to the resource." - type = string - default = null + description = "A mapping of tags to assign to the resource." + type = map(string) + default = {} } diff --git a/package-lock.json b/package-lock.json index d0317c9..4d3f6d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ -{ - "name": "@quantum-sec/package-log-analytics", - "version": "0.0.0-development", - "lockfileVersion": 1 -} +{ + "name": "@quantum-sec/package-log-analytics", + "version": "0.0.0-development", + "lockfileVersion": 1 +}