Skip to content

Commit 0188c94

Browse files
Terraform Team Automationsahilg11
authored andcommitted
Added - Support for Stack Monitoring: Home page for OCI compute and Monitoring Support for TCPS
1 parent 6cf4fb7 commit 0188c94

14 files changed

+225
-30
lines changed

examples/stack_monitoring/monitored_resource_associate_monitored_resources/monitored_resource_associate_monitored_resource.tf

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource1" {
3232
host_name = var.stack_mon_hostname_resource1
3333
management_agent_id = var.stack_mon_management_agent_id_resource1
3434
properties {
35-
name = "OS"
35+
name = "osName"
3636
value = "Linux"
3737
}
38+
properties {
39+
name = "osVersion"
40+
value = "7.0"
41+
}
3842
resource_time_zone = "en"
3943
}
4044
resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
@@ -48,9 +52,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
4852
host_name = var.stack_mon_hostname_resource2
4953
management_agent_id = var.stack_mon_management_agent_id_resource2
5054
properties {
51-
name = "OS"
55+
name = "osName"
5256
value = "Linux"
5357
}
58+
properties {
59+
name = "osVersion"
60+
value = "7.0"
61+
}
5462
resource_time_zone = "en"
5563
}
5664

examples/stack_monitoring/monitored_resources/monitored_resource.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource" {
3232
host_name = var.stack_mon_hostname_resource1
3333
management_agent_id = var.stack_mon_management_agent_id_resource1
3434
properties {
35-
name = "OS"
35+
name = "osName"
3636
value = "Linux"
3737
}
38+
properties {
39+
name = "osVersion"
40+
value = "7.0"
41+
}
3842
resource_time_zone = "en"
43+
lifecycle {
44+
ignore_changes = [
45+
properties, external_id]
46+
}
3947
}
4048

4149
data "oci_stack_monitoring_monitored_resource" "test_monitored_resource" {

examples/stack_monitoring/monitored_resources_list_members/monitored_resources_list_member.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource1" {
3232
host_name = var.stack_mon_hostname_resource1
3333
management_agent_id = var.stack_mon_management_agent_id_resource1
3434
properties {
35-
name = "OS"
35+
name = "osName"
3636
value = "Linux"
3737
}
38+
properties {
39+
name = "osVersion"
40+
value = "7.0"
41+
}
3842
resource_time_zone = "en"
3943
}
4044
resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
@@ -48,9 +52,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
4852
host_name = var.stack_mon_hostname_resource2
4953
management_agent_id = var.stack_mon_management_agent_id_resource2
5054
properties {
51-
name = "OS"
55+
name = "osName"
5256
value = "Linux"
5357
}
58+
properties {
59+
name = "osVersion"
60+
value = "7.0"
61+
}
5462
resource_time_zone = "en"
5563
}
5664

@@ -68,4 +76,4 @@ resource "oci_stack_monitoring_monitored_resources_list_member" "test_monitored_
6876

6977
#Optional
7078
destination_resource_id = oci_stack_monitoring_monitored_resource.test_monitored_resource2.id
71-
}
79+
}

examples/stack_monitoring/monitored_resources_search/monitored_resources_search.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource" {
3232
host_name = var.stack_mon_hostname_resource1
3333
management_agent_id = var.stack_mon_management_agent_id_resource1
3434
properties {
35-
name = "OS"
35+
name = "osName"
3636
value = "Linux"
3737
}
38+
properties {
39+
name = "osVersion"
40+
value = "7.0"
41+
}
3842
resource_time_zone = "en"
3943
}
4044

@@ -48,4 +52,4 @@ resource "oci_stack_monitoring_monitored_resources_search" "test_monitored_resou
4852
name = "terraformExample"
4953
resource_time_zone = "en"
5054
type = "host"
51-
}
55+
}

examples/stack_monitoring/monitored_resources_search_associations/monitored_resources_search_association.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource1" {
3232
host_name = var.stack_mon_hostname_resource1
3333
management_agent_id = var.stack_mon_management_agent_id_resource1
3434
properties {
35-
name = "OS"
35+
name = "osName"
3636
value = "Linux"
3737
}
38+
properties {
39+
name = "osVersion"
40+
value = "7.0"
41+
}
3842
resource_time_zone = "en"
3943
}
4044
resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
@@ -48,9 +52,13 @@ resource "oci_stack_monitoring_monitored_resource" "test_monitored_resource2" {
4852
host_name = var.stack_mon_hostname_resource2
4953
management_agent_id = var.stack_mon_management_agent_id_resource2
5054
properties {
51-
name = "OS"
55+
name = "osName"
5256
value = "Linux"
5357
}
58+
properties {
59+
name = "osVersion"
60+
value = "7.0"
61+
}
5462
resource_time_zone = "en"
5563
}
5664

