Skip to content

Commit e9b4423

Browse files
committed
feat(metrics-route): support managed_by field
Signed-off-by: Fidel Ruiz <[email protected]>
1 parent 70f438b commit e9b4423

23 files changed

+922
-474
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ website/vendor
3333
*.old
3434
vendor/
3535
*.lock.hcl
36+
.envrc
3637

3738
# Test exclusions
3839
!command/test-fixtures/**/*.tfstate
@@ -46,4 +47,4 @@ vendor/
4647
!deleteaddon.sh
4748
!deletecrd.sh
4849
!updatecrd.sh
49-
!updateodf.sh
50+
!updateodf.sh

examples/ibm-metrics-router/README.md

Lines changed: 98 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
# Example for IBM Cloud Metrics Routing
1+
# Examples for Metrics Routing API Version 3
22

3-
This example illustrates how to use the MetricsRouterV3
3+
These examples illustrate how to use the resources and data sources associated with Metrics Routing API Version 3.
44

5-
These types of resources are supported:
5+
The following resources are supported:
6+
* ibm_metrics_router_target
7+
* ibm_metrics_router_route
8+
* ibm_metrics_router_settings
69

7-
* metrics_router_target
8-
* metrics_router_route
9-
* metrics_router_settings
10+
The following data sources are supported:
11+
* ibm_metrics_router_targets
12+
* ibm_metrics_router_routes
1013

1114
## Usage
1215

13-
To run this example you need to execute:
16+
To run this example, execute the following commands:
1417

