Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access monitoring policy #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions aci_access_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,23 @@ module "aci_infra_dhcp_relay_policy" {
providers_ = each.value.providers_
}

locals {
infra_monitoring_policies = flatten([
for policy in try(local.access_policies.monitoring_policies, []) : {
name = "${policy.name}${local.defaults.apic.access_policies.monitoring_policies.name_suffix}"
description = try(policy.description, "")
}
])
}

module "aci_infra_monitoring_policy" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change module name to aci_access_monitoring_policy

source = "./modules/terraform-aci-infra-monitoring-policy"

for_each = { for policy in local.infra_monitoring_policies : policy.name => policy if local.modules.aci_infra_monitoring_policy && var.manage_access_policies }
name = each.value.name
description = each.value.description
}

module "aci_netflow_exporter" {
source = "./modules/terraform-aci-netflow-exporter"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '>= 0.14.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something is wrong with that module folder, i think you copied dhcp relay folder inside monitoring policy


formatter: markdown table

content: |-
# Terraform ACI Monitoring Policy Module

Manages ACI Monitoring Policy

Location in GUI:
`Fabric` » `Access Policies` » `Policies` » `Monitoring`

## Examples

```hcl
{{ include "./examples/complete/main.tf" }}
```

{{ .Requirements }}

{{ .Providers }}

{{ .Inputs }}

{{ .Outputs }}

{{ .Resources }}

output:
file: README.md
mode: replace

sort:
enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!-- BEGIN_TF_DOCS -->
# Terraform ACI Monitoring Policy Module

Manages ACI Monitoring Policy

Location in GUI:
`Fabric` » `Access Policies` » `Policies` » `Monitoring`

## Examples

```hcl
module "aci_infra_monitoring_policy" {
source = "netascode/nac-aci/aci//modules/terraform-aci-access-monitoring-policy"
version = ">= 0.8.0"

name = "INFRA-MONITORING-POL"
description = "My Description"
}
```

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_aci"></a> [aci](#requirement\_aci) | >= 2.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aci"></a> [aci](#provider\_aci) | >= 2.0.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | Monitoring policy name. | `string` | n/a | yes |
| <a name="input_description"></a> description | Description. | string | "" | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_dn"></a> [dn](#output\_dn) | Distinguished name of `monInfraPol` object. |
| <a name="output_name"></a> [name](#output\_name) | Monitoring policy name. |

## Resources

| Name | Type |
|------|------|
| [aci_rest_managed.monInfraPol](https://registry.terraform.io/providers/CiscoDevNet/aci/latest/docs/resources/rest_managed) | resource |
<!-- END_TF_DOCS -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: '>= 0.14.0'

formatter: markdown table

content: |-
# Monitoring Policy Example

To run this example you need to execute:

```bash
$ terraform init
$ terraform plan
$ terraform apply
```

Note that this example will create resources. Resources can be destroyed with `terraform destroy`.

```hcl
{{ include "./main.tf" }}
```

output:
file: README.md
mode: replace
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- BEGIN_TF_DOCS -->
# Monitoring Policy Example

To run this example you need to execute:

```bash
$ terraform init
$ terraform plan
$ terraform apply
```

Note that this example will create resources. Resources can be destroyed with `terraform destroy`.

```hcl
module "aci_infra_monitoring_policy" {
source = "netascode/nac-aci/aci//modules/terraform-aci-access-monitoring-policy"
version = ">= 0.8.0"
name = "INFRA-MONITORING-POL"
description = "My Description"
}
```
<!-- END_TF_DOCS -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "aci_infra_monitoring_policy" {
source = "netascode/nac-aci/aci//modules/terraform-aci-access-monitoring-policy"
version = ">= 0.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= 0.9.2


name = "INFRA-MONITORING-POL"
description = "My Description"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

terraform {
required_version = ">= 1.3.0"

required_providers {
aci = {
source = "CiscoDevNet/aci"
version = ">= 2.0.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "aci_rest_managed" "monInfraPol" {
dn = "uni/infra/moninfra-${var.name}"
class_name = "monInfraPol"
content = {
name = var.name
descr = var.description
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
output "dn" {
value = aci_rest_managed.monInfraPol.id
description = "Distinguished name of `monInfraPol` object."
}

output "name" {
value = aci_rest_managed.monInfraPol.content.name
description = "Monitoring policy name."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
variable "name" {
description = "Monitoring policy name."
type = string

validation {
condition = can(regex("^[a-zA-Z0-9_.:-]{0,64}$", var.name))
error_message = "Allowed characters: `a`-`z`, `A`-`Z`, `0`-`9`, `_`, `.`, `:`, `-`. Maximum characters: 64."
}
}

variable "description" {
description = "Description."
type = string
default = ""

validation {
condition = can(regex("^[a-zA-Z0-9\\!#$%()*,-./:;@ _{|}~?&+]{0,128}$", var.description))
error_message = "Allowed characters: `a`-`z`, `A`-`Z`, `0`-`9`, `\\`, `!`, `#`, `$`, `%`, `(`, `)`, `*`, `,`, `-`, `.`, `/`, `:`, `;`, `@`, ` `, `_`, `{`, `|`, }`, `~`, `?`, `&`, `+`. Maximum characters: 128."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

terraform {
required_version = ">= 1.3.0"

required_providers {
aci = {
source = "CiscoDevNet/aci"
version = ">= 2.0.0"
}
}
}
Loading