@@ -74,4 +82,4 @@ resource "oci_stack_monitoring_monitored_resources_search_association" "test_mon
7482
source_resource_id = oci_stack_monitoring_monitored_resource.test_monitored_resource1.id
7583
source_resource_name = "terraformExample"
7684
source_resource_type = "host"
77-
}
85+
}

internal/integrationtest/stack_monitoring_monitored_resource_test.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ var (
4040
"monitored_resource_id": acctest.Representation{RepType: acctest.Required, Create: `${oci_stack_monitoring_monitored_resource.test_monitored_resource.id}`},
4141
}
4242

43+
StackMonitoringMonitoredResourceOSCreateProperty1 = map[string]interface{}{
44+
"name": acctest.Representation{RepType: acctest.Required, Create: `osName`},
45+
"value": acctest.Representation{RepType: acctest.Required, Create: `Linux`},
46+
}
47+
48+
StackMonitoringMonitoredResourceOSCreateProperty2 = map[string]interface{}{
49+
"name": acctest.Representation{RepType: acctest.Required, Create: `osVersion`},
50+
"value": acctest.Representation{RepType: acctest.Required, Create: `7.0`},
51+
}
52+
53+
StackMonitoringMonitoredResourceOSUpdateProperty1 = map[string]interface{}{
54+
"name": acctest.Representation{RepType: acctest.Required, Update: `osName`},
55+
"value": acctest.Representation{RepType: acctest.Required, Update: `Linux`},
56+
}
57+
58+
StackMonitoringMonitoredResourceOSUpdateProperty2 = map[string]interface{}{
59+
"name": acctest.Representation{RepType: acctest.Required, Update: `osVersion`},
60+
"value": acctest.Representation{RepType: acctest.Required, Update: `7.0`},
61+
}
62+
4363
StackMonitoringMonitoredResourceRepresentation = map[string]interface{}{
4464
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
4565
"name": acctest.Representation{RepType: acctest.Required, Create: `terraformResource`},
@@ -49,13 +69,13 @@ var (
4969
"management_agent_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.stack_mon_management_agent_id_resource1}`},
5070
"credentials": acctest.RepresentationGroup{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceCredentialsRepresentation},
5171
"database_connection_details": acctest.RepresentationGroup{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceDatabaseConnectionDetailsRepresentation},
52-
"properties": acctest.RepresentationGroup{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourcePropertiesRepresentation},
72+
"properties": []acctest.RepresentationGroup{{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceOSCreateProperty1}, {RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceOSCreateProperty2}},
5373
"resource_time_zone": acctest.Representation{RepType: acctest.Optional, Create: `en`},
5474
"lifecycle": acctest.RepresentationGroup{RepType: acctest.Required, Group: ignoreSensitiveDataRepresentation},
5575
}
5676
//Get API does not return sensitive data, it returns null
5777
ignoreSensitiveDataRepresentation = map[string]interface{}{
58-
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`credentials`, `database_connection_details`}},
78+
"ignore_changes": acctest.Representation{RepType: acctest.Required, Create: []string{`credentials`, `database_connection_details`, `properties`, `external_id`}},
5979
}
6080