1518
```bash
1619
$ terraform init
@@ -20,30 +23,69 @@ $ terraform apply
2023

2124
Run `terraform destroy` when you don't need these resources.
2225

26+
## Metrics Routing API Version 3 resources
2327

24-
## MetricsRouterV3 resources
25-
26-
metrics_router_target resource:
28+
### Resource: ibm_metrics_router_target
2729

2830
```hcl
29-
resource "metrics_router_target" "metrics_router_target_instance" {
31+
resource "ibm_metrics_router_target" "metrics_router_target_instance" {
3032
name = var.metrics_router_target_name
3133
destination_crn = var.metrics_router_target_destination_crn
3234
region = var.metrics_router_target_region
35+
managed_by = var.metrics_router_target_managed_by
3336
}
3437
```
35-
metrics_router_route resource:
38+
39+
#### Inputs
40+
41+
| Name | Description | Type | Required |
42+
|------|-------------|------|---------|
43+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
44+
| name | The name of the target resource. | `string` | true |
45+
| destination_crn | Cloud Resource Name (CRN) of the destination resource. Ensure you have a service authorization between IBM Cloud Metrics Routing and your Cloud resource. See [service-to-service authorization](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-target-monitoring&interface=ui#target-monitoring-ui) for details. | `string` | true |
46+
| region | Include this optional field if you used it to create a target in a different region other than the one you are connected. | `string` | false |
47+
| managed_by | Present when the target is enterprise-managed (`managed_by: enterprise`). For account-managed targets this field is omitted. | `string` | false |
48+
49+
#### Outputs
50+
51+
| Name | Description |
52+
|------|-------------|
53+
| crn | The crn of the target resource. |
54+
| target_type | The type of the target. |
55+
| created_at | The timestamp of the target creation time. |
56+
| updated_at | The timestamp of the target last updated time. |
57+
58+
### Resource: ibm_metrics_router_route
3659

3760
```hcl
38-
resource "metrics_router_route" "metrics_router_route_instance" {
61+
resource "ibm_metrics_router_route" "metrics_router_route_instance" {
3962
name = var.metrics_router_route_name
4063
rules = var.metrics_router_route_rules
64+
managed_by = var.metrics_router_route_managed_by
4165
}
4266
```
43-
metrics_router_settings resource:
67+
68+
#### Inputs
69+
70+
| Name | Description | Type | Required |
71+
|------|-------------|------|---------|
72+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
73+
| name | The name of the route. | `string` | true |
74+
| rules | The routing rules that will be evaluated in their order of the array. Once a rule is matched, the remaining rules in the route definition will be skipped. | `list()` | true |
75+
| managed_by | Present when the route is enterprise-managed (`managed_by: enterprise`). | `string` | false |
76+
77+
#### Outputs
78+
79+
| Name | Description |
80+
|------|-------------|
81+
| crn | The crn of the route resource. |
82+
| created_at | The timestamp of the route creation time. |
83+
| updated_at | The timestamp of the route last updated time. |
84+
85+
### Resource: ibm_metrics_router_settings
4486

4587
```hcl
46-
resource "metrics_router_settings" "metrics_router_settings_instance" {
88+
resource "ibm_metrics_router_settings" "metrics_router_settings_instance" {
4789
default_targets = var.metrics_router_settings_default_targets
4890
permitted_target_regions = var.metrics_router_settings_permitted_target_regions
4991
primary_metadata_region = var.metrics_router_settings_primary_metadata_region
@@ -52,23 +94,59 @@ resource "metrics_router_settings" "metrics_router_settings_instance" {
5294
}
5395
```
5496

55-
## MetricsRouterV3 Data sources
97+
#### Inputs
98+
99+
| Name | Description | Type | Required |
100+
|------|-------------|------|---------|
101+
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
102+
| default_targets | A list of default target references. Enterprise-managed targets are not supported. | `list()` | false |
103+
| permitted_target_regions | If present then only these regions may be used to define a target. | `list(string)` | false |
104+
| primary_metadata_region | To store all your meta data in a single region. | `string` | false |
105+
| backup_metadata_region | To backup all your meta data in a different region. | `string` | false |
106+
| private_api_endpoint_only | If you set this true then you cannot access api through public network. | `bool` | false |
107+
108+
## Metrics Routing API Version 3 data sources
56109

57-
metrics_router_targets data source:
110+
### Data source: ibm_metrics_router_targets
58111

59112
```hcl
60-
data "metrics_router_targets" "metrics_router_targets_instance" {
113+
data "ibm_metrics_router_targets" "metrics_router_targets_instance" {
61114
name = var.metrics_router_targets_name
62115
}
63116
```
64-
metrics_router_routes data source:
117+
118+
#### Inputs
119+
120+
| Name | Description | Type | Required |
121+
|------|-------------|------|---------|
122+
| name | The name of the target resource. | `string` | false |
123+
124+
#### Outputs
125+
126+
| Name | Description |
127+
|------|-------------|
128+
| targets | A list of target resources. |
129+
130+
### Data source: ibm_metrics_router_routes
65131

66132
```hcl
67-
data "metrics_router_routes" "metrics_router_routes_instance" {
133+
data "ibm_metrics_router_routes" "metrics_router_routes_instance" {
68134
name = var.metrics_router_routes_name
69135
}
70136
```
71137

138+
#### Inputs
139+
140+
| Name | Description | Type | Required |
141+
|------|-------------|------|---------|
142+
| name | The name of the route. | `string` | false |
143+
144+
#### Outputs
145+
146+
| Name | Description |
147+
|------|-------------|
148+
| routes | A list of route resources. |
149+
72150
## Assumptions
73151

74152
1. TODO
@@ -88,54 +166,3 @@ data "metrics_router_routes" "metrics_router_routes_instance" {
88166
| Name | Version |
89167
|------|---------|
90168
| ibm | 1.13.1 |
91-
92-
## Inputs
93-
94-
### Target
95-
96-
| Name | Description | Type | Required |
97-
|------|-------------|------|---------|
98-
| ibmcloud\_api\_key | IBM Cloud API key | `string` | true |
99-
| name | The name of the target. The name must be 1000 characters or less, and cannot include any special characters other than `(space) - . _ :`. Do not include any personal identifying information (PII) in any resource names. | `string` | true |
100-
| destination_crn | The CRN of the destination resource. Ensure you have a service authorization between IBM Cloud Metrics Routing and your Cloud resource. Read [S2S authorization](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-target-monitoring&interface=ui#target-monitoring-ui) for details.| `string` | true |
101-
| region | Include this optional field if you want to create a target in a different region other than the one you are connected. | `string` | false |
102-
103-
### Route
104-
105-
| Name | Description | Type | Required |
106-
|------|-------------|------|---------|
107-
| name | The name of the route. The name must be 1000 characters or less and cannot include any special characters other than `(space) - . _ :`. Do not include any personal identifying information (PII) in any resource names. | `string` | true |
108-
| rules | Routing rules that will be evaluated in their order of the array. | `list()` | true |
109-
110-
### Settings
111-
112-
| Name | Description | Type | Required |
113-
|------|-------------|------|---------|
114-
| default_targets | A list of default target references. | `list()` | false |
115-
| permitted_target_regions | If present then only these regions may be used to define a target. | `list(string)` | false |
116-
| primary_metadata_region | To store all your meta data in a single region. For new accounts, all target / route creation will fail until primary_metadata_region is set. | `string` | false |
117-
| backup_metadata_region | To backup all your meta data in a different region. | `string` | false |
118-
| private_api_endpoint_only | If you set this true then you cannot access api through public network. | `bool` | false |
119-
120-
### Data Source For Target
121-
122-
| Name | Description | Type | Required |
123-
|------|-------------|------|---------|
124-
| name | The name of the target resource. | `string` | false |
125-
126-
### Data Source For Route
127-
128-
| Name | Description | Type | Required |
129-
|------|-------------|------|---------|
130-
| name | The name of the route. | `string` | false |
131-
132-
## Outputs
133-
134-
135-
| Name | Description |
136-
|------|-------------|
137-
| metrics_router_target | metrics_router_target object |
138-
| metrics_router_route | metrics_router_route object |
139-
| metrics_router_settings | metrics_router_settings object |
140-
| metrics_router_targets | metrics_router_targets object |
141-
| metrics_router_routes | metrics_router_routes object |

examples/ibm-metrics-router/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ resource "ibm_metrics_router_target" "metrics_router_target_instance" {
77
name = var.metrics_router_target_name
88
destination_crn = var.metrics_router_target_destination_crn
99
region = var.metrics_router_target_region
10+
managed_by = var.metrics_router_target_managed_by
1011
}
1112

1213
// Provision metrics_router_route resource instance
@@ -23,12 +24,13 @@ resource "ibm_metrics_router_route" "metrics_router_route_instance" {
2324
values = [ "us-south" ]
2425
}
2526
}
27+
managed_by = var.metrics_router_route_managed_by
2628
}
2729

2830
// Provision metrics_router_settings resource instance
2931
resource "ibm_metrics_router_settings" "metrics_router_settings_instance" {
3032
default_targets {
31-
id = ibm_metrics_router_target.metrics_router_target_instance.id
33+
id = ibm_metrics_router_target.metrics_router_target_instance.id
3234
}
3335
permitted_target_regions = var.metrics_router_settings_permitted_target_regions
3436
primary_metadata_region = var.metrics_router_settings_primary_metadata_region

examples/ibm-metrics-router/outputs.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
// This allows metrics_router_target data to be referenced by other resources and the terraform CLI
2-
// Modify this if only certain data should be exposed
1+
// This output allows metrics_router_target data to be referenced by other resources and the terraform CLI
2+
// Modify this output if only certain data should be exposed
33
output "ibm_metrics_router_target" {
44
value = ibm_metrics_router_target.metrics_router_target_instance
55
description = "metrics_router_target resource instance"
66
}
7-
// This allows metrics_router_route data to be referenced by other resources and the terraform CLI
8-
// Modify this if only certain data should be exposed
7+
// This output allows metrics_router_route data to be referenced by other resources and the terraform CLI
8+
// Modify this output if only certain data should be exposed
99
output "ibm_metrics_router_route" {
1010
value = ibm_metrics_router_route.metrics_router_route_instance
1111
description = "metrics_router_route resource instance"
1212
}
13-
// This allows metrics_router_settings data to be referenced by other resources and the terraform CLI
14-
// Modify this if only certain data should be exposed
13+
// This output allows metrics_router_settings data to be referenced by other resources and the terraform CLI
14+
// Modify this output if only certain data should be exposed
1515
output "ibm_metrics_router_settings" {
1616
value = ibm_metrics_router_settings.metrics_router_settings_instance
1717
description = "metrics_router_settings resource instance"

examples/ibm-metrics-router/variables.tf

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,37 @@ variable "ibmcloud_api_key" {
55

66
// Resource arguments for metrics_router_target
77
variable "metrics_router_target_name" {
8-
description = "The name of the target. The name must be 1000 characters or less, and cannot include any special characters other than `(space) - . _ :`. Do not include any personal identifying information (PII) in any resource names."
8+
description = "The name of the target resource."
99
type = string
1010
default = "my-mr-target"
1111
}
1212
variable "metrics_router_target_destination_crn" {
13-
description = "The CRN of a destination service instance or resource. Ensure you have a service authorization between IBM Cloud Metrics Routing and your Cloud resource. Read [S2S authorization](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-target-monitoring&interface=ui#target-monitoring-ui) for details."
13+
description = "Cloud Resource Name (CRN) of the destination resource. Ensure you have a service authorization between IBM Cloud Metrics Routing and your Cloud resource. See [service-to-service authorization](https://cloud.ibm.com/docs/metrics-router?topic=metrics-router-target-monitoring&interface=ui#target-monitoring-ui) for details."
1414
type = string
1515
default = "crn:v1:bluemix:public:sysdig-monitor:us-south:a/0be5ad401ae913d8ff665d92680664ed:22222222-2222-2222-2222-222222222222::"
1616
}
1717
variable "metrics_router_target_region" {
18-
description = "Include this optional field if you want to create a target in a different region other than the one you are connected."
18+
description = "Include this optional field if you used it to create a target in a different region other than the one you are connected."
1919
type = string
2020
default = "us-south"
2121
}
22+
variable "metrics_router_target_managed_by" {
23+
description = "Present when the target is enterprise-managed (`managed_by: enterprise`). For account-managed targets this field is omitted."
24+
type = string
25+
default = "enterprise"
26+
}
2227

2328
// Resource arguments for metrics_router_route
2429
variable "metrics_router_route_name" {
25-
description = "The name of the route. The name must be 1000 characters or less and cannot include any special characters other than `(space) - . _ :`. Do not include any personal identifying information (PII) in any resource names."
30+
description = "The name of the route."
2631
type = string
2732
default = "my-route"
2833
}
34+
variable "metrics_router_route_managed_by" {
35+
description = "Present when the route is enterprise-managed (`managed_by: enterprise`)."
36+
type = string
37+
default = "enterprise"
38+
}
2939

3040
// Resource arguments for metrics_router_settings
3141
variable "metrics_router_settings_permitted_target_regions" {
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
terraform {
2-
required_version = ">= 0.12"
3-
}
2+
required_version = ">= 1.0"
3+
required_providers {
4+
ibm = {
5+
source = "IBM-Cloud/ibm"
6+
version = "1.52.0-beta0"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)