6181
StackMonitoredResourceRepresentation2 = map[string]interface{}{
@@ -65,7 +85,7 @@ var (
6585
"display_name": acctest.Representation{RepType: acctest.Optional, Create: `displaySecondaryNameTerra`, Update: `displaySecondaryNameTerra2`},
6686
"host_name": acctest.Representation{RepType: acctest.Optional, Create: `${var.stack_mon_hostname_resource2}`},
6787
"management_agent_id": acctest.Representation{RepType: acctest.Optional, Create: `${var.stack_mon_management_agent_id_resource2}`},
68-
"properties": acctest.RepresentationGroup{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourcePropertiesRepresentation},
88+
"properties": []acctest.RepresentationGroup{{RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceOSCreateProperty1}, {RepType: acctest.Optional, Group: StackMonitoringMonitoredResourceOSCreateProperty2}},
6989
"resource_time_zone": acctest.Representation{RepType: acctest.Optional, Create: `en`},
7090
}
7191

@@ -90,10 +110,7 @@ var (
90110
"connector_id": acctest.Representation{RepType: acctest.Optional, Create: `connector.id`},
91111
"db_id": acctest.Representation{RepType: acctest.Optional, Create: `db_id`},
92112
"db_unique_name": acctest.Representation{RepType: acctest.Optional, Create: `dbUniqueName`, Update: `dbUniqueName2`},
93-
}
94-
StackMonitoringMonitoredResourcePropertiesRepresentation = map[string]interface{}{
95-
"name": acctest.Representation{RepType: acctest.Optional, Create: `OS`, Update: `OS`},
96-
"value": acctest.Representation{RepType: acctest.Optional, Create: `Linux`, Update: `Linux`},
113+
"ssl_secret_id": acctest.Representation{RepType: acctest.Optional, Create: `ssl_secret_id`},
97114
}
98115
StackMonitoringMonitoredResourceAliasesCredentialRepresentation = map[string]interface{}{
99116
"name": acctest.Representation{RepType: acctest.Required, Create: `name`, Update: `name2`},
@@ -174,9 +191,7 @@ func TestStackMonitoringMonitoredResourceResource_basic(t *testing.T) {
174191
resource.TestCheckResourceAttrSet(resourceName, "id"),
175192
resource.TestCheckResourceAttrSet(resourceName, "management_agent_id"),
176193
resource.TestCheckResourceAttr(resourceName, "name", "terraformResource"),
177-
resource.TestCheckResourceAttr(resourceName, "properties.#", "1"),
178-
resource.TestCheckResourceAttr(resourceName, "properties.0.name", "OS"),
179-
resource.TestCheckResourceAttr(resourceName, "properties.0.value", "Linux"),
194+
resource.TestCheckResourceAttr(resourceName, "properties.#", "4"),
180195
resource.TestCheckResourceAttr(resourceName, "resource_time_zone", "en"),
181196
resource.TestCheckResourceAttr(resourceName, "type", "host"),
182197

@@ -205,9 +220,7 @@ func TestStackMonitoringMonitoredResourceResource_basic(t *testing.T) {
205220
resource.TestCheckResourceAttrSet(resourceName, "host_name"),
206221
resource.TestCheckResourceAttrSet(resourceName, "id"),
207222
resource.TestCheckResourceAttrSet(resourceName, "management_agent_id"),
208-
resource.TestCheckResourceAttr(resourceName, "properties.#", "1"),
209-
resource.TestCheckResourceAttr(resourceName, "properties.0.name", "OS"),
210-
resource.TestCheckResourceAttr(resourceName, "properties.0.value", "Linux"),
223+
resource.TestCheckResourceAttr(resourceName, "properties.#", "4"),
211224
resource.TestCheckResourceAttr(resourceName, "resource_time_zone", "en"),
212225
resource.TestCheckResourceAttrSet(resourceName, "tenant_id"),
213226
resource.TestCheckResourceAttr(resourceName, "type", "host"),
@@ -233,9 +246,7 @@ func TestStackMonitoringMonitoredResourceResource_basic(t *testing.T) {
233246
resource.TestCheckResourceAttrSet(resourceName, "id"),
234247
resource.TestCheckResourceAttrSet(resourceName, "management_agent_id"),
235248
resource.TestCheckResourceAttr(resourceName, "name", "terraformResource"),
236-
resource.TestCheckResourceAttr(resourceName, "properties.#", "1"),
237-
resource.TestCheckResourceAttr(resourceName, "properties.0.name", "OS"),
238-
resource.TestCheckResourceAttr(resourceName, "properties.0.value", "Linux"),
249+
resource.TestCheckResourceAttr(resourceName, "properties.#", "4"),
239250
resource.TestCheckResourceAttr(resourceName, "resource_time_zone", "en"),
240251
resource.TestCheckResourceAttrSet(resourceName, "tenant_id"),
241252
resource.TestCheckResourceAttr(resourceName, "type", "host"),
@@ -262,9 +273,7 @@ func TestStackMonitoringMonitoredResourceResource_basic(t *testing.T) {
262273
resource.TestCheckResourceAttrSet(singularDatasourceName, "host_name"),
263274
resource.TestCheckResourceAttrSet(singularDatasourceName, "id"),
264275
resource.TestCheckResourceAttr(singularDatasourceName, "name", "terraformResource"),
265-
resource.TestCheckResourceAttr(singularDatasourceName, "properties.#", "1"),
266-
resource.TestCheckResourceAttr(singularDatasourceName, "properties.0.name", "OS"),
267-
resource.TestCheckResourceAttr(singularDatasourceName, "properties.0.value", "Linux"),
276+
resource.TestCheckResourceAttr(singularDatasourceName, "properties.#", "4"),
268277
resource.TestCheckResourceAttr(singularDatasourceName, "resource_time_zone", "en"),
269278
resource.TestCheckResourceAttrSet(singularDatasourceName, "state"),
270279
resource.TestCheckResourceAttrSet(singularDatasourceName, "tenant_id"),

internal/service/stack_monitoring/stack_monitoring_monitored_resource_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func (s *StackMonitoringMonitoredResourceDataSourceCrud) SetData() error {
100100
s.D.Set("display_name", *s.Res.DisplayName)
101101
}
102102

103+
if s.Res.ExternalId != nil {
104+
s.D.Set("external_id", *s.Res.ExternalId)
105+
}
106+
103107
s.D.Set("freeform_tags", s.Res.FreeformTags)
104108

105109
if s.Res.HostName != nil {

internal/service/stack_monitoring/stack_monitoring_monitored_resource_resource.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ func StackMonitoringMonitoredResourceResource() *schema.Resource {
200200
Type: schema.TypeString,
201201
Optional: true,
202202
},
203+
"ssl_secret_id": {
204+
Type: schema.TypeString,
205+
Optional: true,
206+
},
203207

204208
// Computed
205209
},
@@ -214,6 +218,11 @@ func StackMonitoringMonitoredResourceResource() *schema.Resource {
214218
Optional: true,
215219
ForceNew: true,
216220
},
221+
"external_id": {
222+
Type: schema.TypeString,
223+
Optional: true,
224+
ForceNew: true,
225+
},
217226
"host_name": {
218227
Type: schema.TypeString,
219228
Optional: true,
@@ -404,6 +413,11 @@ func (s *StackMonitoringMonitoredResourceResourceCrud) Create() error {
404413
request.ExternalResourceId = &tmp
405414
}
406415

416+
if externalId, ok := s.D.GetOkExists("external_id"); ok {
417+
tmp := externalId.(string)
418+
request.ExternalId = &tmp
419+
}
420+
407421
if hostName, ok := s.D.GetOkExists("host_name"); ok {
408422
tmp := hostName.(string)
409423
request.HostName = &tmp
@@ -683,6 +697,11 @@ func (s *StackMonitoringMonitoredResourceResourceCrud) Update() error {
683697
func (s *StackMonitoringMonitoredResourceResourceCrud) Delete() error {
684698
request := oci_stack_monitoring.DeleteMonitoredResourceRequest{}
685699

700+
if isDeleteMembers, ok := s.D.GetOkExists("is_delete_members"); ok {
701+
tmp := isDeleteMembers.(bool)
702+
request.IsDeleteMembers = &tmp
703+
}
704+
686705
tmp := s.D.Id()
687706
request.MonitoredResourceId = &tmp
688707

@@ -735,6 +754,10 @@ func (s *StackMonitoringMonitoredResourceResourceCrud) SetData() error {
735754
s.D.Set("display_name", *s.Res.DisplayName)
736755
}
737756

757+
if s.Res.ExternalId != nil {
758+
s.D.Set("external_id", *s.Res.ExternalId)
759+
}
760+
738761
s.D.Set("freeform_tags", s.Res.FreeformTags)
739762

740763
if s.Res.HostName != nil {
@@ -816,6 +839,11 @@ func (s *StackMonitoringMonitoredResourceResourceCrud) mapToConnectionDetails(fi
816839
result.ServiceName = &tmp
817840
}
818841

842+
if sslSecretId, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "ssl_secret_id")); ok {
843+
tmp := sslSecretId.(string)
844+
result.SslSecretId = &tmp
845+
}
846+
819847
return result, nil
820848
}
821849

@@ -844,6 +872,10 @@ func ConnectionDetailsToMap(obj *oci_stack_monitoring.ConnectionDetails) map[str
844872
result["service_name"] = string(*obj.ServiceName)
845873
}
846874

875+
if obj.SslSecretId != nil {
876+
result["ssl_secret_id"] = string(*obj.SslSecretId)
877+
}
878+
847879
return result
848880
}
849881

internal/service/stack_monitoring/stack_monitoring_monitored_resources_list_member_resource.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func StackMonitoringMonitoredResourcesListMemberResource() *schema.Resource {
5959
Computed: true,
6060
Elem: schema.TypeString,
6161
},
62+
"external_id": {
63+
Type: schema.TypeString,
64+
Computed: true,
65+
},
6266
"freeform_tags": {
6367
Type: schema.TypeMap,
6468
Computed: true,
@@ -188,6 +192,10 @@ func MonitoredResourceMemberSummaryToMap(obj oci_stack_monitoring.MonitoredResou
188192
result["defined_tags"] = tfresource.DefinedTagsToMap(obj.DefinedTags)
189193
}
190194

195+
if obj.ExternalId != nil {
196+
result["external_id"] = string(*obj.ExternalId)
197+
}
198+
191199
result["freeform_tags"] = obj.FreeformTags
192200

193201
if obj.HostName != nil {

0 commit comments

Comments
 (0)