From 5ea17c7078b9c14059a3f4d162196ea39e088ba6 Mon Sep 17 00:00:00 2001 From: jayvyas Date: Tue, 4 Jul 2023 14:42:58 +0530 Subject: [PATCH 1/3] initial commit --- CHANGELOG.md | 40 --------- ibm/provider/provider.go | 185 +++++++++++++++++---------------------- 2 files changed, 80 insertions(+), 145 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 507d6be45b..a895e502aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -915,12 +915,6 @@ Features - **Resources** - ibm_pi_shared_processor_pool - ibm_pi_spp_placement_group -* Support Security and Compilance - - **DataSources** - - ibm_scc_posture_profile_import - - ibm_scc_posture_scan_initiate_validation - - **Resources** - - ibm_scc_posture_scan_initiate_validation * Support App Configuration - **DataSources** - ibm_app_config_collection @@ -973,12 +967,6 @@ Features - **Resources** - ibm_pi_shared_processor_pool - ibm_pi_shared_processor_pool -* Support Security and Compilance - - **DataSources** - - ibm_scc_posture_profile_import - - ibm_scc_posture_scan_initiate_validation - - **Resources** - - ibm_scc_posture_scan_initiate_validation * Support App Configuration - **DataSources** - ibm_app_config_collection @@ -1135,13 +1123,6 @@ Features - **DataSources** - ibm_database_task - ibm_database_tasks -* Support Security and Compilance - - **DataSources** - - ibm_scc_posture_credential - - ibm_scc_posture_collector - - ibm_scc_posture_scope - - ibm_scc_posture_credentials - - ibm_scc_posture_collectors * Support Virtual Private Cloud - **DataSources** - ibm_is_backup_policy @@ -1199,13 +1180,6 @@ Features - **DataSources** - ibm_database_task - ibm_database_tasks -* Support Security and Compilance - - **DataSources** - - ibm_scc_posture_credential - - ibm_scc_posture_collector - - ibm_scc_posture_scope - - ibm_scc_posture_credentials - - ibm_scc_posture_collectors * Support Virtual Private Cloud - **DataSources** - ibm_is_backup_policy @@ -2061,15 +2035,6 @@ Features - ibm_pi_image_export - ibm_pi_placement_group - ibm_pi_capture -* Support Security and Compliance Center - - **DataSources** - - ibm_scc_posture_profile - - ibm_scc_posture_group_profile - - ibm_scc_posture_scope_correlation - - **Resources** - - ibm_scc_posture_collector - - ibm_scc_posture_scope - - ibm_scc_posture_credential * Support IAM Authorization Policies - **Datasources** - ibm_iam_authorization_policies @@ -2423,11 +2388,6 @@ FEATURES: - ibm_scc_si_note - ibm_scc_si_notes - ibm_scc_si_providers - - ibm_scc_posture_scopes - - ibm_scc_posture_latest_scans - - ibm_scc_posture_profiles - - ibm_scc_posture_scan_summary - -ibm_scc_posture_scan_summaries * Support Event Streams Schema - **Resources** diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index f95f752685..a2d8eb007d 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -718,20 +718,6 @@ func Provider() *schema.Provider { "ibm_scc_account_location_settings": scc.DataSourceIBMSccAccountLocationSettings(), "ibm_scc_account_notification_settings": scc.DataSourceIBMSccNotificationSettings(), - // Compliance Posture Management - "ibm_scc_posture_scopes": scc.DataSourceIBMSccPostureScopes(), - "ibm_scc_posture_latest_scans": scc.DataSourceIBMSccPostureLatestScans(), - "ibm_scc_posture_profiles": scc.DataSourceIBMSccPostureProfiles(), - "ibm_scc_posture_scan_summary": scc.DataSourceIBMSccPostureScansSummary(), - "ibm_scc_posture_scan_summaries": scc.DataSourceIBMSccPostureScanSummaries(), - "ibm_scc_posture_profile": scc.DataSourceIBMSccPostureProfileDetails(), - "ibm_scc_posture_group_profile": scc.DataSourceIBMSccPostureGroupProfileDetails(), - "ibm_scc_posture_scope_correlation": scc.DataSourceIBMSccPostureScopeCorrelation(), - "ibm_scc_posture_credential": scc.DataSourceIBMSccPostureCredential(), - "ibm_scc_posture_collector": scc.DataSourceIBMSccPostureCollector(), - "ibm_scc_posture_scope": scc.DataSourceIBMSccPostureScope(), - "ibm_scc_posture_credentials": scc.DataSourceIBMSccPostureCredentials(), - "ibm_scc_posture_collectors": scc.DataSourceIBMSccPostureCollectors(), // // Added for Context Based Restrictions "ibm_cbr_zone": contextbasedrestrictions.DataSourceIBMCbrZone(), "ibm_cbr_rule": contextbasedrestrictions.DataSourceIBMCbrRule(), @@ -1214,13 +1200,6 @@ func Provider() *schema.Provider { "ibm_scc_template": scc.ResourceIBMSccTemplate(), "ibm_scc_template_attachment": scc.ResourceIBMSccTemplateAttachment(), - //Security and Compliance Center - PostureManagement - "ibm_scc_posture_collector": scc.ResourceIBMSccPostureCollectors(), - "ibm_scc_posture_scope": scc.ResourceIBMSccPostureScopes(), - "ibm_scc_posture_credential": scc.ResourceIBMSccPostureCredentials(), - "ibm_scc_posture_profile_import": scc.ResourceIBMSccPostureProfileImport(), - "ibm_scc_posture_scan_initiate_validation": scc.ResourceIBMSccPostureScanInitiateValidation(), - // // Added for Context Based Restrictions "ibm_cbr_zone": contextbasedrestrictions.ResourceIBMCbrZone(), "ibm_cbr_rule": contextbasedrestrictions.ResourceIBMCbrRule(), @@ -1389,90 +1368,86 @@ func Validator() validate.ValidatorDict { "ibm_is_bare_metal_server_network_interface": vpc.ResourceIBMIsBareMetalServerNetworkInterfaceValidator(), "ibm_is_bare_metal_server": vpc.ResourceIBMIsBareMetalServerValidator(), - "ibm_is_dedicated_host_group": vpc.ResourceIbmIsDedicatedHostGroupValidator(), - "ibm_is_dedicated_host": vpc.ResourceIbmIsDedicatedHostValidator(), - "ibm_is_dedicated_host_disk_management": vpc.ResourceIBMISDedicatedHostDiskManagementValidator(), - "ibm_is_flow_log": vpc.ResourceIBMISFlowLogValidator(), - "ibm_is_instance_group": vpc.ResourceIBMISInstanceGroupValidator(), - "ibm_is_instance_group_membership": vpc.ResourceIBMISInstanceGroupMembershipValidator(), - "ibm_is_instance_group_manager": vpc.ResourceIBMISInstanceGroupManagerValidator(), - "ibm_is_instance_group_manager_policy": vpc.ResourceIBMISInstanceGroupManagerPolicyValidator(), - "ibm_is_instance_group_manager_action": vpc.ResourceIBMISInstanceGroupManagerActionValidator(), - "ibm_is_floating_ip": vpc.ResourceIBMISFloatingIPValidator(), - "ibm_is_ike_policy": vpc.ResourceIBMISIKEValidator(), - "ibm_is_image": vpc.ResourceIBMISImageValidator(), - "ibm_is_image_export_job": vpc.ResourceIBMIsImageExportValidator(), - "ibm_is_instance_template": vpc.ResourceIBMISInstanceTemplateValidator(), - "ibm_is_instance": vpc.ResourceIBMISInstanceValidator(), - "ibm_is_instance_action": vpc.ResourceIBMISInstanceActionValidator(), - "ibm_is_instance_network_interface": vpc.ResourceIBMIsInstanceNetworkInterfaceValidator(), - "ibm_is_instance_disk_management": vpc.ResourceIBMISInstanceDiskManagementValidator(), - "ibm_is_instance_volume_attachment": vpc.ResourceIBMISInstanceVolumeAttachmentValidator(), - "ibm_is_ipsec_policy": vpc.ResourceIBMISIPSECValidator(), - "ibm_is_lb_listener_policy_rule": vpc.ResourceIBMISLBListenerPolicyRuleValidator(), - "ibm_is_lb_listener_policy": vpc.ResourceIBMISLBListenerPolicyValidator(), - "ibm_is_lb_listener": vpc.ResourceIBMISLBListenerValidator(), - "ibm_is_lb_pool_member": vpc.ResourceIBMISLBPoolMemberValidator(), - "ibm_is_lb_pool": vpc.ResourceIBMISLBPoolValidator(), - "ibm_is_lb": vpc.ResourceIBMISLBValidator(), - "ibm_is_network_acl": vpc.ResourceIBMISNetworkACLValidator(), - "ibm_is_network_acl_rule": vpc.ResourceIBMISNetworkACLRuleValidator(), - "ibm_is_public_gateway": vpc.ResourceIBMISPublicGatewayValidator(), - "ibm_is_placement_group": vpc.ResourceIbmIsPlacementGroupValidator(), - "ibm_is_security_group_target": vpc.ResourceIBMISSecurityGroupTargetValidator(), - "ibm_is_security_group_rule": vpc.ResourceIBMISSecurityGroupRuleValidator(), - "ibm_is_security_group": vpc.ResourceIBMISSecurityGroupValidator(), - "ibm_is_share": vpc.ResourceIbmIsShareValidator(), - "ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperationsValidator(), - "ibm_is_share_target": vpc.ResourceIbmIsShareMountTargetValidator(), - "ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTargetValidator(), - "ibm_is_snapshot": vpc.ResourceIBMISSnapshotValidator(), - "ibm_is_ssh_key": vpc.ResourceIBMISSHKeyValidator(), - "ibm_is_subnet": vpc.ResourceIBMISSubnetValidator(), - "ibm_is_subnet_reserved_ip": vpc.ResourceIBMISSubnetReservedIPValidator(), - "ibm_is_volume": vpc.ResourceIBMISVolumeValidator(), - "ibm_is_address_prefix": vpc.ResourceIBMISAddressPrefixValidator(), - "ibm_is_vpc": vpc.ResourceIBMISVPCValidator(), - "ibm_is_vpc_routing_table": vpc.ResourceIBMISVPCRoutingTableValidator(), - "ibm_is_vpc_routing_table_route": vpc.ResourceIBMISVPCRoutingTableRouteValidator(), - "ibm_is_vpn_gateway_connection": vpc.ResourceIBMISVPNGatewayConnectionValidator(), - "ibm_is_vpn_gateway": vpc.ResourceIBMISVPNGatewayValidator(), - "ibm_is_vpn_server": vpc.ResourceIBMIsVPNServerValidator(), - "ibm_is_vpn_server_route": vpc.ResourceIBMIsVPNServerRouteValidator(), - "ibm_kms_key_rings": kms.ResourceIBMKeyRingValidator(), - "ibm_dns_glb_monitor": dnsservices.ResourceIBMPrivateDNSGLBMonitorValidator(), - "ibm_dns_custom_resolver_forwarding_rule": dnsservices.ResourceIBMPrivateDNSForwardingRuleValidator(), - "ibm_schematics_action": schematics.ResourceIBMSchematicsActionValidator(), - "ibm_schematics_job": schematics.ResourceIBMSchematicsJobValidator(), - "ibm_schematics_workspace": schematics.ResourceIBMSchematicsWorkspaceValidator(), - "ibm_schematics_inventory": schematics.ResourceIBMSchematicsInventoryValidator(), - "ibm_schematics_resource_query": schematics.ResourceIBMSchematicsResourceQueryValidator(), - "ibm_resource_instance": resourcecontroller.ResourceIBMResourceInstanceValidator(), - "ibm_resource_key": resourcecontroller.ResourceIBMResourceKeyValidator(), - "ibm_is_virtual_endpoint_gateway": vpc.ResourceIBMISEndpointGatewayValidator(), - "ibm_resource_tag": globaltagging.ResourceIBMResourceTagValidator(), - "ibm_satellite_location": satellite.ResourceIBMSatelliteLocationValidator(), - "ibm_satellite_cluster": satellite.ResourceIBMSatelliteClusterValidator(), - "ibm_pi_volume": power.ResourceIBMPIVolumeValidator(), - "ibm_atracker_target": atracker.ResourceIBMAtrackerTargetValidator(), - "ibm_atracker_route": atracker.ResourceIBMAtrackerRouteValidator(), - "ibm_atracker_settings": atracker.ResourceIBMAtrackerSettingsValidator(), - "ibm_metrics_router_target": metricsrouter.ResourceIBMMetricsRouterTargetValidator(), - "ibm_metrics_router_route": metricsrouter.ResourceIBMMetricsRouterRouteValidator(), - "ibm_metrics_router_settings": metricsrouter.ResourceIBMMetricsRouterSettingsValidator(), - "ibm_satellite_endpoint": satellite.ResourceIBMSatelliteEndpointValidator(), - "ibm_scc_account_settings": scc.ResourceIBMSccAccountSettingsValidator(), - "ibm_scc_posture_collector": scc.ResourceIBMSccPostureCollectorsValidator(), - "ibm_scc_posture_scope": scc.ResourceIBMSccPostureScopesValidator(), - "ibm_scc_posture_credential": scc.ResourceIBMSccPostureCredentialsValidator(), - "ibm_scc_posture_scan_initiate_validation": scc.ResourceIBMSccPostureScanInitiateValidationValidator(), - "ibm_scc_rule": scc.ResourceIBMSccRuleValidator(), - "ibm_scc_rule_attachment": scc.ResourceIBMSccRuleAttachmentValidator(), - "ibm_scc_template": scc.ResourceIBMSccTemplateValidator(), - "ibm_scc_template_attachment": scc.ResourceIBMSccTemplateAttachmentValidator(), - "ibm_cbr_zone": contextbasedrestrictions.ResourceIBMCbrZoneValidator(), - "ibm_cbr_rule": contextbasedrestrictions.ResourceIBMCbrRuleValidator(), - "ibm_satellite_host": satellite.ResourceIBMSatelliteHostValidator(), + "ibm_is_dedicated_host_group": vpc.ResourceIbmIsDedicatedHostGroupValidator(), + "ibm_is_dedicated_host": vpc.ResourceIbmIsDedicatedHostValidator(), + "ibm_is_dedicated_host_disk_management": vpc.ResourceIBMISDedicatedHostDiskManagementValidator(), + "ibm_is_flow_log": vpc.ResourceIBMISFlowLogValidator(), + "ibm_is_instance_group": vpc.ResourceIBMISInstanceGroupValidator(), + "ibm_is_instance_group_membership": vpc.ResourceIBMISInstanceGroupMembershipValidator(), + "ibm_is_instance_group_manager": vpc.ResourceIBMISInstanceGroupManagerValidator(), + "ibm_is_instance_group_manager_policy": vpc.ResourceIBMISInstanceGroupManagerPolicyValidator(), + "ibm_is_instance_group_manager_action": vpc.ResourceIBMISInstanceGroupManagerActionValidator(), + "ibm_is_floating_ip": vpc.ResourceIBMISFloatingIPValidator(), + "ibm_is_ike_policy": vpc.ResourceIBMISIKEValidator(), + "ibm_is_image": vpc.ResourceIBMISImageValidator(), + "ibm_is_image_export_job": vpc.ResourceIBMIsImageExportValidator(), + "ibm_is_instance_template": vpc.ResourceIBMISInstanceTemplateValidator(), + "ibm_is_instance": vpc.ResourceIBMISInstanceValidator(), + "ibm_is_instance_action": vpc.ResourceIBMISInstanceActionValidator(), + "ibm_is_instance_network_interface": vpc.ResourceIBMIsInstanceNetworkInterfaceValidator(), + "ibm_is_instance_disk_management": vpc.ResourceIBMISInstanceDiskManagementValidator(), + "ibm_is_instance_volume_attachment": vpc.ResourceIBMISInstanceVolumeAttachmentValidator(), + "ibm_is_ipsec_policy": vpc.ResourceIBMISIPSECValidator(), + "ibm_is_lb_listener_policy_rule": vpc.ResourceIBMISLBListenerPolicyRuleValidator(), + "ibm_is_lb_listener_policy": vpc.ResourceIBMISLBListenerPolicyValidator(), + "ibm_is_lb_listener": vpc.ResourceIBMISLBListenerValidator(), + "ibm_is_lb_pool_member": vpc.ResourceIBMISLBPoolMemberValidator(), + "ibm_is_lb_pool": vpc.ResourceIBMISLBPoolValidator(), + "ibm_is_lb": vpc.ResourceIBMISLBValidator(), + "ibm_is_network_acl": vpc.ResourceIBMISNetworkACLValidator(), + "ibm_is_network_acl_rule": vpc.ResourceIBMISNetworkACLRuleValidator(), + "ibm_is_public_gateway": vpc.ResourceIBMISPublicGatewayValidator(), + "ibm_is_placement_group": vpc.ResourceIbmIsPlacementGroupValidator(), + "ibm_is_security_group_target": vpc.ResourceIBMISSecurityGroupTargetValidator(), + "ibm_is_security_group_rule": vpc.ResourceIBMISSecurityGroupRuleValidator(), + "ibm_is_security_group": vpc.ResourceIBMISSecurityGroupValidator(), + "ibm_is_share": vpc.ResourceIbmIsShareValidator(), + "ibm_is_share_replica_operations": vpc.ResourceIbmIsShareReplicaOperationsValidator(), + "ibm_is_share_target": vpc.ResourceIbmIsShareMountTargetValidator(), + "ibm_is_share_mount_target": vpc.ResourceIBMIsShareMountTargetValidator(), + "ibm_is_snapshot": vpc.ResourceIBMISSnapshotValidator(), + "ibm_is_ssh_key": vpc.ResourceIBMISSHKeyValidator(), + "ibm_is_subnet": vpc.ResourceIBMISSubnetValidator(), + "ibm_is_subnet_reserved_ip": vpc.ResourceIBMISSubnetReservedIPValidator(), + "ibm_is_volume": vpc.ResourceIBMISVolumeValidator(), + "ibm_is_address_prefix": vpc.ResourceIBMISAddressPrefixValidator(), + "ibm_is_vpc": vpc.ResourceIBMISVPCValidator(), + "ibm_is_vpc_routing_table": vpc.ResourceIBMISVPCRoutingTableValidator(), + "ibm_is_vpc_routing_table_route": vpc.ResourceIBMISVPCRoutingTableRouteValidator(), + "ibm_is_vpn_gateway_connection": vpc.ResourceIBMISVPNGatewayConnectionValidator(), + "ibm_is_vpn_gateway": vpc.ResourceIBMISVPNGatewayValidator(), + "ibm_is_vpn_server": vpc.ResourceIBMIsVPNServerValidator(), + "ibm_is_vpn_server_route": vpc.ResourceIBMIsVPNServerRouteValidator(), + "ibm_kms_key_rings": kms.ResourceIBMKeyRingValidator(), + "ibm_dns_glb_monitor": dnsservices.ResourceIBMPrivateDNSGLBMonitorValidator(), + "ibm_dns_custom_resolver_forwarding_rule": dnsservices.ResourceIBMPrivateDNSForwardingRuleValidator(), + "ibm_schematics_action": schematics.ResourceIBMSchematicsActionValidator(), + "ibm_schematics_job": schematics.ResourceIBMSchematicsJobValidator(), + "ibm_schematics_workspace": schematics.ResourceIBMSchematicsWorkspaceValidator(), + "ibm_schematics_inventory": schematics.ResourceIBMSchematicsInventoryValidator(), + "ibm_schematics_resource_query": schematics.ResourceIBMSchematicsResourceQueryValidator(), + "ibm_resource_instance": resourcecontroller.ResourceIBMResourceInstanceValidator(), + "ibm_resource_key": resourcecontroller.ResourceIBMResourceKeyValidator(), + "ibm_is_virtual_endpoint_gateway": vpc.ResourceIBMISEndpointGatewayValidator(), + "ibm_resource_tag": globaltagging.ResourceIBMResourceTagValidator(), + "ibm_satellite_location": satellite.ResourceIBMSatelliteLocationValidator(), + "ibm_satellite_cluster": satellite.ResourceIBMSatelliteClusterValidator(), + "ibm_pi_volume": power.ResourceIBMPIVolumeValidator(), + "ibm_atracker_target": atracker.ResourceIBMAtrackerTargetValidator(), + "ibm_atracker_route": atracker.ResourceIBMAtrackerRouteValidator(), + "ibm_atracker_settings": atracker.ResourceIBMAtrackerSettingsValidator(), + "ibm_metrics_router_target": metricsrouter.ResourceIBMMetricsRouterTargetValidator(), + "ibm_metrics_router_route": metricsrouter.ResourceIBMMetricsRouterRouteValidator(), + "ibm_metrics_router_settings": metricsrouter.ResourceIBMMetricsRouterSettingsValidator(), + "ibm_satellite_endpoint": satellite.ResourceIBMSatelliteEndpointValidator(), + "ibm_scc_account_settings": scc.ResourceIBMSccAccountSettingsValidator(), + "ibm_scc_rule": scc.ResourceIBMSccRuleValidator(), + "ibm_scc_rule_attachment": scc.ResourceIBMSccRuleAttachmentValidator(), + "ibm_scc_template": scc.ResourceIBMSccTemplateValidator(), + "ibm_scc_template_attachment": scc.ResourceIBMSccTemplateAttachmentValidator(), + "ibm_cbr_zone": contextbasedrestrictions.ResourceIBMCbrZoneValidator(), + "ibm_cbr_rule": contextbasedrestrictions.ResourceIBMCbrRuleValidator(), + "ibm_satellite_host": satellite.ResourceIBMSatelliteHostValidator(), // // Added for Toolchains "ibm_cd_toolchain": cdtoolchain.ResourceIBMCdToolchainValidator(), From 477c584480e86d5c64801b48593edabfd7ce4ce5 Mon Sep 17 00:00:00 2001 From: jayvyas Date: Tue, 4 Jul 2023 15:47:25 +0530 Subject: [PATCH 2/3] removing v1 refereneces --- examples/ibm-scc/posture-management/main.tf | 51 - ibm/acctest/acctest.go | 85 - .../data_source_ibm_scc_posture_collector.go | 306 ---- ...a_source_ibm_scc_posture_collector_test.go | 46 - .../data_source_ibm_scc_posture_collectors.go | 526 ------- ..._source_ibm_scc_posture_collectors_test.go | 40 - .../data_source_ibm_scc_posture_credential.go | 353 ----- ..._source_ibm_scc_posture_credential_test.go | 43 - ...data_source_ibm_scc_posture_credentials.go | 538 ------- ...source_ibm_scc_posture_credentials_test.go | 37 - ...ta_source_ibm_scc_posture_group_profile.go | 347 ----- ...urce_ibm_scc_posture_group_profile_test.go | 36 - ...ata_source_ibm_scc_posture_latest_scans.go | 508 ------ ...ource_ibm_scc_posture_latest_scans_test.go | 37 - .../data_source_ibm_scc_posture_profile.go | 161 -- ...ata_source_ibm_scc_posture_profile_test.go | 45 - .../data_source_ibm_scc_posture_profiles.go | 356 ----- ...ta_source_ibm_scc_posture_profiles_test.go | 37 - ...a_source_ibm_scc_posture_scan_summaries.go | 621 -------- ...rce_ibm_scc_posture_scan_summaries_test.go | 38 - ...ata_source_ibm_scc_posture_scan_summary.go | 356 ----- ...ource_ibm_scc_posture_scan_summary_test.go | 39 - .../scc/data_source_ibm_scc_posture_scope.go | 1372 ----------------- ...ource_ibm_scc_posture_scope_correlation.go | 89 -- ..._ibm_scc_posture_scope_correlation_test.go | 36 - .../data_source_ibm_scc_posture_scope_test.go | 36 - .../scc/data_source_ibm_scc_posture_scopes.go | 630 -------- ...data_source_ibm_scc_posture_scopes_test.go | 40 - .../scc/resource_ibm_scc_posture_collector.go | 231 --- ...resource_ibm_scc_posture_collector_test.go | 193 --- .../resource_ibm_scc_posture_credential.go | 280 ---- ...esource_ibm_scc_posture_credential_test.go | 146 -- ...resource_ibm_scc_posture_import_profile.go | 192 --- ...rce_ibm_scc_posture_import_profile_test.go | 77 - ...bm_scc_posture_scan_initiate_validation.go | 208 --- ...c_posture_scan_initiate_validation_test.go | 40 - .../scc/resource_ibm_scc_posture_scope.go | 235 --- .../resource_ibm_scc_posture_scope_test.go | 185 --- 38 files changed, 8596 deletions(-) delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_collector.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_collector_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_collectors.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_collectors_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_credential.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_credential_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_credentials.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_credentials_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_group_profile.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_group_profile_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_latest_scans.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_latest_scans_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_profile.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_profile_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_profiles.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_profiles_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scan_summaries.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scan_summaries_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scan_summary.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scan_summary_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scope.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scope_correlation.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scope_correlation_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scope_test.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scopes.go delete mode 100644 ibm/service/scc/data_source_ibm_scc_posture_scopes_test.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_collector.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_collector_test.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_credential.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_credential_test.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_import_profile.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_import_profile_test.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation_test.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_scope.go delete mode 100644 ibm/service/scc/resource_ibm_scc_posture_scope_test.go diff --git a/examples/ibm-scc/posture-management/main.tf b/examples/ibm-scc/posture-management/main.tf index 208ac4a725..ec9cd3db23 100644 --- a/examples/ibm-scc/posture-management/main.tf +++ b/examples/ibm-scc/posture-management/main.tf @@ -1,54 +1,3 @@ provider "ibm" { ibmcloud_api_key = var.ibmcloud_api_key -} - -// Create list_scopes data source -data "ibm_scc_posture_scopes" "list_scopes_instance" { - scope_id = var.list_scopes_scope_id -} - -// Create list_profiles data source -data "ibm_scc_posture_profiles" "list_profiles_instance" { - profile_id = var.list_profiles_profile_id -} - -// Create list_credentials data source -data "ibm_scc_posture_credentials" "list_credentials_instance" { -} - -// Create list_collectors data source -data "ibm_scc_posture_collectors" "list_collectors_instance" { -} - -// Create list_latest_scans data source -data "ibm_scc_posture_latest_scans" "list_latest_scans_instance" { - scan_id = var.list_latest_scans_scan_id -} - -// Create scans_summary data source -data "ibm_scc_posture_scan_summary" "scans_summary_instance" { - scan_id = var.scans_summary_scan_id - profile_id = var.scans_summary_profile_id -} - -// Create scan_summaries data source -data "ibm_scc_posture_scan_summaries" "scan_summaries_instance" { - profile_id = var.scan_summaries_profile_id - scope_id = var.scan_summaries_scope_id - scan_id = var.scan_summaries_scan_id -} - -// Create scope data source -data "ibm_scc_posture_scope" "scope_instance" { - scope_id = var.scope_id -} - -// Create collector data source -data "ibm_scc_posture_collector" "collector_instance" { - collector_id = var.collector_id -} - -// Create credential data source -data "ibm_scc_posture_credential" "credential_instance" { - credential_id = var.credential_id } \ No newline at end of file diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index 09ff740107..a7a24fd955 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -206,22 +206,6 @@ var Scc_resource_group_id string // Security and Compliance Center, SI var Scc_si_account string -// Security and Compliance Center, Posture Management -var Scc_posture_scope_id string -var Scc_posture_scan_id string -var Scc_posture_profile_id string -var Scc_posture_group_profile_id string -var Scc_posture_correlation_id string -var Scc_posture_report_setting_id string -var Scc_posture_profile_id_scansummary string -var Scc_posture_scan_id_scansummary string -var Scc_posture_credential_id_scope string -var Scc_posture_credential_id_scope_update string -var Scc_posture_collector_id_scope []string -var Scc_posture_collector_id_scope_update []string -var Scc_posture_collector_id string -var Scc_posture_credential_id string - // ROKS Cluster var ClusterName string @@ -1178,75 +1162,6 @@ func init() { fmt.Println("[INFO] Set the environment variable SCC_SI_ACCOUNT for testing SCC SI resources resource else tests will fail if this is not set correctly") } - Scc_posture_scope_id = os.Getenv("SCC_POSTURE_SCOPE_ID") - if Scc_posture_scope_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_SCOPE_ID for testing SCC Posture resources or datasource resource else tests will fail if this is not set correctly") - } - - Scc_posture_scan_id = os.Getenv("SCC_POSTURE_SCAN_ID") - if Scc_posture_scan_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_SCAN_ID for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_profile_id = os.Getenv("SCC_POSTURE_PROFILE_ID") - if Scc_posture_profile_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_PROFILE_ID for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - Scc_posture_group_profile_id = os.Getenv("SCC_POSTURE_GROUP_PROFILE_ID") - if Scc_posture_group_profile_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_GROUP_PROFILE_ID for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_correlation_id = os.Getenv("SCC_POSTURE_CORRELATION_ID") - if Scc_posture_correlation_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_CORRELATION_ID for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_report_setting_id = os.Getenv("SCC_POSTURE_REPORT_SETTING_ID") - if Scc_posture_report_setting_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_REPORT_SETTING_ID for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_profile_id_scansummary = os.Getenv("SCC_POSTURE_PROFILE_ID_SCANSUMMARY") - if Scc_posture_profile_id_scansummary == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_PROFILE_ID_SCANSUMMARY for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_scan_id_scansummary = os.Getenv("SCC_POSTURE_SCAN_ID_SCANSUMMARY") - if Scc_posture_scan_id_scansummary == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_SCAN_ID_SCANSUMMARY for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_credential_id_scope = os.Getenv("SCC_POSTURE_CREDENTIAL_ID_SCOPE") - if Scc_posture_credential_id_scope == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_CREDENTIAL_ID_SCOPE for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_credential_id_scope_update = os.Getenv("SCC_POSTURE_CREDENTIAL_ID_SCOPE_UPDATE") - if Scc_posture_credential_id_scope_update == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_CREDENTIAL_ID_SCOPE_UPDATE for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_collector_id_scope = []string{os.Getenv("SCC_POSTURE_COLLECTOR_ID_SCOPE")} - if os.Getenv("SCC_POSTURE_COLLECTOR_ID_SCOPE") == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_COLLECTOR_ID_SCOPE for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_collector_id_scope_update = []string{os.Getenv("SCC_POSTURE_COLLECTOR_ID_SCOPE_UPDATE")} - if os.Getenv("SCC_POSTURE_COLLECTOR_ID_SCOPE_UPDATE") == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_COLLECTOR_ID_SCOPE_UPDATE for testing SCC Posture resource or datasource else tests will fail if this is not set correctly") - } - - Scc_posture_collector_id = os.Getenv("SCC_POSTURE_COLLECTOR_ID") - if Scc_posture_collector_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_COLLECTOR_ID for testing SCC Posture resources or datasource resource else tests will fail if this is not set correctly") - } - - Scc_posture_credential_id = os.Getenv("SCC_POSTURE_CREDENTIAL_ID") - if Scc_posture_credential_id == "" { - fmt.Println("[INFO] Set the environment variable SCC_POSTURE_CREDENTIAL_ID for testing SCC Posture resources or datasource resource else tests will fail if this is not set correctly") - } - CloudShellAccountID = os.Getenv("IBM_CLOUD_SHELL_ACCOUNT_ID") if CloudShellAccountID == "" { fmt.Println("[INFO] Set the environment variable IBM_CLOUD_SHELL_ACCOUNT_ID for ibm-cloud-shell resource or datasource else tests will fail if this is not set correctly") diff --git a/ibm/service/scc/data_source_ibm_scc_posture_collector.go b/ibm/service/scc/data_source_ibm_scc_posture_collector.go deleted file mode 100644 index 542c03fd4d..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_collector.go +++ /dev/null @@ -1,306 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureCollector() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureCollectorRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_collector is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "collector_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The id for the given API.", - }, - "display_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The user-friendly name of the collector.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the collector.", - }, - "public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed.", - }, - "last_heartbeat": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the heartbeat time of a controller . This value exists when collector is installed and running.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of collector.", - }, - "collector_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector version. This field is populated when collector is installed.", - }, - "image_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The image version of the collector. This field is populated when collector is installed. \".", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the collector.", - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that created the collector.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was created.", - }, - "updated_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that modified the collector.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was modified.", - }, - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Identifies whether the collector is enabled or not(deleted).", - }, - "registration_code": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The registration code of the collector.This is will be used for initial authentication during installation of collector.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of the collector.", - }, - "credential_public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The credential public key.", - }, - "failure_count": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The number of times the collector has failed.", - }, - "approved_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved local gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "approved_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved internet gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "last_failed_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed local gateway ip. This field will be populated only when collector is installed.", - }, - "reset_reason": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field .", - }, - "hostname": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name.", - }, - "install_path": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The installation path of the collector. This field will be populated when collector is installed.The value will be folder path.", - }, - "use_private_endpoint": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false.", - }, - "managed_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The entity that manages the collector.", - }, - "trial_expiry": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed.", - }, - "last_failed_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed internet gateway ip of the collector.", - }, - "status_description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector status.", - }, - "reset_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field.", - }, - "is_public": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network.", - }, - "is_ubi_image": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector has a Ubi image.", - }, - }, - } -} - -func dataSourceIBMSccPostureCollectorRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - CollectorOptions := &posturemanagementv2.GetCollectorOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - CollectorOptions.SetAccountID(accountID) - CollectorOptions.SetID(d.Get("collector_id").(string)) - - collector, response, err := postureManagementClient.GetCollectorWithContext(context, CollectorOptions) - if err != nil { - log.Printf("[DEBUG] GetCollectorWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetCollectorWithContext failed %s\n%s", err, response)) - } - - d.SetId(*collector.ID) - if err = d.Set("display_name", collector.DisplayName); err != nil { - return diag.FromErr(fmt.Errorf("Error setting display_name: %s", err)) - } - if err = d.Set("name", collector.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if err = d.Set("public_key", collector.PublicKey); err != nil { - return diag.FromErr(fmt.Errorf("Error setting public_key: %s", err)) - } - if err = d.Set("last_heartbeat", flex.DateTimeToString(collector.LastHeartbeat)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_heartbeat: %s", err)) - } - if err = d.Set("status", collector.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) - } - if err = d.Set("collector_version", collector.CollectorVersion); err != nil { - return diag.FromErr(fmt.Errorf("Error setting collector_version: %s", err)) - } - if err = d.Set("image_version", collector.ImageVersion); err != nil { - return diag.FromErr(fmt.Errorf("Error setting image_version: %s", err)) - } - if err = d.Set("description", collector.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - if err = d.Set("created_by", collector.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_by: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(collector.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } - if err = d.Set("updated_by", collector.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) - } - if err = d.Set("updated_at", flex.DateTimeToString(collector.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) - } - if err = d.Set("enabled", collector.Enabled); err != nil { - return diag.FromErr(fmt.Errorf("Error setting enabled: %s", err)) - } - if err = d.Set("registration_code", collector.RegistrationCode); err != nil { - return diag.FromErr(fmt.Errorf("Error setting registration_code: %s", err)) - } - if err = d.Set("type", collector.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - if err = d.Set("credential_public_key", collector.CredentialPublicKey); err != nil { - return diag.FromErr(fmt.Errorf("Error setting credential_public_key: %s", err)) - } - if err = d.Set("failure_count", flex.IntValue(collector.FailureCount)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting failure_count: %s", err)) - } - if err = d.Set("approved_local_gateway_ip", collector.ApprovedLocalGatewayIP); err != nil { - return diag.FromErr(fmt.Errorf("Error setting approved_local_gateway_ip: %s", err)) - } - if err = d.Set("approved_internet_gateway_ip", collector.ApprovedInternetGatewayIP); err != nil { - return diag.FromErr(fmt.Errorf("Error setting approved_internet_gateway_ip: %s", err)) - } - if err = d.Set("last_failed_local_gateway_ip", collector.LastFailedLocalGatewayIP); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_failed_local_gateway_ip: %s", err)) - } - if err = d.Set("reset_reason", collector.ResetReason); err != nil { - return diag.FromErr(fmt.Errorf("Error setting reset_reason: %s", err)) - } - if err = d.Set("hostname", collector.Hostname); err != nil { - return diag.FromErr(fmt.Errorf("Error setting hostname: %s", err)) - } - if err = d.Set("install_path", collector.InstallPath); err != nil { - return diag.FromErr(fmt.Errorf("Error setting install_path: %s", err)) - } - if err = d.Set("use_private_endpoint", collector.UsePrivateEndpoint); err != nil { - return diag.FromErr(fmt.Errorf("Error setting use_private_endpoint: %s", err)) - } - if err = d.Set("managed_by", collector.ManagedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting managed_by: %s", err)) - } - if err = d.Set("trial_expiry", flex.DateTimeToString(collector.TrialExpiry)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting trial_expiry: %s", err)) - } - if err = d.Set("last_failed_internet_gateway_ip", collector.LastFailedInternetGatewayIP); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_failed_internet_gateway_ip: %s", err)) - } - if err = d.Set("status_description", collector.StatusDescription); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_description: %s", err)) - } - if err = d.Set("reset_time", flex.DateTimeToString(collector.ResetTime)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting reset_time: %s", err)) - } - if err = d.Set("is_public", collector.IsPublic); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_public: %s", err)) - } - if err = d.Set("is_ubi_image", collector.IsUbiImage); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_ubi_image: %s", err)) - } - - return nil -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_collector_test.go b/ibm/service/scc/data_source_ibm_scc_posture_collector_test.go deleted file mode 100644 index 0289ce3b80..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_collector_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureCollectorDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIBMSccPostureCollectorDataSourceConfigBasic(acc.Scc_posture_collector_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "collector_id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "display_name"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "name"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "status"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "enabled"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "registration_code"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "type"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "failure_count"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "use_private_endpoint"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "managed_by"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "status_description"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collector.collector", "is_public"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureCollectorDataSourceConfigBasic(collectorId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_collector" "collector" { - collector_id = "%s" - } - `, collectorId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_collectors.go b/ibm/service/scc/data_source_ibm_scc_posture_collectors.go deleted file mode 100644 index a7a4b4778e..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_collectors.go +++ /dev/null @@ -1,526 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureCollectors() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureListCollectorsRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_collectors is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "offset": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The offset from the start of the list (0-based).", - }, - "limit": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The number of items to return.", - }, - "total_count": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The total number of items in the list. This will have value as 0 when no collectors are available and below values will not be populated in that case.", - }, - "first": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "next": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "collectors": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The array of items returned.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the collector.", - }, - "display_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The user-friendly name of the collector.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the collector.", - }, - "public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed.", - }, - "last_heartbeat": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the heartbeat time of a controller . This value exists when collector is installed and running.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of collector.", - }, - "collector_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector version. This field is populated when collector is installed.", - }, - "image_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The image version of the collector. This field is populated when collector is installed. \".", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the collector.", - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that created the collector.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was created.", - }, - "updated_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that modified the collector.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was modified.", - }, - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Identifies whether the collector is enabled or not(deleted).", - }, - "registration_code": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The registration code of the collector.This is will be used for initial authentication during installation of collector.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of the collector.", - }, - "credential_public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The credential public key.", - }, - "failure_count": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The number of times the collector has failed.", - }, - "approved_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved local gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "approved_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved internet gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "last_failed_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed local gateway ip. This field will be populated only when collector is installed.", - }, - "reset_reason": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field .", - }, - "hostname": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name.", - }, - "install_path": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The installation path of the collector. This field will be populated when collector is installed.The value will be folder path.", - }, - "use_private_endpoint": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false.", - }, - "managed_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The entity that manages the collector.", - }, - "trial_expiry": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed.", - }, - "last_failed_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed internet gateway ip of the collector.", - }, - "status_description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector status.", - }, - "reset_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field.", - }, - "is_public": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network.", - }, - "is_ubi_image": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector has a Ubi image.", - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureListCollectorsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - listCollectorsOptions := &posturemanagementv2.ListCollectorsOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - listCollectorsOptions.SetAccountID(accountID) - - collectorList, response, err := postureManagementClient.ListCollectorsWithContext(context, listCollectorsOptions) - if err != nil { - log.Printf("[DEBUG] ListCollectorsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ListCollectorsWithContext failed %s\n%s", err, response)) - } - - d.SetId(dataSourceIBMSccPostureListCollectorsID(d)) - if err = d.Set("offset", flex.IntValue(collectorList.Offset)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting offset: %s", err)) - } - if err = d.Set("limit", flex.IntValue(collectorList.Limit)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting limit: %s", err)) - } - if err = d.Set("total_count", flex.IntValue(collectorList.TotalCount)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting total_count: %s", err)) - } - - if collectorList.First != nil { - err = d.Set("first", dataSourceCollectorListFlattenFirst(*collectorList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting first %s", err)) - } - } - - if collectorList.Last != nil { - err = d.Set("last", dataSourceCollectorListFlattenLast(*collectorList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting last %s", err)) - } - } - - if collectorList.Next != nil { - err = d.Set("next", dataSourceCollectorListFlattenNext(*collectorList.Next)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting next %s", err)) - } - } - - if collectorList.Previous != nil { - err = d.Set("previous", dataSourceCollectorListFlattenPrevious(*collectorList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting previous %s", err)) - } - } - - if collectorList.Collectors != nil { - err = d.Set("collectors", dataSourceCollectorListFlattenCollectors(collectorList.Collectors)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting collectors %s", err)) - } - } - - return nil -} - -// dataSourceIBMSccPostureListCollectorsID returns a reasonable ID for the list. -func dataSourceIBMSccPostureListCollectorsID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceCollectorListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCollectorListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCollectorListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceCollectorListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCollectorListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCollectorListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceCollectorListFlattenNext(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCollectorListNextToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCollectorListNextToMap(nextItem posturemanagementv2.PageLink) (nextMap map[string]interface{}) { - nextMap = map[string]interface{}{} - - if nextItem.Href != nil { - nextMap["href"] = nextItem.Href - } - - return nextMap -} - -func dataSourceCollectorListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCollectorListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCollectorListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceCollectorListFlattenCollectors(result []posturemanagementv2.Collector) (collectors []map[string]interface{}) { - for _, collectorsItem := range result { - collectors = append(collectors, dataSourceCollectorListCollectorsToMap(collectorsItem)) - } - - return collectors -} - -func dataSourceCollectorListCollectorsToMap(collectorsItem posturemanagementv2.Collector) (collectorsMap map[string]interface{}) { - collectorsMap = map[string]interface{}{} - - if collectorsItem.ID != nil { - collectorsMap["id"] = collectorsItem.ID - } - if collectorsItem.DisplayName != nil { - collectorsMap["display_name"] = collectorsItem.DisplayName - } - if collectorsItem.Name != nil { - collectorsMap["name"] = collectorsItem.Name - } - if collectorsItem.PublicKey != nil { - collectorsMap["public_key"] = collectorsItem.PublicKey - } - if collectorsItem.LastHeartbeat != nil { - collectorsMap["last_heartbeat"] = collectorsItem.LastHeartbeat.String() - } - if collectorsItem.Status != nil { - collectorsMap["status"] = collectorsItem.Status - } - if collectorsItem.CollectorVersion != nil { - collectorsMap["collector_version"] = collectorsItem.CollectorVersion - } - if collectorsItem.ImageVersion != nil { - collectorsMap["image_version"] = collectorsItem.ImageVersion - } - if collectorsItem.Description != nil { - collectorsMap["description"] = collectorsItem.Description - } - if collectorsItem.CreatedBy != nil { - collectorsMap["created_by"] = collectorsItem.CreatedBy - } - if collectorsItem.CreatedAt != nil { - collectorsMap["created_at"] = collectorsItem.CreatedAt.String() - } - if collectorsItem.UpdatedBy != nil { - collectorsMap["updated_by"] = collectorsItem.UpdatedBy - } - if collectorsItem.UpdatedAt != nil { - collectorsMap["updated_at"] = collectorsItem.UpdatedAt.String() - } - if collectorsItem.Enabled != nil { - collectorsMap["enabled"] = collectorsItem.Enabled - } - if collectorsItem.RegistrationCode != nil { - collectorsMap["registration_code"] = collectorsItem.RegistrationCode - } - if collectorsItem.Type != nil { - collectorsMap["type"] = collectorsItem.Type - } - if collectorsItem.CredentialPublicKey != nil { - collectorsMap["credential_public_key"] = collectorsItem.CredentialPublicKey - } - if collectorsItem.FailureCount != nil { - collectorsMap["failure_count"] = collectorsItem.FailureCount - } - if collectorsItem.ApprovedLocalGatewayIP != nil { - collectorsMap["approved_local_gateway_ip"] = collectorsItem.ApprovedLocalGatewayIP - } - if collectorsItem.ApprovedInternetGatewayIP != nil { - collectorsMap["approved_internet_gateway_ip"] = collectorsItem.ApprovedInternetGatewayIP - } - if collectorsItem.LastFailedLocalGatewayIP != nil { - collectorsMap["last_failed_local_gateway_ip"] = collectorsItem.LastFailedLocalGatewayIP - } - if collectorsItem.ResetReason != nil { - collectorsMap["reset_reason"] = collectorsItem.ResetReason - } - if collectorsItem.Hostname != nil { - collectorsMap["hostname"] = collectorsItem.Hostname - } - if collectorsItem.InstallPath != nil { - collectorsMap["install_path"] = collectorsItem.InstallPath - } - if collectorsItem.UsePrivateEndpoint != nil { - collectorsMap["use_private_endpoint"] = collectorsItem.UsePrivateEndpoint - } - if collectorsItem.ManagedBy != nil { - collectorsMap["managed_by"] = collectorsItem.ManagedBy - } - if collectorsItem.TrialExpiry != nil { - collectorsMap["trial_expiry"] = collectorsItem.TrialExpiry.String() - } - if collectorsItem.LastFailedInternetGatewayIP != nil { - collectorsMap["last_failed_internet_gateway_ip"] = collectorsItem.LastFailedInternetGatewayIP - } - if collectorsItem.StatusDescription != nil { - collectorsMap["status_description"] = collectorsItem.StatusDescription - } - if collectorsItem.ResetTime != nil { - collectorsMap["reset_time"] = collectorsItem.ResetTime.String() - } - if collectorsItem.IsPublic != nil { - collectorsMap["is_public"] = collectorsItem.IsPublic - } - if collectorsItem.IsUbiImage != nil { - collectorsMap["is_ubi_image"] = collectorsItem.IsUbiImage - } - - return collectorsMap -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_collectors_test.go b/ibm/service/scc/data_source_ibm_scc_posture_collectors_test.go deleted file mode 100644 index c6b2d2534f..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_collectors_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureListCollectorsDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIBMSccPostureListCollectorsDataSourceConfigBasic(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "offset"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "limit"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "total_count"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "first.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "last.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_collectors.list_collectors", "collectors.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureListCollectorsDataSourceConfigBasic() string { - return fmt.Sprintf(` - data "ibm_scc_posture_collectors" "list_collectors" { - } - `) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_credential.go b/ibm/service/scc/data_source_ibm_scc_posture_credential.go deleted file mode 100644 index 6bc5fddb8d..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_credential.go +++ /dev/null @@ -1,353 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureCredential() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureCredentialRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_credential is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "credential_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The id for the given API.", - }, - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Credentials status enabled/disbaled.", - }, - "credential_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials type.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials description.", - }, - "display_fields": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Details the fields on the credential. This will change as per credential type selected.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ibm_api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key. This is mandatory for IBM Credential Type.", - }, - "aws_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS client Id.This is mandatory for AWS Cloud.", - }, - "aws_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS client secret.This is mandatory for AWS Cloud.", - }, - "aws_region": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS region.", - }, - "aws_arn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS arn value.", - }, - "username": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "password": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "azure_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure client Id. This is mandatory for Azure Credential type.", - }, - "azure_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure client secret.This is mandatory for Azure Credential type.", - }, - "azure_subscription_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure subscription Id.This is mandatory for Azure Credential type.", - }, - "azure_resource_group": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure resource group.", - }, - "database_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Database name.This is mandatory for Database Credential type.", - }, - "winrm_authtype": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_usessl": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_port": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows port.This is mandatory for Windows Kerberos Credential type.", - }, - "ms_365_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 client Id.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 client secret.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_tenant_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 tenantId.This is mandatory for Windows MS365 Credential type.", - }, - "auth_url": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "user_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "pem_file_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the PEM file.", - }, - "pem_data": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The base64 encoded data to associate with the PEM file.", - }, - }, - }, - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the user who created the credentials.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The time that the credentials was created in UTC.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The modified time that the credentials was modified in UTC.", - }, - "updated_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the user who modified the credentials.", - }, - "purpose": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Purpose for which the credential is created.", - }, - }, - } -} - -func dataSourceIBMSccPostureCredentialRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - CredentialOptions := &posturemanagementv2.GetCredentialOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - CredentialOptions.SetAccountID(accountID) - CredentialOptions.SetID(d.Get("credential_id").(string)) - - credential, response, err := postureManagementClient.GetCredentialWithContext(context, CredentialOptions) - if err != nil { - log.Printf("[DEBUG] GetCredentialWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetCredentialWithContext failed %s\n%s", err, response)) - } - - d.SetId(*credential.ID) - if err = d.Set("enabled", credential.Enabled); err != nil { - return diag.FromErr(fmt.Errorf("Error setting enabled: %s", err)) - } - if err = d.Set("credential_type", credential.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - if err = d.Set("name", credential.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if err = d.Set("description", credential.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - - if credential.DisplayFields != nil { - err = d.Set("display_fields", dataSourceCredentialFlattenDisplayFields(*credential.DisplayFields)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting display_fields %s", err)) - } - } - if err = d.Set("created_by", credential.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_by: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(credential.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } - if err = d.Set("updated_at", flex.DateTimeToString(credential.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_at: %s", err)) - } - if err = d.Set("updated_by", credential.UpdatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting updated_by: %s", err)) - } - if err = d.Set("purpose", credential.Purpose); err != nil { - return diag.FromErr(fmt.Errorf("Error setting purpose: %s", err)) - } - - return nil -} - -func dataSourceCredentialFlattenDisplayFields(result posturemanagementv2.CredentialDisplayFields) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCredentialDisplayFieldsToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCredentialDisplayFieldsToMap(displayFieldsItem posturemanagementv2.CredentialDisplayFields) (displayFieldsMap map[string]interface{}) { - displayFieldsMap = map[string]interface{}{} - - if displayFieldsItem.IBMAPIKey != nil { - displayFieldsMap["ibm_api_key"] = displayFieldsItem.IBMAPIKey - } - if displayFieldsItem.AwsClientID != nil { - displayFieldsMap["aws_client_id"] = displayFieldsItem.AwsClientID - } - if displayFieldsItem.AwsClientSecret != nil { - displayFieldsMap["aws_client_secret"] = displayFieldsItem.AwsClientSecret - } - if displayFieldsItem.AwsRegion != nil { - displayFieldsMap["aws_region"] = displayFieldsItem.AwsRegion - } - if displayFieldsItem.AwsArn != nil { - displayFieldsMap["aws_arn"] = displayFieldsItem.AwsArn - } - if displayFieldsItem.Username != nil { - displayFieldsMap["username"] = displayFieldsItem.Username - } - if displayFieldsItem.Password != nil { - displayFieldsMap["password"] = displayFieldsItem.Password - } - if displayFieldsItem.AzureClientID != nil { - displayFieldsMap["azure_client_id"] = displayFieldsItem.AzureClientID - } - if displayFieldsItem.AzureClientSecret != nil { - displayFieldsMap["azure_client_secret"] = displayFieldsItem.AzureClientSecret - } - if displayFieldsItem.AzureSubscriptionID != nil { - displayFieldsMap["azure_subscription_id"] = displayFieldsItem.AzureSubscriptionID - } - if displayFieldsItem.AzureResourceGroup != nil { - displayFieldsMap["azure_resource_group"] = displayFieldsItem.AzureResourceGroup - } - if displayFieldsItem.DatabaseName != nil { - displayFieldsMap["database_name"] = displayFieldsItem.DatabaseName - } - if displayFieldsItem.WinrmAuthtype != nil { - displayFieldsMap["winrm_authtype"] = displayFieldsItem.WinrmAuthtype - } - if displayFieldsItem.WinrmUsessl != nil { - displayFieldsMap["winrm_usessl"] = displayFieldsItem.WinrmUsessl - } - if displayFieldsItem.WinrmPort != nil { - displayFieldsMap["winrm_port"] = displayFieldsItem.WinrmPort - } - if displayFieldsItem.Ms365ClientID != nil { - displayFieldsMap["ms_365_client_id"] = displayFieldsItem.Ms365ClientID - } - if displayFieldsItem.Ms365ClientSecret != nil { - displayFieldsMap["ms_365_client_secret"] = displayFieldsItem.Ms365ClientSecret - } - if displayFieldsItem.Ms365TenantID != nil { - displayFieldsMap["ms_365_tenant_id"] = displayFieldsItem.Ms365TenantID - } - if displayFieldsItem.AuthURL != nil { - displayFieldsMap["auth_url"] = displayFieldsItem.AuthURL - } - if displayFieldsItem.ProjectName != nil { - displayFieldsMap["project_name"] = displayFieldsItem.ProjectName - } - if displayFieldsItem.UserDomainName != nil { - displayFieldsMap["user_domain_name"] = displayFieldsItem.UserDomainName - } - if displayFieldsItem.ProjectDomainName != nil { - displayFieldsMap["project_domain_name"] = displayFieldsItem.ProjectDomainName - } - if displayFieldsItem.PemFileName != nil { - displayFieldsMap["pem_file_name"] = displayFieldsItem.PemFileName - } - if displayFieldsItem.PemData != nil { - displayFieldsMap["pem_data"] = displayFieldsItem.PemData - } - - return displayFieldsMap -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_credential_test.go b/ibm/service/scc/data_source_ibm_scc_posture_credential_test.go deleted file mode 100644 index 70ce3c1788..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_credential_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureCredentialDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIBMSccPostureCredentialDataSourceConfigBasic(acc.Scc_posture_credential_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "credential_id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "enabled"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "credential_type"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "name"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "created_by"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "updated_by"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credential.credential", "purpose"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureCredentialDataSourceConfigBasic(credentialId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_credential" "credential" { - credential_id = "%s" - } - `, credentialId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_credentials.go b/ibm/service/scc/data_source_ibm_scc_posture_credentials.go deleted file mode 100644 index ffd7fc3f76..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_credentials.go +++ /dev/null @@ -1,538 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "net/url" - "reflect" - "strconv" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureCredentials() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureListCredentialsRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_credentials is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "first": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "credentials": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "The details of a credentials.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Credentials status enabled/disbaled.", - }, - "id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials ID.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials type.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials name.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Credentials description.", - }, - "display_fields": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Details the fields on the credential. This will change as per credential type selected.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ibm_api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Sensitive: true, - Description: "The IBM Cloud API Key. This is mandatory for IBM Credential Type.", - }, - "aws_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS client Id.This is mandatory for AWS Cloud.", - }, - "aws_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Sensitive: true, - Description: "AWS client secret.This is mandatory for AWS Cloud.", - }, - "aws_region": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS region.", - }, - "aws_arn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS arn value.", - }, - "username": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "password": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Sensitive: true, - Description: "password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "azure_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure client Id. This is mandatory for Azure Credential type.", - }, - "azure_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Sensitive: true, - Description: "Azure client secret.This is mandatory for Azure Credential type.", - }, - "azure_subscription_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure subscription Id.This is mandatory for Azure Credential type.", - }, - "azure_resource_group": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure resource group.", - }, - "database_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Database name.This is mandatory for Database Credential type.", - }, - "winrm_authtype": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_usessl": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_port": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows port.This is mandatory for Windows Kerberos Credential type.", - }, - "ms_365_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 client Id.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Sensitive: true, - Description: "The MS365 client secret.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_tenant_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 tenantId.This is mandatory for Windows MS365 Credential type.", - }, - "auth_url": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "user_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "pem_file_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the PEM file.", - }, - "pem_data": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The base64 encoded data to associate with the PEM file.", - }, - }, - }, - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the user who created the credentials.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The time that the credentials was created in UTC.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The modified time that the credentials was modified in UTC.", - }, - "updated_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "ID of the user who modified the credentials.", - }, - "purpose": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Purpose for which the credential is created.", - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureListCredentialsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - listCredentialsOptions := &posturemanagementv2.ListCredentialsOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - listCredentialsOptions.SetAccountID(accountID) - - var credentialList *posturemanagementv2.CredentialList - - listCredentialsOptions.Limit = core.Int64Ptr(int64(2)) - result, response, err := postureManagementClient.ListCredentialsWithContext(context, listCredentialsOptions) - credentialList = result - if err != nil { - log.Printf("[DEBUG] ListCredentialsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ListCredentialsWithContext failed %s\n%s", err, response)) - } - - d.SetId(dataSourceIBMSccPostureListCredentialsID(d)) - - if credentialList.First != nil { - err = d.Set("first", dataSourceCredentialListFlattenFirst(*credentialList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting first %s", err)) - } - } - - if credentialList.Last != nil { - err = d.Set("last", dataSourceCredentialListFlattenLast(*credentialList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting last %s", err)) - } - } - - if credentialList.Previous != nil { - err = d.Set("previous", dataSourceCredentialListFlattenPrevious(*credentialList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting previous %s", err)) - } - } - - if credentialList.Credentials != nil { - err = d.Set("credentials", dataSourceCredentialListFlattenCredentials(credentialList.Credentials)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting credentials %s", err)) - } - } - - return nil -} - -// dataSourceIBMSccPostureListCredentialsID returns a reasonable ID for the list. -func dataSourceIBMSccPostureListCredentialsID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceCredentialListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCredentialListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCredentialListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceCredentialListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCredentialListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCredentialListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceCredentialListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceCredentialListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceCredentialListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceCredentialListFlattenCredentials(result []posturemanagementv2.Credential) (credentials []map[string]interface{}) { - for _, credentialsItem := range result { - credentials = append(credentials, dataSourceCredentialListCredentialsToMap(credentialsItem)) - } - - return credentials -} - -func dataSourceCredentialListCredentialsToMap(credentialsItem posturemanagementv2.Credential) (credentialsMap map[string]interface{}) { - credentialsMap = map[string]interface{}{} - - if credentialsItem.Enabled != nil { - credentialsMap["enabled"] = credentialsItem.Enabled - } - if credentialsItem.ID != nil { - credentialsMap["id"] = credentialsItem.ID - } - if credentialsItem.Type != nil { - credentialsMap["type"] = credentialsItem.Type - } - if credentialsItem.Name != nil { - credentialsMap["name"] = credentialsItem.Name - } - if credentialsItem.Description != nil { - credentialsMap["description"] = credentialsItem.Description - } - if credentialsItem.DisplayFields != nil { - displayFieldsList := []map[string]interface{}{} - displayFieldsMap := dataSourceCredentialListCredentialsDisplayFieldsToMap(*credentialsItem.DisplayFields) - displayFieldsList = append(displayFieldsList, displayFieldsMap) - credentialsMap["display_fields"] = displayFieldsList - } - if credentialsItem.CreatedBy != nil { - credentialsMap["created_by"] = credentialsItem.CreatedBy - } - if credentialsItem.CreatedAt != nil { - credentialsMap["created_at"] = credentialsItem.CreatedAt.String() - } - if credentialsItem.UpdatedAt != nil { - credentialsMap["updated_at"] = credentialsItem.UpdatedAt.String() - } - if credentialsItem.UpdatedBy != nil { - credentialsMap["updated_by"] = credentialsItem.UpdatedBy - } - if credentialsItem.Purpose != nil { - credentialsMap["purpose"] = credentialsItem.Purpose - } - - return credentialsMap -} - -func dataSourceCredentialListCredentialsDisplayFieldsToMap(displayFieldsItem posturemanagementv2.CredentialDisplayFields) (displayFieldsMap map[string]interface{}) { - displayFieldsMap = map[string]interface{}{} - - if displayFieldsItem.IBMAPIKey != nil { - displayFieldsMap["ibm_api_key"] = displayFieldsItem.IBMAPIKey - } - if displayFieldsItem.AwsClientID != nil { - displayFieldsMap["aws_client_id"] = displayFieldsItem.AwsClientID - } - if displayFieldsItem.AwsClientSecret != nil { - displayFieldsMap["aws_client_secret"] = displayFieldsItem.AwsClientSecret - } - if displayFieldsItem.AwsRegion != nil { - displayFieldsMap["aws_region"] = displayFieldsItem.AwsRegion - } - if displayFieldsItem.AwsArn != nil { - displayFieldsMap["aws_arn"] = displayFieldsItem.AwsArn - } - if displayFieldsItem.Username != nil { - displayFieldsMap["username"] = displayFieldsItem.Username - } - if displayFieldsItem.Password != nil { - displayFieldsMap["password"] = displayFieldsItem.Password - } - if displayFieldsItem.AzureClientID != nil { - displayFieldsMap["azure_client_id"] = displayFieldsItem.AzureClientID - } - if displayFieldsItem.AzureClientSecret != nil { - displayFieldsMap["azure_client_secret"] = displayFieldsItem.AzureClientSecret - } - if displayFieldsItem.AzureSubscriptionID != nil { - displayFieldsMap["azure_subscription_id"] = displayFieldsItem.AzureSubscriptionID - } - if displayFieldsItem.AzureResourceGroup != nil { - displayFieldsMap["azure_resource_group"] = displayFieldsItem.AzureResourceGroup - } - if displayFieldsItem.DatabaseName != nil { - displayFieldsMap["database_name"] = displayFieldsItem.DatabaseName - } - if displayFieldsItem.WinrmAuthtype != nil { - displayFieldsMap["winrm_authtype"] = displayFieldsItem.WinrmAuthtype - } - if displayFieldsItem.WinrmUsessl != nil { - displayFieldsMap["winrm_usessl"] = displayFieldsItem.WinrmUsessl - } - if displayFieldsItem.WinrmPort != nil { - displayFieldsMap["winrm_port"] = displayFieldsItem.WinrmPort - } - if displayFieldsItem.Ms365ClientID != nil { - displayFieldsMap["ms_365_client_id"] = displayFieldsItem.Ms365ClientID - } - if displayFieldsItem.Ms365ClientSecret != nil { - displayFieldsMap["ms_365_client_secret"] = displayFieldsItem.Ms365ClientSecret - } - if displayFieldsItem.Ms365TenantID != nil { - displayFieldsMap["ms_365_tenant_id"] = displayFieldsItem.Ms365TenantID - } - if displayFieldsItem.AuthURL != nil { - displayFieldsMap["auth_url"] = displayFieldsItem.AuthURL - } - if displayFieldsItem.ProjectName != nil { - displayFieldsMap["project_name"] = displayFieldsItem.ProjectName - } - if displayFieldsItem.UserDomainName != nil { - displayFieldsMap["user_domain_name"] = displayFieldsItem.UserDomainName - } - if displayFieldsItem.ProjectDomainName != nil { - displayFieldsMap["project_domain_name"] = displayFieldsItem.ProjectDomainName - } - if displayFieldsItem.PemFileName != nil { - displayFieldsMap["pem_file_name"] = displayFieldsItem.PemFileName - } - if displayFieldsItem.PemData != nil { - displayFieldsMap["pem_data"] = displayFieldsItem.PemData - } - - return displayFieldsMap -} - -func dataSourceCredentialListGetNext(next interface{}) int64 { - if reflect.ValueOf(next).IsNil() { - return 0 - } - - u, err := url.Parse(reflect.ValueOf(next).Elem().FieldByName("Href").Elem().String()) - if err != nil { - return 0 - } - - q := u.Query() - var page string - - if q.Get("start") != "" { - page = q.Get("start") - } else if q.Get("offset") != "" { - page = q.Get("offset") - } - - convertedVal, err := strconv.ParseInt(page, 10, 64) - if err != nil { - return 0 - } - return convertedVal -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_credentials_test.go b/ibm/service/scc/data_source_ibm_scc_posture_credentials_test.go deleted file mode 100644 index 7283e84195..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_credentials_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureListCredentialsDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIBMSccPostureListCredentialsDataSourceConfigBasic(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credentials.list_credentials", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credentials.list_credentials", "first.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credentials.list_credentials", "last.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_credentials.list_credentials", "credentials.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureListCredentialsDataSourceConfigBasic() string { - return fmt.Sprintf(` - data "ibm_scc_posture_credentials" "list_credentials" { - } - `) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_group_profile.go b/ibm/service/scc/data_source_ibm_scc_posture_group_profile.go deleted file mode 100644 index 056844a96c..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_group_profile.go +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "net/url" - "reflect" - "strconv" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - //"github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureGroupProfileDetails() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureGroupProfileDetailsRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_group_profile is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "profile_id": { - Type: schema.TypeString, - Required: true, - Description: "The profile ID. This can be obtained from the Security and Compliance Center UI by clicking on the profile name. The URL contains the ID.", - }, - "first": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "controls": { - Type: schema.TypeList, - Computed: true, - Description: "Profiles array.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The identifier number of the control.", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "The description of the control.", - }, - "external_control_id": { - Type: schema.TypeString, - Computed: true, - Description: "The external identifier number of the control.", - }, - "goals": { - Type: schema.TypeList, - Computed: true, - Description: "Mapped goals aganist the control identifier.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - Description: "The description of the goal.", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The goal ID.", - }, - "severity": { - Type: schema.TypeString, - Computed: true, - Description: "The severity of the goal.", - }, - "is_manual": { - Type: schema.TypeBool, - Computed: true, - Description: "The goal is manual check.", - }, - "is_remediable": { - Type: schema.TypeBool, - Computed: true, - Description: "The goal is remediable or not.", - }, - "is_reversible": { - Type: schema.TypeBool, - Computed: true, - Description: "The goal is reversible or not.", - }, - "is_automatable": { - Type: schema.TypeBool, - Computed: true, - Description: "The goal is automatable or not.", - }, - "is_auto_remediable": { - Type: schema.TypeBool, - Computed: true, - Description: "The goal is autoremediable or not.", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureGroupProfileDetailsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getProfileControlsOptions := &posturemanagementv2.GetProfileControlsOptions{} - - getProfileControlsOptions.SetProfileID(d.Get("profile_id").(string)) - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getProfileControlsOptions.SetAccountID(accountID) - - var controlList *posturemanagementv2.ControlList - var offset int64 - finalList := []posturemanagementv2.ControlItem{} - - for { - - result, response, err := postureManagementClient.GetProfileControlsWithContext(context, getProfileControlsOptions) - controlList = result - if err != nil { - log.Printf("[DEBUG] GetProfileControlsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetProfileControlsWithContext failed %s\n%s", err, response)) - } - offset = dataSourceControlListGetNext(result.Next) - finalList = append(finalList, result.Controls...) - if offset == 0 { - break - } - } - - controlList.Controls = finalList - - d.SetId(dataSourceIBMSccPostureGroupProfileDetailsID(d)) - - if controlList.Controls != nil { - err = d.Set("controls", dataSourceControlListFlattenControls(controlList.Controls)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting controls %s", err)) - } - } - - return nil -} - -// dataSourceIBMGroupProfileDetailsID returns a reasonable ID for the list. -func dataSourceIBMSccPostureGroupProfileDetailsID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceControlListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceControlListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceControlListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceControlListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceControlListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceControlListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceControlListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceControlListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceControlListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceControlListFlattenControls(result []posturemanagementv2.ControlItem) (controls []map[string]interface{}) { - for _, controlsItem := range result { - controls = append(controls, dataSourceControlListControlsToMap(controlsItem)) - } - - return controls -} - -func dataSourceControlListControlsToMap(controlsItem posturemanagementv2.ControlItem) (controlsMap map[string]interface{}) { - controlsMap = map[string]interface{}{} - - if controlsItem.ID != nil { - controlsMap["id"] = controlsItem.ID - } - if controlsItem.Description != nil { - controlsMap["description"] = controlsItem.Description - } - if controlsItem.ExternalControlID != nil { - controlsMap["external_control_id"] = controlsItem.ExternalControlID - } - if controlsItem.Goals != nil { - goalsList := []map[string]interface{}{} - for _, goalsItem := range controlsItem.Goals { - goalsList = append(goalsList, dataSourceControlListControlsGoalsToMap(goalsItem)) - } - controlsMap["goals"] = goalsList - } - - return controlsMap -} - -func dataSourceControlListControlsGoalsToMap(goalsItem posturemanagementv2.GoalItem) (goalsMap map[string]interface{}) { - goalsMap = map[string]interface{}{} - - if goalsItem.Description != nil { - goalsMap["description"] = goalsItem.Description - } - if goalsItem.ID != nil { - goalsMap["id"] = goalsItem.ID - } - if goalsItem.Severity != nil { - goalsMap["severity"] = goalsItem.Severity - } - if goalsItem.IsManual != nil { - goalsMap["is_manual"] = goalsItem.IsManual - } - if goalsItem.IsRemediable != nil { - goalsMap["is_remediable"] = goalsItem.IsRemediable - } - if goalsItem.IsReversible != nil { - goalsMap["is_reversible"] = goalsItem.IsReversible - } - if goalsItem.IsAutomatable != nil { - goalsMap["is_automatable"] = goalsItem.IsAutomatable - } - if goalsItem.IsAutoRemediable != nil { - goalsMap["is_auto_remediable"] = goalsItem.IsAutoRemediable - } - - return goalsMap -} - -func dataSourceControlListGetNext(next interface{}) int64 { - if reflect.ValueOf(next).IsNil() { - return 0 - } - - u, err := url.Parse(reflect.ValueOf(next).Elem().FieldByName("Href").Elem().String()) - if err != nil { - return 0 - } - - q := u.Query() - var page string - - if q.Get("start") != "" { - page = q.Get("start") - } else if q.Get("offset") != "" { - page = q.Get("offset") - } - - convertedVal, err := strconv.ParseInt(page, 10, 64) - if err != nil { - return 0 - } - return convertedVal -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_group_profile_test.go b/ibm/service/scc/data_source_ibm_scc_posture_group_profile_test.go deleted file mode 100644 index f01bf5d3e8..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_group_profile_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureGroupProfileDetailsDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureGroupProfileDetailsDataSourceConfigBasic(acc.Scc_posture_group_profile_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_group_profile.group_profile_details", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_group_profile.group_profile_details", "profile_id"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureGroupProfileDetailsDataSourceConfigBasic(groupprofileId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_group_profile" "group_profile_details" { - profile_id = "%s" - } - `, groupprofileId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_latest_scans.go b/ibm/service/scc/data_source_ibm_scc_posture_latest_scans.go deleted file mode 100644 index bdbc4c7916..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_latest_scans.go +++ /dev/null @@ -1,508 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "net/url" - "reflect" - "strconv" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureLatestScans() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureListLatestScansRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_latest_scans is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "scan_id": { - Type: schema.TypeString, - Optional: true, - Description: "The ID of the scan.", - }, - "first": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "latest_scans": { - Type: schema.TypeList, - Computed: true, - Description: "The details of a scan.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "scan_id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the scan.", - }, - "scan_name": { - Type: schema.TypeString, - Computed: true, - Description: "A system generated name that is the combination of 12 characters in the scope name and 12 characters of a profile name.", - }, - "scope_id": { - Type: schema.TypeString, - Computed: true, - Description: "The scope ID of the scan.", - }, - "scope_name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the scope.", - }, - "profiles": { - Type: schema.TypeList, - Computed: true, - Description: "Profiles array.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the profile.", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "An auto-generated unique identifier for the scope.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile.", - }, - }, - }, - }, - "group_profile_id": { - Type: schema.TypeString, - Computed: true, - Description: "The group ID of profile.", - }, - "group_profile_name": { - Type: schema.TypeString, - Computed: true, - Description: "The group name of the profile.", - }, - "report_run_by": { - Type: schema.TypeString, - Computed: true, - Description: "The entity that ran the report.", - }, - "start_time": { - Type: schema.TypeString, - Computed: true, - Description: "The date and time the scan was run.", - }, - "report_setting_id": { - Type: schema.TypeString, - Computed: true, - Description: "The unique ID for Scan that is created.", - }, - "end_time": { - Type: schema.TypeString, - Computed: true, - Description: "The date and time the scan completed.", - }, - "result": { - Type: schema.TypeList, - Computed: true, - Description: "The result of a scan.The above values will not be avaialble if no scopes are available.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "goals_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that passed the scan.", - }, - "goals_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "goals_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "goals_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that failed the scan.", - }, - "goals_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of goals that were included in the scan.", - }, - "controls_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that passed the scan.", - }, - "controls_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that failed the scan.", - }, - "controls_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "controls_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "controls_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of controls that were included in the scan.", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureListLatestScansRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - listLatestScansOptions := &posturemanagementv2.ListLatestScansOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - listLatestScansOptions.SetAccountID(accountID) - - var scanList *posturemanagementv2.ScanList - var offset int64 - finalList := []posturemanagementv2.ScanItem{} - var scanID string - var suppliedFilter bool - - if v, ok := d.GetOk("scan_id"); ok { - scanID = v.(string) - suppliedFilter = true - } - - for { - listLatestScansOptions.Offset = &offset - - listLatestScansOptions.Limit = core.Int64Ptr(int64(100)) - result, response, err := postureManagementClient.ListLatestScansWithContext(context, listLatestScansOptions) - scanList = result - if err != nil { - log.Printf("[DEBUG] ListLatestScansWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ListLatestScansWithContext failed %s\n%s", err, response)) - } - offset = dataSourceScanListGetNext(result.Next) - if suppliedFilter { - for _, data := range result.LatestScans { - if *data.ScanID == scanID { - finalList = append(finalList, data) - } - } - } else { - finalList = append(finalList, result.LatestScans...) - } - if offset == 0 { - break - } - } - - scanList.LatestScans = finalList - - if suppliedFilter { - if len(scanList.LatestScans) == 0 { - return diag.FromErr(fmt.Errorf("no LatestScans found with scanID %s", scanID)) - } - d.SetId(scanID) - } else { - d.SetId(dataSourceIBMListLatestScansID(d)) - } - - if scanList.First != nil { - err = d.Set("first", dataSourceScanListFlattenFirst(*scanList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting first %s", err)) - } - } - - if scanList.Last != nil { - err = d.Set("last", dataSourceScanListFlattenLast(*scanList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last %s", err)) - } - } - - if scanList.Previous != nil { - err = d.Set("previous", dataSourceScanListFlattenPrevious(*scanList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting previous %s", err)) - } - } - - if scanList.LatestScans != nil { - err = d.Set("latest_scans", dataSourceScanListFlattenLatestScans(scanList.LatestScans)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting latest_scans %s", err)) - } - } - - return nil -} - -// dataSourceIBMListLatestScansID returns a reasonable ID for the list. -func dataSourceIBMListLatestScansID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceScanListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScanListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScanListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceScanListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScanListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScanListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceScanListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScanListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScanListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceScanListFlattenLatestScans(result []posturemanagementv2.ScanItem) (latestScans []map[string]interface{}) { - for _, latestScansItem := range result { - latestScans = append(latestScans, dataSourceScanListLatestScansToMap(latestScansItem)) - } - - return latestScans -} - -func dataSourceScanListLatestScansToMap(latestScansItem posturemanagementv2.ScanItem) (latestScansMap map[string]interface{}) { - latestScansMap = map[string]interface{}{} - - if latestScansItem.ScanID != nil { - latestScansMap["scan_id"] = latestScansItem.ScanID - } - if latestScansItem.ScanName != nil { - latestScansMap["scan_name"] = latestScansItem.ScanName - } - if latestScansItem.ScopeID != nil { - latestScansMap["scope_id"] = latestScansItem.ScopeID - } - if latestScansItem.ScopeName != nil { - latestScansMap["scope_name"] = latestScansItem.ScopeName - } - if latestScansItem.Profiles != nil { - profilesList := []map[string]interface{}{} - for _, profilesItem := range latestScansItem.Profiles { - profilesList = append(profilesList, dataSourceScanListLatestScansProfilesToMap(profilesItem)) - } - latestScansMap["profiles"] = profilesList - } - if latestScansItem.GroupProfileID != nil { - latestScansMap["group_profile_id"] = latestScansItem.GroupProfileID - } - if latestScansItem.GroupProfileName != nil { - latestScansMap["group_profile_name"] = latestScansItem.GroupProfileName - } - if latestScansItem.ReportRunBy != nil { - latestScansMap["report_run_by"] = latestScansItem.ReportRunBy - } - if latestScansItem.StartTime != nil { - latestScansMap["start_time"] = latestScansItem.StartTime.String() - } - if latestScansItem.ReportSettingID != nil { - latestScansMap["report_setting_id"] = latestScansItem.ReportSettingID - } - if latestScansItem.EndTime != nil { - latestScansMap["end_time"] = latestScansItem.EndTime.String() - } - if latestScansItem.Result != nil { - resultList := []map[string]interface{}{} - resultMap := dataSourceScanListLatestScansResultToMap(*latestScansItem.Result) - resultList = append(resultList, resultMap) - latestScansMap["result"] = resultList - } - - return latestScansMap -} - -func dataSourceScanListLatestScansProfilesToMap(profilesItem posturemanagementv2.ProfileItem) (profilesMap map[string]interface{}) { - profilesMap = map[string]interface{}{} - - if profilesItem.Name != nil { - profilesMap["name"] = profilesItem.Name - } - if profilesItem.ID != nil { - profilesMap["id"] = profilesItem.ID - } - if profilesItem.Type != nil { - profilesMap["type"] = profilesItem.Type - } - - return profilesMap -} - -func dataSourceScanListLatestScansResultToMap(resultItem posturemanagementv2.ScanResult) (resultMap map[string]interface{}) { - resultMap = map[string]interface{}{} - - if resultItem.GoalsPassCount != nil { - resultMap["goals_pass_count"] = resultItem.GoalsPassCount - } - if resultItem.GoalsUnableToPerformCount != nil { - resultMap["goals_unable_to_perform_count"] = resultItem.GoalsUnableToPerformCount - } - if resultItem.GoalsNotApplicableCount != nil { - resultMap["goals_not_applicable_count"] = resultItem.GoalsNotApplicableCount - } - if resultItem.GoalsFailCount != nil { - resultMap["goals_fail_count"] = resultItem.GoalsFailCount - } - if resultItem.GoalsTotalCount != nil { - resultMap["goals_total_count"] = resultItem.GoalsTotalCount - } - if resultItem.ControlsPassCount != nil { - resultMap["controls_pass_count"] = resultItem.ControlsPassCount - } - if resultItem.ControlsFailCount != nil { - resultMap["controls_fail_count"] = resultItem.ControlsFailCount - } - if resultItem.ControlsNotApplicableCount != nil { - resultMap["controls_not_applicable_count"] = resultItem.ControlsNotApplicableCount - } - if resultItem.ControlsUnableToPerformCount != nil { - resultMap["controls_unable_to_perform_count"] = resultItem.ControlsUnableToPerformCount - } - if resultItem.ControlsTotalCount != nil { - resultMap["controls_total_count"] = resultItem.ControlsTotalCount - } - - return resultMap -} - -func dataSourceScanListGetNext(next interface{}) int64 { - if reflect.ValueOf(next).IsNil() { - return 0 - } - - u, err := url.Parse(reflect.ValueOf(next).Elem().FieldByName("Href").Elem().String()) - if err != nil { - return 0 - } - - q := u.Query() - var page string - - if q.Get("start") != "" { - page = q.Get("start") - } else if q.Get("offset") != "" { - page = q.Get("offset") - } - - convertedVal, err := strconv.ParseInt(page, 10, 64) - if err != nil { - return 0 - } - return convertedVal -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_latest_scans_test.go b/ibm/service/scc/data_source_ibm_scc_posture_latest_scans_test.go deleted file mode 100644 index 6094b497de..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_latest_scans_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureListLatestScansDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureListLatestScansDataSourceConfigBasic(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_latest_scans.list_latest_scans", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_latest_scans.list_latest_scans", "first.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_latest_scans.list_latest_scans", "last.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_latest_scans.list_latest_scans", "latest_scans.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureListLatestScansDataSourceConfigBasic() string { - return ` - data "ibm_scc_posture_latest_scans" "list_latest_scans" { - } - ` -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_profile.go b/ibm/service/scc/data_source_ibm_scc_posture_profile.go deleted file mode 100644 index 8b95da2475..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_profile.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureProfileDetails() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureProfileDetailsRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_profile is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "profile_id": { - Type: schema.TypeString, - Required: true, - Description: "The id for the given API.", - }, - "profile_type": { - Type: schema.TypeString, - Required: true, - Description: "The profile type ID. This will be 4 for profiles and 6 for group profiles.", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the profile.", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "A description of the profile.", - }, - "version": { - Type: schema.TypeInt, - Computed: true, - Description: "The version of the profile.", - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who created the profile.", - }, - "modified_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who last modified the profile.", - }, - "reason_for_delete": { - Type: schema.TypeString, - Computed: true, - Description: "A reason that you want to delete a profile.", - }, - "base_profile": { - Type: schema.TypeString, - Computed: true, - Description: "The base profile that the controls are pulled from.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile.", - }, - "no_of_controls": { - Type: schema.TypeInt, - Computed: true, - Description: "no of Controls.", - }, - "created_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was created in UTC.", - }, - "updated_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was most recently modified in UTC.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "The profile status. If the profile is enabled, the value is true. If the profile is disabled, the value is false.", - }, - }, - } -} - -func dataSourceIBMSccPostureProfileDetailsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getProfileOptions := &posturemanagementv2.GetProfileOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getProfileOptions.SetAccountID(accountID) - - getProfileOptions.SetID(d.Get("profile_id").(string)) - getProfileOptions.SetProfileType(d.Get("profile_type").(string)) - - profile, response, err := postureManagementClient.GetProfileWithContext(context, getProfileOptions) - if err != nil { - log.Printf("[DEBUG] GetProfileWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetProfileWithContext failed %s\n%s", err, response)) - } - - d.SetId(*profile.ID) - if err = d.Set("name", profile.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) - } - if err = d.Set("description", profile.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) - } - if err = d.Set("version", flex.IntValue(profile.Version)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting version: %s", err)) - } - if err = d.Set("created_by", profile.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) - } - if err = d.Set("modified_by", profile.ModifiedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting modified_by: %s", err)) - } - if err = d.Set("reason_for_delete", profile.ReasonForDelete); err != nil { - return nil //return diag.FromErr(fmt.Errorf("[ERROR] Error setting reason_for_delete: %s", err)) - } - if err = d.Set("base_profile", profile.BaseProfile); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting base_profile: %s", err)) - } - if err = d.Set("type", profile.Type); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err)) - } - if err = d.Set("no_of_controls", flex.IntValue(profile.NoOfControls)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting no_of_controls: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(profile.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) - } - if err = d.Set("updated_at", flex.DateTimeToString(profile.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) - } - if err = d.Set("enabled", profile.Enabled); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting enabled: %s", err)) - } - - return nil -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_profile_test.go b/ibm/service/scc/data_source_ibm_scc_posture_profile_test.go deleted file mode 100644 index 60cbe6cdd6..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_profile_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureProfileDetailsDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureProfileDetailsDataSourceConfigBasic(acc.Scc_posture_profile_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "profile_type"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "name"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "version"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "created_by"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "modified_by"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "type"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "no_of_controls"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "created_at"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "updated_at"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profile.profile_details", "enabled"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureProfileDetailsDataSourceConfigBasic(profileId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_profile" "profile_details" { - profile_id = "%s" - profile_type = "authored" - } - `, profileId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_profiles.go b/ibm/service/scc/data_source_ibm_scc_posture_profiles.go deleted file mode 100644 index 8fda13de79..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_profiles.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "net/url" - "reflect" - "strconv" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureProfiles() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureListProfilesRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_profiles is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "first": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "profiles": { - Type: schema.TypeList, - Computed: true, - Description: "Profiles.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the profile.", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "A description of the profile.", - }, - "version": { - Type: schema.TypeInt, - Computed: true, - Description: "The version of the profile.", - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who created the profile.", - }, - "modified_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who last modified the profile.", - }, - "reason_for_delete": { - Type: schema.TypeString, - Computed: true, - Description: "A reason that you want to delete a profile.", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "An auto-generated unique identifying number of the profile.", - }, - "base_profile": { - Type: schema.TypeString, - Computed: true, - Description: "The base profile that the controls are pulled from.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile.", - }, - "no_of_controls": { - Type: schema.TypeInt, - Computed: true, - Description: "no of Controls.", - }, - "created_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was created in UTC.", - }, - "updated_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was most recently modified in UTC.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "The profile status. If the profile is enabled, the value is true. If the profile is disabled, the value is false.", - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureListProfilesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - listProfilesOptions := &posturemanagementv2.ListProfilesOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - listProfilesOptions.SetAccountID(accountID) - - var profileList *posturemanagementv2.ProfileList - var offset int64 - finalList := []posturemanagementv2.Profile{} - - for { - listProfilesOptions.Offset = &offset - - listProfilesOptions.Limit = core.Int64Ptr(int64(100)) - result, response, err := postureManagementClient.ListProfilesWithContext(context, listProfilesOptions) - profileList = result - if err != nil { - log.Printf("[DEBUG] ListProfilesWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ListProfilesWithContext failed %s\n%s", err, response)) - } - offset = dataSourceProfileListGetNext(result.Next) - finalList = append(finalList, result.Profiles...) - if offset == 0 { - break - } - } - - profileList.Profiles = finalList - - d.SetId(dataSourceIBMSccPostureListProfilesID(d)) - - if profileList.First != nil { - err = d.Set("first", dataSourceProfileListFlattenFirst(*profileList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting first %s", err)) - } - } - - if profileList.Last != nil { - err = d.Set("last", dataSourceProfileListFlattenLast(*profileList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last %s", err)) - } - } - - if profileList.Previous != nil { - err = d.Set("previous", dataSourceProfileListFlattenPrevious(*profileList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting previous %s", err)) - } - } - - if profileList.Profiles != nil { - err = d.Set("profiles", dataSourceProfileListFlattenProfiles(profileList.Profiles)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting profiles %s", err)) - } - } - - return nil -} - -// dataSourceIBMListProfilesID returns a reasonable ID for the list. -func dataSourceIBMSccPostureListProfilesID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceProfileListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceProfileListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceProfileListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceProfileListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceProfileListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceProfileListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceProfileListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceProfileListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceProfileListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceProfileListFlattenProfiles(result []posturemanagementv2.Profile) (profiles []map[string]interface{}) { - for _, profilesItem := range result { - profiles = append(profiles, dataSourceProfileListProfilesToMap(profilesItem)) - } - - return profiles -} - -func dataSourceProfileListProfilesToMap(profilesItem posturemanagementv2.Profile) (profilesMap map[string]interface{}) { - profilesMap = map[string]interface{}{} - - if profilesItem.Name != nil { - profilesMap["name"] = profilesItem.Name - } - if profilesItem.Description != nil { - profilesMap["description"] = profilesItem.Description - } - if profilesItem.Version != nil { - profilesMap["version"] = profilesItem.Version - } - if profilesItem.CreatedBy != nil { - profilesMap["created_by"] = profilesItem.CreatedBy - } - if profilesItem.ModifiedBy != nil { - profilesMap["modified_by"] = profilesItem.ModifiedBy - } - if profilesItem.ReasonForDelete != nil { - profilesMap["reason_for_delete"] = profilesItem.ReasonForDelete - } - if profilesItem.ID != nil { - profilesMap["id"] = profilesItem.ID - } - if profilesItem.BaseProfile != nil { - profilesMap["base_profile"] = profilesItem.BaseProfile - } - if profilesItem.Type != nil { - profilesMap["type"] = profilesItem.Type - } - if profilesItem.NoOfControls != nil { - profilesMap["no_of_controls"] = profilesItem.NoOfControls - } - if profilesItem.CreatedAt != nil { - profilesMap["created_at"] = profilesItem.CreatedAt.String() - } - if profilesItem.UpdatedAt != nil { - profilesMap["updated_at"] = profilesItem.UpdatedAt.String() - } - if profilesItem.Enabled != nil { - profilesMap["enabled"] = profilesItem.Enabled - } - - return profilesMap -} - -func dataSourceProfileListGetNext(next interface{}) int64 { - if reflect.ValueOf(next).IsNil() { - return 0 - } - - u, err := url.Parse(reflect.ValueOf(next).Elem().FieldByName("Href").Elem().String()) - if err != nil { - return 0 - } - - q := u.Query() - var page string - - if q.Get("start") != "" { - page = q.Get("start") - } else if q.Get("offset") != "" { - page = q.Get("offset") - } - - convertedVal, err := strconv.ParseInt(page, 10, 64) - if err != nil { - return 0 - } - return convertedVal -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_profiles_test.go b/ibm/service/scc/data_source_ibm_scc_posture_profiles_test.go deleted file mode 100644 index e7e3d2e030..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_profiles_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureListProfilesDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureListProfilesDataSourceConfigBasic(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profiles.list_profiles", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profiles.list_profiles", "first.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profiles.list_profiles", "last.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_profiles.list_profiles", "profiles.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureListProfilesDataSourceConfigBasic() string { - return ` - data "ibm_scc_posture_profiles" "list_profiles" { - } - ` -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries.go b/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries.go deleted file mode 100644 index 24540784b6..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries.go +++ /dev/null @@ -1,621 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "net/url" - "reflect" - "strconv" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureScanSummaries() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureScanSummariesRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_scan_summaries is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "report_setting_id": { - Type: schema.TypeString, - Required: true, - Description: "The report setting ID. This can be obtained from the /validations/latest_scans API call.", - }, - "first": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "summaries": { - Type: schema.TypeList, - Computed: true, - Description: "Summaries.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the scan.", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "A system generated name that is the combination of 12 characters in the scope name and 12 characters of a profile name.", - }, - "scope_id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the scope.", - }, - "scope_name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the scope.", - }, - "report_run_by": { - Type: schema.TypeString, - Computed: true, - Description: "The entity that ran the report.", - }, - "start_time": { - Type: schema.TypeString, - Computed: true, - Description: "The date and time the scan was run.", - }, - "end_time": { - Type: schema.TypeString, - Computed: true, - Description: "The date and time the scan completed.", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "The status of the collector as it completes a scan.", - }, - "profiles": { - Type: schema.TypeList, - Computed: true, - Description: "The list of profiles.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the profile.", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the profile.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile. To learn more about profile types, check out the [docs] (https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-profiles).", - }, - "validation_result": { - Type: schema.TypeList, - Computed: true, - Description: "The result of a scan.The above values will not be avaialble if no scopes are available.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "goals_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that passed the scan.", - }, - "goals_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "goals_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "goals_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that failed the scan.", - }, - "goals_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of goals that were included in the scan.", - }, - "controls_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that passed the scan.", - }, - "controls_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that failed the scan.", - }, - "controls_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "controls_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "controls_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of controls that were included in the scan.", - }, - }, - }, - }, - }, - }, - }, - "group_profiles": { - Type: schema.TypeList, - Computed: true, - Description: "The list of group profiles.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the profile.", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the profile.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile. To learn more about profile types, check out the [docs] (https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-profiles).", - }, - "validation_result": { - Type: schema.TypeList, - Computed: true, - Description: "The result of a scan.The above values will not be avaialble if no scopes are available.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "goals_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that passed the scan.", - }, - "goals_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "goals_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "goals_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of goals that failed the scan.", - }, - "goals_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of goals that were included in the scan.", - }, - "controls_pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that passed the scan.", - }, - "controls_fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that failed the scan.", - }, - "controls_not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found.", - }, - "controls_unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected.", - }, - "controls_total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of controls that were included in the scan.", - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureScanSummariesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - scanSummariesOptions := &posturemanagementv2.ScanSummariesOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - scanSummariesOptions.SetAccountID(accountID) - - scanSummariesOptions.SetReportSettingID(d.Get("report_setting_id").(string)) - - var summaryList *posturemanagementv2.SummaryList - var offset int64 - finalList := []posturemanagementv2.SummaryItem{} - - for { - scanSummariesOptions.Offset = &offset - - scanSummariesOptions.Limit = core.Int64Ptr(int64(100)) - result, response, err := postureManagementClient.ScanSummariesWithContext(context, scanSummariesOptions) - summaryList = result - if err != nil { - log.Printf("[DEBUG] ScanSummariesWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ScanSummariesWithContext failed %s\n%s", err, response)) - } - offset = dataSourceSummaryListGetNext(result.Next) - finalList = append(finalList, result.Summaries...) - if offset == 0 { - break - } - } - - summaryList.Summaries = finalList - - d.SetId(dataSourceIBMSccPostureScanSummariesID(d)) - - if summaryList.First != nil { - err = d.Set("first", dataSourceSummaryListFlattenFirst(*summaryList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting first %s", err)) - } - } - - if summaryList.Last != nil { - err = d.Set("last", dataSourceSummaryListFlattenLast(*summaryList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last %s", err)) - } - } - - if summaryList.Previous != nil { - err = d.Set("previous", dataSourceSummaryListFlattenPrevious(*summaryList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting previous %s", err)) - } - } - - if summaryList.Summaries != nil { - err = d.Set("summaries", dataSourceSummaryListFlattenSummaries(summaryList.Summaries)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting summaries %s", err)) - } - } - - return nil -} - -// dataSourceIBMScanSummariesID returns a reasonable ID for the list. -func dataSourceIBMSccPostureScanSummariesID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceSummaryListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceSummaryListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceSummaryListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceSummaryListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceSummaryListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceSummaryListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceSummaryListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceSummaryListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceSummaryListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceSummaryListFlattenSummaries(result []posturemanagementv2.SummaryItem) (summaries []map[string]interface{}) { - for _, summariesItem := range result { - summaries = append(summaries, dataSourceSummaryListSummariesToMap(summariesItem)) - } - - return summaries -} - -func dataSourceSummaryListSummariesToMap(summariesItem posturemanagementv2.SummaryItem) (summariesMap map[string]interface{}) { - summariesMap = map[string]interface{}{} - - if summariesItem.ID != nil { - summariesMap["id"] = summariesItem.ID - } - if summariesItem.Name != nil { - summariesMap["name"] = summariesItem.Name - } - if summariesItem.ScopeID != nil { - summariesMap["scope_id"] = summariesItem.ScopeID - } - if summariesItem.ScopeName != nil { - summariesMap["scope_name"] = summariesItem.ScopeName - } - if summariesItem.ReportRunBy != nil { - summariesMap["report_run_by"] = summariesItem.ReportRunBy - } - if summariesItem.StartTime != nil { - summariesMap["start_time"] = summariesItem.StartTime.String() - } - if summariesItem.EndTime != nil { - summariesMap["end_time"] = summariesItem.EndTime.String() - } - if summariesItem.Status != nil { - summariesMap["status"] = summariesItem.Status - } - if summariesItem.Profiles != nil { - profilesList := []map[string]interface{}{} - for _, profilesItem := range summariesItem.Profiles { - profilesList = append(profilesList, dataSourceSummaryListSummariesProfilesToMap(profilesItem)) - } - summariesMap["profiles"] = profilesList - } - if summariesItem.GroupProfiles != nil { - groupProfilesList := []map[string]interface{}{} - for _, groupProfilesItem := range summariesItem.GroupProfiles { - groupProfilesList = append(groupProfilesList, dataSourceSummaryListSummariesGroupProfilesToMap(groupProfilesItem)) - } - summariesMap["group_profiles"] = groupProfilesList - } - - return summariesMap -} - -func dataSourceSummaryListSummariesProfilesToMap(profilesItem posturemanagementv2.ProfileResult) (profilesMap map[string]interface{}) { - profilesMap = map[string]interface{}{} - - if profilesItem.ID != nil { - profilesMap["id"] = profilesItem.ID - } - if profilesItem.Name != nil { - profilesMap["name"] = profilesItem.Name - } - if profilesItem.Type != nil { - profilesMap["type"] = profilesItem.Type - } - if profilesItem.ValidationResult != nil { - validationResultList := []map[string]interface{}{} - validationResultMap := dataSourceSummaryListProfilesValidationResultToMap(*profilesItem.ValidationResult) - validationResultList = append(validationResultList, validationResultMap) - profilesMap["validation_result"] = validationResultList - } - - return profilesMap -} - -func dataSourceSummaryListProfilesValidationResultToMap(validationResultItem posturemanagementv2.ScanResult) (validationResultMap map[string]interface{}) { - validationResultMap = map[string]interface{}{} - - if validationResultItem.GoalsPassCount != nil { - validationResultMap["goals_pass_count"] = validationResultItem.GoalsPassCount - } - if validationResultItem.GoalsUnableToPerformCount != nil { - validationResultMap["goals_unable_to_perform_count"] = validationResultItem.GoalsUnableToPerformCount - } - if validationResultItem.GoalsNotApplicableCount != nil { - validationResultMap["goals_not_applicable_count"] = validationResultItem.GoalsNotApplicableCount - } - if validationResultItem.GoalsFailCount != nil { - validationResultMap["goals_fail_count"] = validationResultItem.GoalsFailCount - } - if validationResultItem.GoalsTotalCount != nil { - validationResultMap["goals_total_count"] = validationResultItem.GoalsTotalCount - } - if validationResultItem.ControlsPassCount != nil { - validationResultMap["controls_pass_count"] = validationResultItem.ControlsPassCount - } - if validationResultItem.ControlsFailCount != nil { - validationResultMap["controls_fail_count"] = validationResultItem.ControlsFailCount - } - if validationResultItem.ControlsNotApplicableCount != nil { - validationResultMap["controls_not_applicable_count"] = validationResultItem.ControlsNotApplicableCount - } - if validationResultItem.ControlsUnableToPerformCount != nil { - validationResultMap["controls_unable_to_perform_count"] = validationResultItem.ControlsUnableToPerformCount - } - if validationResultItem.ControlsTotalCount != nil { - validationResultMap["controls_total_count"] = validationResultItem.ControlsTotalCount - } - - return validationResultMap -} - -func dataSourceSummaryListSummariesGroupProfilesToMap(groupProfilesItem posturemanagementv2.ProfileResult) (groupProfilesMap map[string]interface{}) { - groupProfilesMap = map[string]interface{}{} - - if groupProfilesItem.ID != nil { - groupProfilesMap["id"] = groupProfilesItem.ID - } - if groupProfilesItem.Name != nil { - groupProfilesMap["name"] = groupProfilesItem.Name - } - if groupProfilesItem.Type != nil { - groupProfilesMap["type"] = groupProfilesItem.Type - } - if groupProfilesItem.ValidationResult != nil { - validationResultList := []map[string]interface{}{} - validationResultMap := dataSourceSummaryListGroupProfilesValidationResultToMap(*groupProfilesItem.ValidationResult) - validationResultList = append(validationResultList, validationResultMap) - groupProfilesMap["validation_result"] = validationResultList - } - - return groupProfilesMap -} - -func dataSourceSummaryListGroupProfilesValidationResultToMap(validationResultItem posturemanagementv2.ScanResult) (validationResultMap map[string]interface{}) { - validationResultMap = map[string]interface{}{} - - if validationResultItem.GoalsPassCount != nil { - validationResultMap["goals_pass_count"] = validationResultItem.GoalsPassCount - } - if validationResultItem.GoalsUnableToPerformCount != nil { - validationResultMap["goals_unable_to_perform_count"] = validationResultItem.GoalsUnableToPerformCount - } - if validationResultItem.GoalsNotApplicableCount != nil { - validationResultMap["goals_not_applicable_count"] = validationResultItem.GoalsNotApplicableCount - } - if validationResultItem.GoalsFailCount != nil { - validationResultMap["goals_fail_count"] = validationResultItem.GoalsFailCount - } - if validationResultItem.GoalsTotalCount != nil { - validationResultMap["goals_total_count"] = validationResultItem.GoalsTotalCount - } - if validationResultItem.ControlsPassCount != nil { - validationResultMap["controls_pass_count"] = validationResultItem.ControlsPassCount - } - if validationResultItem.ControlsFailCount != nil { - validationResultMap["controls_fail_count"] = validationResultItem.ControlsFailCount - } - if validationResultItem.ControlsNotApplicableCount != nil { - validationResultMap["controls_not_applicable_count"] = validationResultItem.ControlsNotApplicableCount - } - if validationResultItem.ControlsUnableToPerformCount != nil { - validationResultMap["controls_unable_to_perform_count"] = validationResultItem.ControlsUnableToPerformCount - } - if validationResultItem.ControlsTotalCount != nil { - validationResultMap["controls_total_count"] = validationResultItem.ControlsTotalCount - } - - return validationResultMap -} - -func dataSourceSummaryListGetNext(next interface{}) int64 { - if reflect.ValueOf(next).IsNil() { - return 0 - } - - u, err := url.Parse(reflect.ValueOf(next).Elem().FieldByName("Href").Elem().String()) - if err != nil { - return 0 - } - - q := u.Query() - var page string - - if q.Get("start") != "" { - page = q.Get("start") - } else if q.Get("offset") != "" { - page = q.Get("offset") - } - - convertedVal, err := strconv.ParseInt(page, 10, 64) - if err != nil { - return 0 - } - return convertedVal -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries_test.go b/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries_test.go deleted file mode 100644 index 675de220ca..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scan_summaries_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureScanSummariesDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureScanSummariesDataSourceConfigBasic(acc.Scc_posture_report_setting_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summaries.scan_summaries", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summaries.scan_summaries", "report_setting_id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summaries.scan_summaries", "summaries.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureScanSummariesDataSourceConfigBasic(report_setting_id string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_scan_summaries" "scan_summaries" { - report_setting_id = "%s" - } - `, report_setting_id) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scan_summary.go b/ibm/service/scc/data_source_ibm_scc_posture_scan_summary.go deleted file mode 100644 index 5105c4cf0b..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scan_summary.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureScansSummary() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureScansSummaryRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_scan_summary is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "scan_id": { - Type: schema.TypeString, - Required: true, - Description: "Your Scan ID.", - }, - "profile_id": { - Type: schema.TypeString, - Required: true, - Description: "The profile ID. This can be obtained from the Security and Compliance Center UI by clicking on the profile name. The URL contains the ID.", - }, - "discover_id": { - Type: schema.TypeString, - Computed: true, - Description: "The scan discovery ID.", - }, - "profile_name": { - Type: schema.TypeString, - Computed: true, - Description: "The scan profile name.", - }, - "scope_id": { - Type: schema.TypeString, - Computed: true, - Description: "The scan summary scope ID.", - }, - "controls": { - Type: schema.TypeList, - Computed: true, - Description: "The list of controls on the scan summary.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The scan summary control ID.", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "The control status.", - }, - "external_control_id": { - Type: schema.TypeString, - Computed: true, - Description: "The external control ID.", - }, - "desciption": { - Type: schema.TypeString, - Computed: true, - Description: "The scan profile name.", - }, - "goals": { - Type: schema.TypeList, - Computed: true, - Description: "The list of goals on the control.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - Description: "The description of the goal.", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The goal ID.", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "The goal status.", - }, - "severity": { - Type: schema.TypeString, - Computed: true, - Description: "The severity of the goal.", - }, - "completed_time": { - Type: schema.TypeString, - Computed: true, - Description: "The report completed time.", - }, - "error": { - Type: schema.TypeString, - Computed: true, - Description: "The error on goal validation.", - }, - "resource_result": { - Type: schema.TypeList, - Computed: true, - Description: "The list of resource results.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The resource name.", - }, - "types": { - Type: schema.TypeString, - Computed: true, - Description: "The resource type.", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "The resource control result status.", - }, - "display_expected_value": { - Type: schema.TypeString, - Computed: true, - Description: "The expected results of a resource.", - }, - "actual_value": { - Type: schema.TypeString, - Computed: true, - Description: "The actual results of a resource.", - }, - "results_info": { - Type: schema.TypeString, - Computed: true, - Description: "The results information.", - }, - "not_applicable_reason": { - Type: schema.TypeString, - Computed: true, - Description: "The reason for goal not applicable for a resource.", - }, - }, - }, - }, - }, - }, - }, - "resource_statistics": { - Type: schema.TypeList, - Computed: true, - Description: "A scans summary controls.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pass_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The resource count of pass controls.", - }, - "fail_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The resource count of fail controls.", - }, - "unable_to_perform_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of resources that were unable to be scanned against a control.", - }, - "not_applicable_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The resource count of not applicable(na) controls.", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureScansSummaryRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - scansSummaryOptions := &posturemanagementv2.ScansSummaryOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - scansSummaryOptions.SetAccountID(accountID) - - scansSummaryOptions.SetScanID(d.Get("scan_id").(string)) - scansSummaryOptions.SetProfileID(d.Get("profile_id").(string)) - - summary, response, err := postureManagementClient.ScansSummaryWithContext(context, scansSummaryOptions) - if err != nil { - log.Printf("[DEBUG] ScansSummaryWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ScansSummaryWithContext failed %s\n%s", err, response)) - } - - d.SetId(*summary.ID) - - if err = d.Set("discover_id", summary.DiscoverID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting discover_id: %s", err)) - } - if err = d.Set("profile_name", summary.ProfileName); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting profile_name: %s", err)) - } - if err = d.Set("scope_id", summary.ScopeID); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting scope_id: %s", err)) - } - - if summary.Controls != nil { - err = d.Set("controls", dataSourceSummaryFlattenControlsv2(summary.Controls)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting controls %s", err)) - } - } - - return nil -} - -func dataSourceSummaryFlattenControlsv2(result []posturemanagementv2.Control) (controls []map[string]interface{}) { - for _, controlsItem := range result { - controls = append(controls, dataSourceSummaryControlsToMapv2(controlsItem)) - } - - return controls -} - -func dataSourceSummaryControlsToMapv2(controlsItem posturemanagementv2.Control) (controlsMap map[string]interface{}) { - controlsMap = map[string]interface{}{} - - if controlsItem.ID != nil { - controlsMap["id"] = controlsItem.ID - } - if controlsItem.Status != nil { - controlsMap["status"] = controlsItem.Status - } - if controlsItem.ExternalControlID != nil { - controlsMap["external_control_id"] = controlsItem.ExternalControlID - } - if controlsItem.Description != nil { - controlsMap["description"] = controlsItem.Description - } - if controlsItem.Goals != nil { - goalsList := []map[string]interface{}{} - for _, goalsItem := range controlsItem.Goals { - goalsList = append(goalsList, dataSourceSummaryControlsGoalsToMapv2(goalsItem)) - } - controlsMap["goals"] = goalsList - } - if controlsItem.ResourceStatistics != nil { - resourceStatisticsList := []map[string]interface{}{} - resourceStatisticsMap := dataSourceSummaryControlsResourceStatisticsToMapv2(*controlsItem.ResourceStatistics) - resourceStatisticsList = append(resourceStatisticsList, resourceStatisticsMap) - controlsMap["resource_statistics"] = resourceStatisticsList - } - - return controlsMap -} - -func dataSourceSummaryControlsGoalsToMapv2(goalsItem posturemanagementv2.Goal) (goalsMap map[string]interface{}) { - goalsMap = map[string]interface{}{} - - if goalsItem.Description != nil { - goalsMap["description"] = goalsItem.Description - } - if goalsItem.ID != nil { - goalsMap["id"] = goalsItem.ID - } - if goalsItem.Status != nil { - goalsMap["status"] = goalsItem.Status - } - if goalsItem.Severity != nil { - goalsMap["severity"] = goalsItem.Severity - } - if goalsItem.CompletedTime != nil { - goalsMap["completed_time"] = goalsItem.CompletedTime.String() - } - if goalsItem.Error != nil { - goalsMap["error"] = goalsItem.Error - } - if goalsItem.ResourceResult != nil { - resourceResultList := []map[string]interface{}{} - for _, resourceResultItem := range goalsItem.ResourceResult { - resourceResultList = append(resourceResultList, dataSourceSummaryGoalsResourceResultToMapv2(resourceResultItem)) - } - goalsMap["resource_result"] = resourceResultList - } - - return goalsMap -} - -func dataSourceSummaryGoalsResourceResultToMapv2(resourceResultItem posturemanagementv2.ResourceResult) (resourceResultMap map[string]interface{}) { - resourceResultMap = map[string]interface{}{} - - if resourceResultItem.Name != nil { - resourceResultMap["name"] = resourceResultItem.Name - } - if resourceResultItem.Types != nil { - resourceResultMap["types"] = resourceResultItem.Types - } - if resourceResultItem.Status != nil { - resourceResultMap["status"] = resourceResultItem.Status - } - if resourceResultItem.DisplayExpectedValue != nil { - resourceResultMap["display_expected_value"] = resourceResultItem.DisplayExpectedValue - } - if resourceResultItem.ActualValue != nil { - resourceResultMap["actual_value"] = resourceResultItem.ActualValue - } - if resourceResultItem.ResultsInfo != nil { - resourceResultMap["results_info"] = resourceResultItem.ResultsInfo - } - if resourceResultItem.NotApplicableReason != nil { - resourceResultMap["not_applicable_reason"] = resourceResultItem.NotApplicableReason - } - - return resourceResultMap -} - -func dataSourceSummaryControlsResourceStatisticsToMapv2(resourceStatisticsItem posturemanagementv2.ResourceStatistics) (resourceStatisticsMap map[string]interface{}) { - resourceStatisticsMap = map[string]interface{}{} - - if resourceStatisticsItem.PassCount != nil { - resourceStatisticsMap["pass_count"] = resourceStatisticsItem.PassCount - } - if resourceStatisticsItem.FailCount != nil { - resourceStatisticsMap["fail_count"] = resourceStatisticsItem.FailCount - } - if resourceStatisticsItem.UnableToPerformCount != nil { - resourceStatisticsMap["unable_to_perform_count"] = resourceStatisticsItem.UnableToPerformCount - } - if resourceStatisticsItem.NotApplicableCount != nil { - resourceStatisticsMap["not_applicable_count"] = resourceStatisticsItem.NotApplicableCount - } - - return resourceStatisticsMap -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scan_summary_test.go b/ibm/service/scc/data_source_ibm_scc_posture_scan_summary_test.go deleted file mode 100644 index 6686df68ba..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scan_summary_test.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureScansSummaryDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureScansSummaryDataSourceConfigBasic(acc.Scc_posture_scan_id_scansummary, acc.Scc_posture_profile_id_scansummary), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summary.scans_summary", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summary.scans_summary", "scan_id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scan_summary.scans_summary", "profile_id"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureScansSummaryDataSourceConfigBasic(scanId string, profileId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_scan_summary" "scans_summary" { - scan_id = "%s" - profile_id = "%s" - } - `, scanId, profileId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scope.go b/ibm/service/scc/data_source_ibm_scc_posture_scope.go deleted file mode 100644 index f8b3560723..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scope.go +++ /dev/null @@ -1,1372 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureScope() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureScopeRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_scope is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "scope_id": &schema.Schema{ - Type: schema.TypeString, - Required: true, - Description: "The id for the given API.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_name .", - }, - "uuid": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_uuid .Will be displayed only when value exists.", - }, - "partner_uuid": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of partner_uuid .Will be displayed only when value exists.", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_description .Will be displayed only when value exists.", - }, - "org_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_org_id .Will be displayed only when value exists.", - }, - "cloud_type_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_cloud_type_id .Will be displayed only when value exists.", - }, - "tld_credential_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_tld_credential_id .Will be displayed only when value exists.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_status .Will be displayed only when value exists.", - }, - "status_msg": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_status_msg .Will be displayed only when value exists.", - }, - "subset_selected": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_subset_selected .Will be displayed only when value exists.", - }, - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_enabled .Will be displayed only when value exists.", - }, - "last_discover_start_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_last_discover_start_time .Will be displayed only when value exists.", - }, - "last_discover_completed_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_last_discover_completed_time .Will be displayed only when value exists.", - }, - "last_successful_discover_start_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_last_successful_discover_start_time .Will be displayed only when value exists.", - }, - "last_successful_discover_completed_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_last_successful_discover_completed_time .Will be displayed only when value exists.", - }, - "task_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_task_type .Will be displayed only when value exists.", - }, - "tasks": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of scope_tasks .Will be displayed only when value exists.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "task_logs": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of task_logs .", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "task_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_id .", - }, - "task_gateway_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_gateway_id .", - }, - "task_gateway_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_gateway_name .", - }, - "task_task_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_task_type .", - }, - "task_gateway_schema_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_gateway_schema_id .", - }, - "task_schema_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_schema_name .", - }, - "task_discover_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_discover_id .", - }, - "task_status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_status .", - }, - "task_status_msg": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_status_msg .", - }, - "task_start_time": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_start_time .", - }, - "task_updated_time": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of task_updated_time .", - }, - "task_derived_status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_derived_status .", - }, - "task_created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of task_created_by .", - }, - }, - }, - }, - "status_updated_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_status_updated_time .Will be displayed only when value exists.", - }, - "collectors_by_type": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of collectors_by_type .Will be displayed only when value exists.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "credentials_by_type": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_credentials_by_type .Will be displayed only when value exists.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "credentials_by_sub_categeory_type": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_credentials_by_sub_categeory_type .Will be displayed only when value exists.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "sub_categories_by_type": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_sub_categories_by_type .Will be displayed only when value exists.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "resource_groups": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_resource_groups .Will be displayed only when value exists.", - }, - "region_names": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_region_names .Will be displayed only when value exists.", - }, - "cloud_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_cloud_type .Will be displayed only when value exists.", - }, - "env_sub_category": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_env_sub_category .Will be displayed only when value exists.", - }, - "tld_credentail": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of ScopeDetailsCredential .", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "credential_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_id .", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_name .", - }, - "uuid": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_uuid .", - }, - "credential_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_type .", - }, - "data": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of credential_data .", - }, - "display_fields": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Details the fields on the credential. This will change as per credential type selected.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ibm_api_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The IBM Cloud API Key. This is mandatory for IBM Credential Type.", - }, - "aws_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS client Id.This is mandatory for AWS Cloud.", - }, - "aws_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS client secret.This is mandatory for AWS Cloud.", - }, - "aws_region": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS region.", - }, - "aws_arn": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "AWS arn value.", - }, - "username": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "password": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials.", - }, - "azure_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure client Id. This is mandatory for Azure Credential type.", - }, - "azure_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure client secret.This is mandatory for Azure Credential type.", - }, - "azure_subscription_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure subscription Id.This is mandatory for Azure Credential type.", - }, - "azure_resource_group": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Azure resource group.", - }, - "database_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Database name.This is mandatory for Database Credential type.", - }, - "winrm_authtype": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_usessl": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type.", - }, - "winrm_port": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Kerberos windows port.This is mandatory for Windows Kerberos Credential type.", - }, - "ms_365_client_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 client Id.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_client_secret": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 client secret.This is mandatory for Windows MS365 Credential type.", - }, - "ms_365_tenant_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The MS365 tenantId.This is mandatory for Windows MS365 Credential type.", - }, - "auth_url": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "user_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "project_domain_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type.", - }, - "pem_file_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the PEM file.", - }, - "pem_data": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The base64 encoded data to associate with the PEM file.", - }, - }, - }, - }, - "version_timestamp": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of credential_version_timestamp .", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_description .", - }, - "is_enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of credential_is_enabled .", - }, - "gateway_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_gateway_key .", - }, - "purpose": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of credential_purpose .", - }, - }, - }, - }, - "collectors": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of collectors .Will be displayed only when value exists.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "collector_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the collector.", - }, - "display_name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The user-friendly name of the collector.", - }, - "name": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The name of the collector.", - }, - "public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed.", - }, - "last_heartbeat": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the heartbeat time of a controller . This value exists when collector is installed and running.", - }, - "status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The status of collector.", - }, - "collector_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector version. This field is populated when collector is installed.", - }, - "image_version": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The image version of the collector. This field is populated when collector is installed. \".", - }, - "description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The description of the collector.", - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that created the collector.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was created.", - }, - "updated_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that modified the collector.", - }, - "updated_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was modified.", - }, - "enabled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Identifies whether the collector is enabled or not(deleted).", - }, - "registration_code": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The registration code of the collector.This is will be used for initial authentication during installation of collector.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The type of the collector.", - }, - "credential_public_key": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The credential public key.", - }, - "failure_count": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "The number of times the collector has failed.", - }, - "approved_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved local gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "approved_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The approved internet gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "last_failed_local_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed local gateway ip. This field will be populated only when collector is installed.", - }, - "reset_reason": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field .", - }, - "hostname": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name.", - }, - "install_path": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The installation path of the collector. This field will be populated when collector is installed.The value will be folder path.", - }, - "use_private_endpoint": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false.", - }, - "managed_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The entity that manages the collector.", - }, - "trial_expiry": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed.", - }, - "last_failed_internet_gateway_ip": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The failed internet gateway ip of the collector.", - }, - "status_description": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The collector status.", - }, - "reset_time": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field.", - }, - "is_public": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network.", - }, - "is_ubi_image": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector has a Ubi image.", - }, - }, - }, - }, - "first_level_scoped_data": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of scope_first_level_scoped_data .Will be displayed only when value exists.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "scope_object": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_object .", - }, - "scope_init_scope": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_init_scope .", - }, - "scope": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope .", - }, - "scope_changed": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_changed .", - }, - "scope_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_id .", - }, - "scope_properties": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_properties .", - }, - "scope_overlay": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_overlay .", - }, - "scope_new_found": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_new_found .", - }, - "scope_discovery_status": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_discovery_status .", - }, - "scope_fact_status": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_fact_status .", - }, - "scope_facts": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_facts .", - }, - "scope_list_members": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_list_members .", - }, - "scope_children": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_children .", - }, - "scope_resource_category": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_resource_category .", - }, - "scope_resource_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_resource_type .", - }, - "scope_resource": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_resource .", - }, - "scope_resource_attributes": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_resource_attributes .", - }, - "scope_drift": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_drift .", - }, - "scope_parse_status": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_parse_status .", - }, - "scope_transformed_facts": &schema.Schema{ - Type: schema.TypeMap, - Computed: true, - Description: "Stores the value of scope_transformed_facts .", - }, - "scope_collector_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_collector_id .", - }, - }, - }, - }, - "discovery_methods": &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of scope_discovery_methods .Will be displayed only when value exists.", - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "discovery_method": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_discovery_method .Will be displayed only when value exists.", - }, - "file_type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_file_type .Will be displayed only when value exists.", - }, - "file_format": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_file_format .Will be displayed only when value exists.", - }, - "created_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_created_by .Will be displayed only when value exists.", - }, - "created_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_created_on .Will be displayed only when value exists.", - }, - "modified_by": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_modified_by .Will be displayed only when value exists.", - }, - "modified_at": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_modified_on .Will be displayed only when value exists.", - }, - "is_discovery_scheduled": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_is_discovery_scheduled .Will be displayed only when value exists.", - }, - "interval": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_freq .Will be displayed only when value exists.", - }, - "discovery_setting_id": &schema.Schema{ - Type: schema.TypeInt, - Computed: true, - Description: "Stores the value of scope_discovery_setting_id .Will be displayed only when value exists.", - }, - "include_new_eagerly": &schema.Schema{ - Type: schema.TypeBool, - Computed: true, - Description: "Stores the value of scope_include_new_eagerly .Will be displayed only when value exists.", - }, - "type": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_type .Will be displayed only when value exists.", - }, - "correlation_id": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "A correlation_Id is created when a scope is created and discovery task is triggered or when a validation is triggered on a Scope. This is used to get the status of the task(discovery or validation).", - }, - "credential_attributes": &schema.Schema{ - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_credential_attributes .Will be displayed only when value exists.", - }, - }, - } -} - -func dataSourceIBMSccPostureScopeRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - ScopeDetailsOptions := &posturemanagementv2.GetScopeDetailsOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - ScopeDetailsOptions.SetAccountID(accountID) - ScopeDetailsOptions.SetID(d.Get("scope_id").(string)) - - scope, response, err := postureManagementClient.GetScopeDetailsWithContext(context, ScopeDetailsOptions) - if err != nil { - log.Printf("[DEBUG] GetScopeDetailsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetScopeDetailsWithContext failed %s\n%s", err, response)) - } - - d.SetId(*scope.ID) - if err = d.Set("name", scope.Name); err != nil { - return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) - } - if err = d.Set("uuid", scope.UUID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting uuid: %s", err)) - } - if err = d.Set("partner_uuid", scope.PartnerUUID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting partner_uuid: %s", err)) - } - if err = d.Set("description", scope.Description); err != nil { - return diag.FromErr(fmt.Errorf("Error setting description: %s", err)) - } - if err = d.Set("org_id", flex.IntValue(scope.OrgID)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting org_id: %s", err)) - } - if err = d.Set("cloud_type_id", flex.IntValue(scope.CloudTypeID)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cloud_type_id: %s", err)) - } - if err = d.Set("tld_credential_id", flex.IntValue(scope.TldCredentialID)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting tld_credential_id: %s", err)) - } - if err = d.Set("status", scope.Status); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) - } - if err = d.Set("status_msg", scope.StatusMsg); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_msg: %s", err)) - } - if err = d.Set("subset_selected", scope.SubsetSelected); err != nil { - return diag.FromErr(fmt.Errorf("Error setting subset_selected: %s", err)) - } - if err = d.Set("enabled", scope.Enabled); err != nil { - return diag.FromErr(fmt.Errorf("Error setting enabled: %s", err)) - } - if err = d.Set("last_discover_start_time", scope.LastDiscoverStartTime); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_discover_start_time: %s", err)) - } - if err = d.Set("last_discover_completed_time", scope.LastDiscoverCompletedTime); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_discover_completed_time: %s", err)) - } - if err = d.Set("last_successful_discover_start_time", scope.LastSuccessfulDiscoverStartTime); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_successful_discover_start_time: %s", err)) - } - if err = d.Set("last_successful_discover_completed_time", scope.LastSuccessfulDiscoverCompletedTime); err != nil { - return diag.FromErr(fmt.Errorf("Error setting last_successful_discover_completed_time: %s", err)) - } - if err = d.Set("task_type", scope.TaskType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting task_type: %s", err)) - } - - if scope.Tasks != nil { - err = d.Set("tasks", dataSourceScopeFlattenTasks(scope.Tasks)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting tasks %s", err)) - } - } - if err = d.Set("status_updated_time", scope.StatusUpdatedTime); err != nil { - return diag.FromErr(fmt.Errorf("Error setting status_updated_time: %s", err)) - } - - if scope.CollectorsByType != nil { - convertedMap := make(map[string]interface{}, len(scope.CollectorsByType)) - for k, v := range scope.CollectorsByType { - convertedMap[k] = v - } - - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting collectors_by_type %s", err)) - } - } - - if scope.CredentialsByType != nil { - convertedMap := make(map[string]interface{}, len(scope.CredentialsByType)) - for k, v := range scope.CredentialsByType { - convertedMap[k] = v - } - - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting credentials_by_type %s", err)) - } - } - - if scope.CredentialsBySubCategeoryType != nil { - convertedMap := make(map[string]interface{}, len(scope.CredentialsBySubCategeoryType)) - for k, v := range scope.CredentialsBySubCategeoryType { - convertedMap[k] = v - } - - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting credentials_by_sub_categeory_type %s", err)) - } - } - if err = d.Set("resource_groups", scope.ResourceGroups); err != nil { - return diag.FromErr(fmt.Errorf("Error setting resource_groups: %s", err)) - } - if err = d.Set("region_names", scope.RegionNames); err != nil { - return diag.FromErr(fmt.Errorf("Error setting region_names: %s", err)) - } - if err = d.Set("cloud_type", scope.CloudType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting cloud_type: %s", err)) - } - if err = d.Set("env_sub_category", scope.EnvSubCategory); err != nil { - return diag.FromErr(fmt.Errorf("Error setting env_sub_category: %s", err)) - } - - if scope.TldCredentail != nil { - err = d.Set("tld_credentail", dataSourceScopeFlattenTldCredentail(*scope.TldCredentail)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting tld_credentail %s", err)) - } - } - - if scope.Collectors != nil { - err = d.Set("collectors", dataSourceScopeFlattenCollectors(scope.Collectors)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting collectors %s", err)) - } - } - - if scope.FirstLevelScopedData != nil { - err = d.Set("first_level_scoped_data", dataSourceScopeFlattenFirstLevelScopedData(scope.FirstLevelScopedData)) - if err != nil { - return diag.FromErr(fmt.Errorf("Error setting first_level_scoped_data %s", err)) - } - } - if err = d.Set("discovery_method", scope.DiscoveryMethod); err != nil { - return diag.FromErr(fmt.Errorf("Error setting discovery_method: %s", err)) - } - if err = d.Set("file_type", scope.FileType); err != nil { - return diag.FromErr(fmt.Errorf("Error setting file_type: %s", err)) - } - if err = d.Set("file_format", scope.FileFormat); err != nil { - return diag.FromErr(fmt.Errorf("Error setting file_format: %s", err)) - } - if err = d.Set("created_by", scope.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_by: %s", err)) - } - if err = d.Set("created_at", scope.CreatedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting created_at: %s", err)) - } - if err = d.Set("modified_by", scope.ModifiedBy); err != nil { - return diag.FromErr(fmt.Errorf("Error setting modified_by: %s", err)) - } - if err = d.Set("modified_at", scope.ModifiedAt); err != nil { - return diag.FromErr(fmt.Errorf("Error setting modified_at: %s", err)) - } - if err = d.Set("is_discovery_scheduled", scope.IsDiscoveryScheduled); err != nil { - return diag.FromErr(fmt.Errorf("Error setting is_discovery_scheduled: %s", err)) - } - if err = d.Set("interval", flex.IntValue(scope.Interval)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting interval: %s", err)) - } - if err = d.Set("discovery_setting_id", flex.IntValue(scope.DiscoverySettingID)); err != nil { - return diag.FromErr(fmt.Errorf("Error setting discovery_setting_id: %s", err)) - } - if err = d.Set("include_new_eagerly", scope.IncludeNewEagerly); err != nil { - return diag.FromErr(fmt.Errorf("Error setting include_new_eagerly: %s", err)) - } - if err = d.Set("type", scope.Type); err != nil { - return diag.FromErr(fmt.Errorf("Error setting type: %s", err)) - } - if err = d.Set("correlation_id", scope.CorrelationID); err != nil { - return diag.FromErr(fmt.Errorf("Error setting correlation_id: %s", err)) - } - if err = d.Set("credential_attributes", scope.CredentialAttributes); err != nil { - return diag.FromErr(fmt.Errorf("Error setting credential_attributes: %s", err)) - } - - return nil -} - -func dataSourceScopeFlattenTasks(result []posturemanagementv2.ScopeDetailsGatewayTask) (tasks []map[string]interface{}) { - for _, tasksItem := range result { - tasks = append(tasks, dataSourceScopeTasksToMap(tasksItem)) - } - - return tasks -} - -func dataSourceScopeTasksToMap(tasksItem posturemanagementv2.ScopeDetailsGatewayTask) (tasksMap map[string]interface{}) { - tasksMap = map[string]interface{}{} - - if tasksItem.TaskLogs != nil { - taskLogsList := []map[string]interface{}{} - for _, taskLogsItem := range tasksItem.TaskLogs { - taskLogsList = append(taskLogsList, dataSourceScopeTasksTaskLogsToMap(taskLogsItem)) - } - tasksMap["task_logs"] = taskLogsList - } - if tasksItem.TaskID != nil { - tasksMap["task_id"] = tasksItem.TaskID - } - if tasksItem.TaskGatewayID != nil { - tasksMap["task_gateway_id"] = tasksItem.TaskGatewayID - } - if tasksItem.TaskGatewayName != nil { - tasksMap["task_gateway_name"] = tasksItem.TaskGatewayName - } - if tasksItem.TaskTaskType != nil { - tasksMap["task_task_type"] = tasksItem.TaskTaskType - } - if tasksItem.TaskGatewaySchemaID != nil { - tasksMap["task_gateway_schema_id"] = tasksItem.TaskGatewaySchemaID - } - if tasksItem.TaskSchemaName != nil { - tasksMap["task_schema_name"] = tasksItem.TaskSchemaName - } - if tasksItem.TaskDiscoverID != nil { - tasksMap["task_discover_id"] = tasksItem.TaskDiscoverID - } - if tasksItem.TaskStatus != nil { - tasksMap["task_status"] = tasksItem.TaskStatus - } - if tasksItem.TaskStatusMsg != nil { - tasksMap["task_status_msg"] = tasksItem.TaskStatusMsg - } - if tasksItem.TaskStartTime != nil { - tasksMap["task_start_time"] = tasksItem.TaskStartTime - } - if tasksItem.TaskUpdatedTime != nil { - tasksMap["task_updated_time"] = tasksItem.TaskUpdatedTime - } - if tasksItem.TaskDerivedStatus != nil { - tasksMap["task_derived_status"] = tasksItem.TaskDerivedStatus - } - if tasksItem.TaskCreatedBy != nil { - tasksMap["task_created_by"] = tasksItem.TaskCreatedBy - } - - return tasksMap -} - -func dataSourceScopeTasksTaskLogsToMap(taskLogsItem posturemanagementv2.TaskLogs) (taskLogsMap map[string]interface{}) { - taskLogsMap = map[string]interface{}{} - - return taskLogsMap -} - -func dataSourceScopeFlattenTldCredentail(result posturemanagementv2.ScopeDetailsCredential) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScopeTldCredentailToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScopeTldCredentailToMap(tldCredentailItem posturemanagementv2.ScopeDetailsCredential) (tldCredentailMap map[string]interface{}) { - tldCredentailMap = map[string]interface{}{} - - if tldCredentailItem.ID != nil { - tldCredentailMap["credential_id"] = tldCredentailItem.ID - } - if tldCredentailItem.Name != nil { - tldCredentailMap["name"] = tldCredentailItem.Name - } - if tldCredentailItem.UUID != nil { - tldCredentailMap["uuid"] = tldCredentailItem.UUID - } - if tldCredentailItem.Type != nil { - tldCredentailMap["credential_type"] = tldCredentailItem.Type - } - if tldCredentailItem.Data != nil { - tldCredentailMap["data"] = tldCredentailItem.Data - } - if tldCredentailItem.DisplayFields != nil { - displayFieldsList := []map[string]interface{}{} - displayFieldsMap := dataSourceScopeTldCredentailDisplayFieldsToMap(*tldCredentailItem.DisplayFields) - displayFieldsList = append(displayFieldsList, displayFieldsMap) - tldCredentailMap["display_fields"] = displayFieldsList - } - if tldCredentailItem.VersionTimestamp != nil { - tldCredentailMap["version_timestamp"] = tldCredentailItem.VersionTimestamp - } - if tldCredentailItem.Description != nil { - tldCredentailMap["description"] = tldCredentailItem.Description - } - if tldCredentailItem.IsEnabled != nil { - tldCredentailMap["is_enabled"] = tldCredentailItem.IsEnabled - } - if tldCredentailItem.GatewayKey != nil { - tldCredentailMap["gateway_key"] = tldCredentailItem.GatewayKey - } - if tldCredentailItem.Purpose != nil { - tldCredentailMap["purpose"] = tldCredentailItem.Purpose - } - - return tldCredentailMap -} - -func dataSourceScopeTldCredentailDisplayFieldsToMap(displayFieldsItem posturemanagementv2.ScopeDetailsCredentialDisplayFields) (displayFieldsMap map[string]interface{}) { - displayFieldsMap = map[string]interface{}{} - - if displayFieldsItem.IBMAPIKey != nil { - displayFieldsMap["ibm_api_key"] = displayFieldsItem.IBMAPIKey - } - if displayFieldsItem.AwsClientID != nil { - displayFieldsMap["aws_client_id"] = displayFieldsItem.AwsClientID - } - if displayFieldsItem.AwsClientSecret != nil { - displayFieldsMap["aws_client_secret"] = displayFieldsItem.AwsClientSecret - } - if displayFieldsItem.AwsRegion != nil { - displayFieldsMap["aws_region"] = displayFieldsItem.AwsRegion - } - if displayFieldsItem.AwsArn != nil { - displayFieldsMap["aws_arn"] = displayFieldsItem.AwsArn - } - if displayFieldsItem.Username != nil { - displayFieldsMap["username"] = displayFieldsItem.Username - } - if displayFieldsItem.Password != nil { - displayFieldsMap["password"] = displayFieldsItem.Password - } - if displayFieldsItem.AzureClientID != nil { - displayFieldsMap["azure_client_id"] = displayFieldsItem.AzureClientID - } - if displayFieldsItem.AzureClientSecret != nil { - displayFieldsMap["azure_client_secret"] = displayFieldsItem.AzureClientSecret - } - if displayFieldsItem.AzureSubscriptionID != nil { - displayFieldsMap["azure_subscription_id"] = displayFieldsItem.AzureSubscriptionID - } - if displayFieldsItem.AzureResourceGroup != nil { - displayFieldsMap["azure_resource_group"] = displayFieldsItem.AzureResourceGroup - } - if displayFieldsItem.DatabaseName != nil { - displayFieldsMap["database_name"] = displayFieldsItem.DatabaseName - } - if displayFieldsItem.WinrmAuthtype != nil { - displayFieldsMap["winrm_authtype"] = displayFieldsItem.WinrmAuthtype - } - if displayFieldsItem.WinrmUsessl != nil { - displayFieldsMap["winrm_usessl"] = displayFieldsItem.WinrmUsessl - } - if displayFieldsItem.WinrmPort != nil { - displayFieldsMap["winrm_port"] = displayFieldsItem.WinrmPort - } - if displayFieldsItem.Ms365ClientID != nil { - displayFieldsMap["ms_365_client_id"] = displayFieldsItem.Ms365ClientID - } - if displayFieldsItem.Ms365ClientSecret != nil { - displayFieldsMap["ms_365_client_secret"] = displayFieldsItem.Ms365ClientSecret - } - if displayFieldsItem.Ms365TenantID != nil { - displayFieldsMap["ms_365_tenant_id"] = displayFieldsItem.Ms365TenantID - } - if displayFieldsItem.AuthURL != nil { - displayFieldsMap["auth_url"] = displayFieldsItem.AuthURL - } - if displayFieldsItem.ProjectName != nil { - displayFieldsMap["project_name"] = displayFieldsItem.ProjectName - } - if displayFieldsItem.UserDomainName != nil { - displayFieldsMap["user_domain_name"] = displayFieldsItem.UserDomainName - } - if displayFieldsItem.ProjectDomainName != nil { - displayFieldsMap["project_domain_name"] = displayFieldsItem.ProjectDomainName - } - - return displayFieldsMap -} - -func dataSourceScopeFlattenCollectors(result []posturemanagementv2.Collector) (collectors []map[string]interface{}) { - for _, collectorsItem := range result { - collectors = append(collectors, dataSourceScopeCollectorsToMap(collectorsItem)) - } - - return collectors -} - -func dataSourceScopeCollectorsToMap(collectorsItem posturemanagementv2.Collector) (collectorsMap map[string]interface{}) { - collectorsMap = map[string]interface{}{} - - if collectorsItem.ID != nil { - collectorsMap["collector_id"] = collectorsItem.ID - } - if collectorsItem.DisplayName != nil { - collectorsMap["display_name"] = collectorsItem.DisplayName - } - if collectorsItem.Name != nil { - collectorsMap["name"] = collectorsItem.Name - } - if collectorsItem.PublicKey != nil { - collectorsMap["public_key"] = collectorsItem.PublicKey - } - if collectorsItem.LastHeartbeat != nil { - collectorsMap["last_heartbeat"] = collectorsItem.LastHeartbeat.String() - } - if collectorsItem.Status != nil { - collectorsMap["status"] = collectorsItem.Status - } - if collectorsItem.CollectorVersion != nil { - collectorsMap["collector_version"] = collectorsItem.CollectorVersion - } - if collectorsItem.ImageVersion != nil { - collectorsMap["image_version"] = collectorsItem.ImageVersion - } - if collectorsItem.Description != nil { - collectorsMap["description"] = collectorsItem.Description - } - if collectorsItem.CreatedBy != nil { - collectorsMap["created_by"] = collectorsItem.CreatedBy - } - if collectorsItem.CreatedAt != nil { - collectorsMap["created_at"] = collectorsItem.CreatedAt.String() - } - if collectorsItem.UpdatedBy != nil { - collectorsMap["updated_by"] = collectorsItem.UpdatedBy - } - if collectorsItem.UpdatedAt != nil { - collectorsMap["updated_at"] = collectorsItem.UpdatedAt.String() - } - if collectorsItem.Enabled != nil { - collectorsMap["enabled"] = collectorsItem.Enabled - } - if collectorsItem.RegistrationCode != nil { - collectorsMap["registration_code"] = collectorsItem.RegistrationCode - } - if collectorsItem.Type != nil { - collectorsMap["type"] = collectorsItem.Type - } - if collectorsItem.CredentialPublicKey != nil { - collectorsMap["credential_public_key"] = collectorsItem.CredentialPublicKey - } - if collectorsItem.FailureCount != nil { - collectorsMap["failure_count"] = collectorsItem.FailureCount - } - if collectorsItem.ApprovedLocalGatewayIP != nil { - collectorsMap["approved_local_gateway_ip"] = collectorsItem.ApprovedLocalGatewayIP - } - if collectorsItem.ApprovedInternetGatewayIP != nil { - collectorsMap["approved_internet_gateway_ip"] = collectorsItem.ApprovedInternetGatewayIP - } - if collectorsItem.LastFailedLocalGatewayIP != nil { - collectorsMap["last_failed_local_gateway_ip"] = collectorsItem.LastFailedLocalGatewayIP - } - if collectorsItem.ResetReason != nil { - collectorsMap["reset_reason"] = collectorsItem.ResetReason - } - if collectorsItem.Hostname != nil { - collectorsMap["hostname"] = collectorsItem.Hostname - } - if collectorsItem.InstallPath != nil { - collectorsMap["install_path"] = collectorsItem.InstallPath - } - if collectorsItem.UsePrivateEndpoint != nil { - collectorsMap["use_private_endpoint"] = collectorsItem.UsePrivateEndpoint - } - if collectorsItem.ManagedBy != nil { - collectorsMap["managed_by"] = collectorsItem.ManagedBy - } - if collectorsItem.TrialExpiry != nil { - collectorsMap["trial_expiry"] = collectorsItem.TrialExpiry.String() - } - if collectorsItem.LastFailedInternetGatewayIP != nil { - collectorsMap["last_failed_internet_gateway_ip"] = collectorsItem.LastFailedInternetGatewayIP - } - if collectorsItem.StatusDescription != nil { - collectorsMap["status_description"] = collectorsItem.StatusDescription - } - if collectorsItem.ResetTime != nil { - collectorsMap["reset_time"] = collectorsItem.ResetTime.String() - } - if collectorsItem.IsPublic != nil { - collectorsMap["is_public"] = collectorsItem.IsPublic - } - if collectorsItem.IsUbiImage != nil { - collectorsMap["is_ubi_image"] = collectorsItem.IsUbiImage - } - - return collectorsMap -} - -func dataSourceScopeFlattenFirstLevelScopedData(result []posturemanagementv2.ScopeDetailsAssetData) (firstLevelScopedData []map[string]interface{}) { - for _, firstLevelScopedDataItem := range result { - firstLevelScopedData = append(firstLevelScopedData, dataSourceScopeFirstLevelScopedDataToMap(firstLevelScopedDataItem)) - } - - return firstLevelScopedData -} - -func dataSourceScopeFirstLevelScopedDataToMap(firstLevelScopedDataItem posturemanagementv2.ScopeDetailsAssetData) (firstLevelScopedDataMap map[string]interface{}) { - firstLevelScopedDataMap = map[string]interface{}{} - - if firstLevelScopedDataItem.ScopeObject != nil { - firstLevelScopedDataMap["scope_object"] = firstLevelScopedDataItem.ScopeObject - } - if firstLevelScopedDataItem.ScopeInitScope != nil { - firstLevelScopedDataMap["scope_init_scope"] = firstLevelScopedDataItem.ScopeInitScope - } - if firstLevelScopedDataItem.Scope != nil { - firstLevelScopedDataMap["scope"] = firstLevelScopedDataItem.Scope - } - if firstLevelScopedDataItem.ScopeChanged != nil { - firstLevelScopedDataMap["scope_changed"] = firstLevelScopedDataItem.ScopeChanged - } - if firstLevelScopedDataItem.ScopeID != nil { - firstLevelScopedDataMap["scope_id"] = firstLevelScopedDataItem.ScopeID - } - if firstLevelScopedDataItem.ScopeProperties != nil { - firstLevelScopedDataMap["scope_properties"] = firstLevelScopedDataItem.ScopeProperties - } - if firstLevelScopedDataItem.ScopeOverlay != nil { - firstLevelScopedDataMap["scope_overlay"] = firstLevelScopedDataItem.ScopeOverlay - } - if firstLevelScopedDataItem.ScopeNewFound != nil { - firstLevelScopedDataMap["scope_new_found"] = firstLevelScopedDataItem.ScopeNewFound - } - if firstLevelScopedDataItem.ScopeDiscoveryStatus != nil { - firstLevelScopedDataMap["scope_discovery_status"] = firstLevelScopedDataItem.ScopeDiscoveryStatus - } - if firstLevelScopedDataItem.ScopeFactStatus != nil { - firstLevelScopedDataMap["scope_fact_status"] = firstLevelScopedDataItem.ScopeFactStatus - } - if firstLevelScopedDataItem.ScopeFacts != nil { - firstLevelScopedDataMap["scope_facts"] = firstLevelScopedDataItem.ScopeFacts - } - if firstLevelScopedDataItem.ScopeListMembers != nil { - firstLevelScopedDataMap["scope_list_members"] = firstLevelScopedDataItem.ScopeListMembers - } - if firstLevelScopedDataItem.ScopeChildren != nil { - firstLevelScopedDataMap["scope_children"] = firstLevelScopedDataItem.ScopeChildren - } - if firstLevelScopedDataItem.ScopeResourceCategory != nil { - firstLevelScopedDataMap["scope_resource_category"] = firstLevelScopedDataItem.ScopeResourceCategory - } - if firstLevelScopedDataItem.ScopeResourceType != nil { - firstLevelScopedDataMap["scope_resource_type"] = firstLevelScopedDataItem.ScopeResourceType - } - if firstLevelScopedDataItem.ScopeResource != nil { - firstLevelScopedDataMap["scope_resource"] = firstLevelScopedDataItem.ScopeResource - } - if firstLevelScopedDataItem.ScopeResourceAttributes != nil { - firstLevelScopedDataMap["scope_resource_attributes"] = firstLevelScopedDataItem.ScopeResourceAttributes - } - if firstLevelScopedDataItem.ScopeDrift != nil { - firstLevelScopedDataMap["scope_drift"] = firstLevelScopedDataItem.ScopeDrift - } - if firstLevelScopedDataItem.ScopeParseStatus != nil { - firstLevelScopedDataMap["scope_parse_status"] = firstLevelScopedDataItem.ScopeParseStatus - } - if firstLevelScopedDataItem.ScopeTransformedFacts != nil { - firstLevelScopedDataMap["scope_transformed_facts"] = firstLevelScopedDataItem.ScopeTransformedFacts - } - if firstLevelScopedDataItem.ScopeCollectorID != nil { - firstLevelScopedDataMap["scope_collector_id"] = firstLevelScopedDataItem.ScopeCollectorID - } - - return firstLevelScopedDataMap -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation.go b/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation.go deleted file mode 100644 index c376ca82bb..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureScopeCorrelation() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureScopeCorrelationRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_scope_correlation is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "correlation_id": { - Type: schema.TypeString, - Required: true, - Description: "A correlation_Id is created when a scope is created and discovery task is triggered or when a validation is triggered on a Scope. This is used to get the status of the task(discovery or validation).", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "Returns the current status of a task.", - }, - "start_time": { - Type: schema.TypeString, - Computed: true, - Description: "Returns the time that task started.", - }, - "last_heartbeat": { - Type: schema.TypeString, - Computed: true, - Description: "Returns the time that the scope was last updated. This value exists when collector is installed and running.", - }, - }, - } -} - -func dataSourceIBMSccPostureScopeCorrelationRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getCorrelationIDOptions := &posturemanagementv2.GetCorrelationIDOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getCorrelationIDOptions.SetAccountID(accountID) - - getCorrelationIDOptions.SetCorrelationID(d.Get("correlation_id").(string)) - - scopeTaskStatus, response, err := postureManagementClient.GetCorrelationIDWithContext(context, getCorrelationIDOptions) - if err != nil { - log.Printf("[DEBUG] GetCorrelationIDWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetCorrelationIDWithContext failed %s\n%s", err, response)) - } - - d.SetId(dataSourceIBMSccPostureScopeCorrelationID(d)) - if err = d.Set("status", scopeTaskStatus.Status); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting status: %s", err)) - } - if err = d.Set("start_time", scopeTaskStatus.StartTime); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting start_time: %s", err)) - } - if err = d.Set("last_heartbeat", flex.DateTimeToString(scopeTaskStatus.LastHeartbeat)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last_heartbeat: %s", err)) - } - - return nil -} - -// dataSourceIBMScopeCorrelationID returns a reasonable ID for the list. -func dataSourceIBMSccPostureScopeCorrelationID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation_test.go b/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation_test.go deleted file mode 100644 index 3e86a3ef88..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scope_correlation_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureScopeCorrelationDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureScopeCorrelationDataSourceConfigBasic(acc.Scc_posture_correlation_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scope_correlation.scope_correlation", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scope_correlation.scope_correlation", "correlation_id"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureScopeCorrelationDataSourceConfigBasic(correlationId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_scope_correlation" "scope_correlation" { - correlation_id = "%s" - } - `, correlationId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scope_test.go b/ibm/service/scc/data_source_ibm_scc_posture_scope_test.go deleted file mode 100644 index 6ae258ee56..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scope_test.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright IBM Corp. 2022 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureScopeDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - resource.TestStep{ - Config: testAccCheckIBMSccPostureScopeDataSourceConfigBasic(acc.Scc_posture_scope_id), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scope.scope", "scope_id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scope.scope", "name"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureScopeDataSourceConfigBasic(scopeId string) string { - return fmt.Sprintf(` - data "ibm_scc_posture_scope" "scope" { - scope_id = "%s" - } - `, scopeId) -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scopes.go b/ibm/service/scc/data_source_ibm_scc_posture_scopes.go deleted file mode 100644 index d00b32e230..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scopes.go +++ /dev/null @@ -1,630 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "time" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func DataSourceIBMSccPostureScopes() *schema.Resource { - return &schema.Resource{ - ReadContext: dataSourceIBMSccPostureListScopesRead, - DeprecationMessage: "**Removal Notification** Data Source Removal: Data Source ibm_scc_posture_scopes is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "offset": { - Type: schema.TypeInt, - Computed: true, - Description: "The offset of the page.", - }, - "limit": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of scopes displayed per page.", - }, - "total_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The total number of scopes. This value is 0 if no scopes are available and below fields will not be available in that case.", - }, - "first": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "last": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "previous": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "next": { - Type: schema.TypeList, - Computed: true, - Description: "The URL of a page.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "href": { - Type: schema.TypeString, - Computed: true, - Description: "The URL of a page.", - }, - }, - }, - }, - "scopes": { - Type: schema.TypeList, - Computed: true, - Description: "Scopes.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - Description: "A detailed description of the scope.", - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who created the scope.", - }, - "modified_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who most recently modified the scope.", - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: "An auto-generated unique identifier for the scope.", - }, - "uuid": { - Type: schema.TypeString, - Computed: true, - Description: "Stores the value of scope_uuid .", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "A unique name for your scope.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "Indicates whether scope is enabled/disabled.", - }, - "credential_type": { - Type: schema.TypeString, - Computed: true, - Description: "The environment that the scope is targeted to.", - }, - "created_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the scope was created in UTC.", - }, - "updated_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the scope was last modified in UTC.", - }, - "collectors": { - Type: schema.TypeList, - Computed: true, - Description: "Stores the value of collectors .Will be displayed only when value exists.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Description: "The id of the collector.", - }, - "display_name": { - Type: schema.TypeString, - Computed: true, - Description: "The user-friendly name of the collector.", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "The name of the collector.", - }, - "public_key": { - Type: schema.TypeString, - Computed: true, - Description: "The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed.", - }, - "last_heartbeat": { - Type: schema.TypeString, - Computed: true, - Description: "Stores the heartbeat time of a controller . This value exists when collector is installed and running.", - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: "The status of collector.", - }, - "collector_version": { - Type: schema.TypeString, - Computed: true, - Description: "The collector version. This field is populated when collector is installed.", - }, - "image_version": { - Type: schema.TypeString, - Computed: true, - Description: "The image version of the collector. This field is populated when collector is installed. \".", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "The description of the collector.", - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that created the collector.", - }, - "created_at": { - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was created.", - }, - "updated_by": { - Type: schema.TypeString, - Computed: true, - Description: "The id of the user that modified the collector.", - }, - "updated_at": { - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time the collector was modified.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "Identifies whether the collector is enabled or not(deleted).", - }, - "registration_code": { - Type: schema.TypeString, - Computed: true, - Description: "The registration code of the collector.This is will be used for initial authentication during installation of collector.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of the collector.", - }, - "credential_public_key": { - Type: schema.TypeString, - Computed: true, - Description: "The credential public key.", - }, - "failure_count": { - Type: schema.TypeInt, - Computed: true, - Description: "The number of times the collector has failed.", - }, - "approved_local_gateway_ip": { - Type: schema.TypeString, - Computed: true, - Description: "The approved local gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "approved_internet_gateway_ip": { - Type: schema.TypeString, - Computed: true, - Description: "The approved internet gateway ip of the collector. This field will be populated only when collector is installed.", - }, - "last_failed_local_gateway_ip": { - Type: schema.TypeString, - Computed: true, - Description: "The failed local gateway ip. This field will be populated only when collector is installed.", - }, - "reset_reason": { - Type: schema.TypeString, - Computed: true, - Description: "The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field .", - }, - "hostname": { - Type: schema.TypeString, - Computed: true, - Description: "The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name.", - }, - "install_path": { - Type: schema.TypeString, - Computed: true, - Description: "The installation path of the collector. This field will be populated when collector is installed.The value will be folder path.", - }, - "use_private_endpoint": { - Type: schema.TypeBool, - Computed: true, - Description: "Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false.", - }, - "managed_by": { - Type: schema.TypeString, - Computed: true, - Description: "The entity that manages the collector.", - }, - "trial_expiry": { - Type: schema.TypeString, - Computed: true, - Description: "The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed.", - }, - "last_failed_internet_gateway_ip": { - Type: schema.TypeString, - Computed: true, - Description: "The failed internet gateway ip of the collector.", - }, - "status_description": { - Type: schema.TypeString, - Computed: true, - Description: "The collector status.", - }, - "reset_time": { - Type: schema.TypeString, - Computed: true, - Description: "The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field.", - }, - "is_public": { - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network.", - }, - "is_ubi_image": { - Type: schema.TypeBool, - Computed: true, - Description: "Determines whether the collector has a Ubi image.", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - -func dataSourceIBMSccPostureListScopesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - listScopesOptions := &posturemanagementv2.ListScopesOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - listScopesOptions.SetAccountID(accountID) - - finalList, response, err := postureManagementClient.ListScopesWithContext(context, listScopesOptions) - if err != nil { - log.Printf("[DEBUG] ListScopesWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ListScopesWithContext failed %s\n%s", err, response)) - } - - scopeList := finalList - - d.SetId(dataSourceIBMSccPostureListScopesID(d)) - if err = d.Set("offset", flex.IntValue(scopeList.Offset)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting offset: %s", err)) - } - if err = d.Set("limit", flex.IntValue(scopeList.Limit)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting limit: %s", err)) - } - if err = d.Set("total_count", flex.IntValue(scopeList.TotalCount)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting total_count: %s", err)) - } - - if scopeList.First != nil { - err = d.Set("first", dataSourceScopeListFlattenFirst(*scopeList.First)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting first %s", err)) - } - } - - if scopeList.Last != nil { - err = d.Set("last", dataSourceScopeListFlattenLast(*scopeList.Last)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting last %s", err)) - } - } - - if scopeList.Previous != nil { - err = d.Set("previous", dataSourceScopeListFlattenPrevious(*scopeList.Previous)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting previous %s", err)) - } - } - - if scopeList.Next != nil { - err = d.Set("next", dataSourceScopeListFlattenNext(*scopeList.Next)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting next %s", err)) - } - } - - if scopeList.Scopes != nil { - err = d.Set("scopes", dataSourceScopeListFlattenScopes(scopeList.Scopes)) - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting scopes %s", err)) - } - } - - return nil -} - -// dataSourceIBMListScopesID returns a reasonable ID for the list. -func dataSourceIBMSccPostureListScopesID(d *schema.ResourceData) string { - return time.Now().UTC().String() -} - -func dataSourceScopeListFlattenFirst(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScopeListFirstToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScopeListFirstToMap(firstItem posturemanagementv2.PageLink) (firstMap map[string]interface{}) { - firstMap = map[string]interface{}{} - - if firstItem.Href != nil { - firstMap["href"] = firstItem.Href - } - - return firstMap -} - -func dataSourceScopeListFlattenLast(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScopeListLastToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScopeListLastToMap(lastItem posturemanagementv2.PageLink) (lastMap map[string]interface{}) { - lastMap = map[string]interface{}{} - - if lastItem.Href != nil { - lastMap["href"] = lastItem.Href - } - - return lastMap -} - -func dataSourceScopeListFlattenPrevious(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScopeListPreviousToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScopeListPreviousToMap(previousItem posturemanagementv2.PageLink) (previousMap map[string]interface{}) { - previousMap = map[string]interface{}{} - - if previousItem.Href != nil { - previousMap["href"] = previousItem.Href - } - - return previousMap -} - -func dataSourceScopeListFlattenNext(result posturemanagementv2.PageLink) (finalList []map[string]interface{}) { - finalList = []map[string]interface{}{} - finalMap := dataSourceScopeListNextToMap(result) - finalList = append(finalList, finalMap) - - return finalList -} - -func dataSourceScopeListNextToMap(nextItem posturemanagementv2.PageLink) (nextMap map[string]interface{}) { - nextMap = map[string]interface{}{} - - if nextItem.Href != nil { - nextMap["href"] = nextItem.Href - } - - return nextMap -} - -func dataSourceScopeListFlattenScopes(result []posturemanagementv2.ScopeItem) (scopes []map[string]interface{}) { - for _, scopesItem := range result { - scopes = append(scopes, dataSourceScopeListScopesToMap(scopesItem)) - } - - return scopes -} - -func dataSourceScopeListScopesToMap(scopesItem posturemanagementv2.ScopeItem) (scopesMap map[string]interface{}) { - scopesMap = map[string]interface{}{} - - if scopesItem.Description != nil { - scopesMap["description"] = scopesItem.Description - } - if scopesItem.CreatedBy != nil { - scopesMap["created_by"] = scopesItem.CreatedBy - } - if scopesItem.ModifiedBy != nil { - scopesMap["modified_by"] = scopesItem.ModifiedBy - } - if scopesItem.ID != nil { - scopesMap["id"] = scopesItem.ID - } - if scopesItem.UUID != nil { - scopesMap["uuid"] = scopesItem.UUID - } - if scopesItem.Name != nil { - scopesMap["name"] = scopesItem.Name - } - if scopesItem.Enabled != nil { - scopesMap["enabled"] = scopesItem.Enabled - } - if scopesItem.CredentialType != nil { - scopesMap["credential_type"] = scopesItem.CredentialType - } - if scopesItem.CreatedAt != nil { - scopesMap["created_at"] = scopesItem.CreatedAt.String() - } - if scopesItem.UpdatedAt != nil { - scopesMap["updated_at"] = scopesItem.UpdatedAt.String() - } - if scopesItem.Collectors != nil { - collectorsList := []map[string]interface{}{} - for _, collectorsItem := range scopesItem.Collectors { - collectorsList = append(collectorsList, dataSourceScopeListScopesCollectorsToMap(collectorsItem)) - } - scopesMap["collectors"] = collectorsList - } - - return scopesMap -} - -func dataSourceScopeListScopesCollectorsToMap(collectorsItem posturemanagementv2.Collector) (collectorsMap map[string]interface{}) { - collectorsMap = map[string]interface{}{} - - if collectorsItem.ID != nil { - collectorsMap["id"] = collectorsItem.ID - } - if collectorsItem.DisplayName != nil { - collectorsMap["display_name"] = collectorsItem.DisplayName - } - if collectorsItem.Name != nil { - collectorsMap["name"] = collectorsItem.Name - } - if collectorsItem.PublicKey != nil { - collectorsMap["public_key"] = collectorsItem.PublicKey - } - if collectorsItem.LastHeartbeat != nil { - collectorsMap["last_heartbeat"] = collectorsItem.LastHeartbeat.String() - } - if collectorsItem.Status != nil { - collectorsMap["status"] = collectorsItem.Status - } - if collectorsItem.CollectorVersion != nil { - collectorsMap["collector_version"] = collectorsItem.CollectorVersion - } - if collectorsItem.ImageVersion != nil { - collectorsMap["image_version"] = collectorsItem.ImageVersion - } - if collectorsItem.Description != nil { - collectorsMap["description"] = collectorsItem.Description - } - if collectorsItem.CreatedBy != nil { - collectorsMap["created_by"] = collectorsItem.CreatedBy - } - if collectorsItem.CreatedAt != nil { - collectorsMap["created_at"] = collectorsItem.CreatedAt.String() - } - if collectorsItem.UpdatedBy != nil { - collectorsMap["updated_by"] = collectorsItem.UpdatedBy - } - if collectorsItem.UpdatedAt != nil { - collectorsMap["updated_at"] = collectorsItem.UpdatedAt.String() - } - if collectorsItem.Enabled != nil { - collectorsMap["enabled"] = collectorsItem.Enabled - } - if collectorsItem.RegistrationCode != nil { - collectorsMap["registration_code"] = collectorsItem.RegistrationCode - } - if collectorsItem.Type != nil { - collectorsMap["type"] = collectorsItem.Type - } - if collectorsItem.CredentialPublicKey != nil { - collectorsMap["credential_public_key"] = collectorsItem.CredentialPublicKey - } - if collectorsItem.FailureCount != nil { - collectorsMap["failure_count"] = collectorsItem.FailureCount - } - if collectorsItem.ApprovedLocalGatewayIP != nil { - collectorsMap["approved_local_gateway_ip"] = collectorsItem.ApprovedLocalGatewayIP - } - if collectorsItem.ApprovedInternetGatewayIP != nil { - collectorsMap["approved_internet_gateway_ip"] = collectorsItem.ApprovedInternetGatewayIP - } - if collectorsItem.LastFailedLocalGatewayIP != nil { - collectorsMap["last_failed_local_gateway_ip"] = collectorsItem.LastFailedLocalGatewayIP - } - if collectorsItem.ResetReason != nil { - collectorsMap["reset_reason"] = collectorsItem.ResetReason - } - if collectorsItem.Hostname != nil { - collectorsMap["hostname"] = collectorsItem.Hostname - } - if collectorsItem.InstallPath != nil { - collectorsMap["install_path"] = collectorsItem.InstallPath - } - if collectorsItem.UsePrivateEndpoint != nil { - collectorsMap["use_private_endpoint"] = collectorsItem.UsePrivateEndpoint - } - if collectorsItem.ManagedBy != nil { - collectorsMap["managed_by"] = collectorsItem.ManagedBy - } - if collectorsItem.TrialExpiry != nil { - collectorsMap["trial_expiry"] = collectorsItem.TrialExpiry.String() - } - if collectorsItem.LastFailedInternetGatewayIP != nil { - collectorsMap["last_failed_internet_gateway_ip"] = collectorsItem.LastFailedInternetGatewayIP - } - if collectorsItem.StatusDescription != nil { - collectorsMap["status_description"] = collectorsItem.StatusDescription - } - if collectorsItem.ResetTime != nil { - collectorsMap["reset_time"] = collectorsItem.ResetTime.String() - } - if collectorsItem.IsPublic != nil { - collectorsMap["is_public"] = collectorsItem.IsPublic - } - if collectorsItem.IsUbiImage != nil { - collectorsMap["is_ubi_image"] = collectorsItem.IsUbiImage - } - - return collectorsMap -} diff --git a/ibm/service/scc/data_source_ibm_scc_posture_scopes_test.go b/ibm/service/scc/data_source_ibm_scc_posture_scopes_test.go deleted file mode 100644 index d6bc28f148..0000000000 --- a/ibm/service/scc/data_source_ibm_scc_posture_scopes_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureListScopesDataSourceBasic(t *testing.T) { - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureListScopesDataSourceConfigBasic(), - Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "id"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "offset"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "limit"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "total_count"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "first.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "last.#"), - resource.TestCheckResourceAttrSet("data.ibm_scc_posture_scopes.list_scopes", "scopes.#"), - ), - }, - }, - }) -} - -func testAccCheckIBMSccPostureListScopesDataSourceConfigBasic() string { - return ` - data "ibm_scc_posture_scopes" "list_scopes" { - } - ` -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_collector.go b/ibm/service/scc/resource_ibm_scc_posture_collector.go deleted file mode 100644 index f7cc425ff2..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_collector.go +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func ResourceIBMSccPostureCollectors() *schema.Resource { - return &schema.Resource{ - ReadContext: resourceIBMSccPostureCollectorsRead, - UpdateContext: resourceIBMSccPostureCollectorsUpdate, - DeleteContext: resourceIBMSccPostureCollectorsDelete, - Importer: &schema.ResourceImporter{}, - DeprecationMessage: "**Removal Notification** Resource Removal: Resource ibm_scc_posture_collector is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_collector", "name"), - Description: "A unique name for your collector.", - }, - "is_public": { - Type: schema.TypeBool, - Required: true, - Description: "Determines whether the collector endpoint is accessible on a public network. If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network.", - }, - "managed_by": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_collector", "managed_by"), - Description: "Determines whether the collector is an IBM or customer-managed virtual machine. Use `ibm` to allow Security and Compliance Center to create, install, and manage the collector on your behalf. The collector is installed in an OpenShift cluster and approved automatically for use. Use `customer` if you would like to install the collector by using your own virtual machine. For more information, check out the [docs](https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-collector).", - }, - "description": { - Type: schema.TypeString, - Optional: true, - Default: "", - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_collector", "description"), - Description: "A detailed description of the collector.", - }, - "passphrase": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_collector", "passphrase"), - Description: "To protect the credentials that you add to the service, a passphrase is used to generate a data encryption key. The key is used to securely store your credentials and prevent anyone from accessing them.", - }, - "is_ubi_image": { - Type: schema.TypeBool, - Optional: true, - Description: "Determines whether the collector has a Ubi image.", - }, - }, - } -} - -func ResourceIBMSccPostureCollectorsValidator() *validate.ResourceValidator { - validateSchema := make([]validate.ValidateSchema, 0) - validateSchema = append(validateSchema, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-.,_\s]*$`, - MinValueLength: 3, - MaxValueLength: 46, - }, - validate.ValidateSchema{ - Identifier: "managed_by", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "customer, ibm", - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[a-zA-Z0-9-._,\s]*$`, - MinValueLength: 1, - MaxValueLength: 255, - }, - validate.ValidateSchema{ - Identifier: "passphrase", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[a-zA-Z0-9-._,\s]*$`, - MinValueLength: 1, - MaxValueLength: 255, - }, - ) - - resourceValidator := validate.ResourceValidator{ResourceName: "ibm_collectors", Schema: validateSchema} - return &resourceValidator -} - -func resourceIBMSccPostureCollectorsCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - createCollectorOptions := &posturemanagementv2.CreateCollectorOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - createCollectorOptions.SetAccountID(userDetails.UserAccount) - - createCollectorOptions.SetName(d.Get("name").(string)) - createCollectorOptions.SetIsPublic(d.Get("is_public").(bool)) - createCollectorOptions.SetManagedBy(d.Get("managed_by").(string)) - if _, ok := d.GetOk("description"); ok { - createCollectorOptions.SetDescription(d.Get("description").(string)) - } - if _, ok := d.GetOk("passphrase"); ok { - createCollectorOptions.SetPassphrase(d.Get("passphrase").(string)) - } - if _, ok := d.GetOk("is_ubi_image"); ok { - createCollectorOptions.SetIsUbiImage(d.Get("is_ubi_image").(bool)) - } - - collector, response, err := postureManagementClient.CreateCollectorWithContext(context, createCollectorOptions) - if err != nil { - log.Printf("[DEBUG] CreateCollectorWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateCollectorWithContext failed %s\n%s", err, response)) - } - - d.SetId(*collector.ID) - - return resourceIBMSccPostureCollectorsRead(context, d, meta) -} - -func resourceIBMSccPostureCollectorsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getCollectorsOptions := &posturemanagementv2.GetCollectorOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getCollectorsOptions.SetAccountID(accountID) - getCollectorsOptions.SetID(d.Id()) - - collector, response, err := postureManagementClient.GetCollectorWithContext(context, getCollectorsOptions) - if err != nil { - if response != nil && response.StatusCode == 404 { - d.SetId("") - return nil - } - log.Printf("[DEBUG] GetCollectorWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetCollectorWithContext failed %s\n%s", err, response)) - } - d.SetId(*(collector.ID)) - return nil -} - -func resourceIBMSccPostureCollectorsUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - updateCollectorOptions := &posturemanagementv2.UpdateCollectorOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - updateCollectorOptions.SetAccountID(userDetails.UserAccount) - - updateCollectorOptions.SetID(d.Id()) - - hasChange := false - - if hasChange { - //updateCollectorOptions.CollectorUpdatePatch, _ = patchVals.AsPatch() - _, response, err := postureManagementClient.UpdateCollectorWithContext(context, updateCollectorOptions) - if err != nil { - log.Printf("[DEBUG] UpdateCollectorWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateCollectorWithContext failed %s\n%s", err, response)) - } - } - - return resourceIBMSccPostureCollectorsRead(context, d, meta) -} - -func resourceIBMSccPostureCollectorsDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - deleteCollectorOptions := &posturemanagementv2.DeleteCollectorOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - deleteCollectorOptions.SetAccountID(userDetails.UserAccount) - - deleteCollectorOptions.SetID(d.Id()) - - response, err := postureManagementClient.DeleteCollectorWithContext(context, deleteCollectorOptions) - if err != nil { - log.Printf("[DEBUG] DeleteCollectorWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteCollectorWithContext failed %s\n%s", err, response)) - } - - d.SetId("") - - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_collector_test.go b/ibm/service/scc/resource_ibm_scc_posture_collector_test.go deleted file mode 100644 index 78f18537fb..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_collector_test.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - "time" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func TestAccIBMSccPostureCollectorsBasic(t *testing.T) { - var conf posturemanagementv2.Collector - name := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - isPublic := "true" - managedBy := "customer" - nameUpdate := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - isPublicUpdate := "true" - managedByUpdate := "customer" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMSccPostureCollectorsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureCollectorsConfigBasic(name, isPublic, managedBy), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureCollectorsExists("ibm_scc_posture_collector.collectors", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "name", name), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_public", isPublic), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "managed_by", managedBy), - ), - }, - { - Config: testAccCheckIBMSccPostureCollectorsConfigBasic(nameUpdate, isPublicUpdate, managedByUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_public", isPublicUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "managed_by", managedByUpdate), - ), - }, - }, - }) -} - -func TestAccIBMCollectorsAllArgs(t *testing.T) { - var conf posturemanagementv2.Collector - name := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - isPublic := "false" - managedBy := "ibm" - description := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - passphrase := fmt.Sprintf("tf_passphrase_%d", time.Now().UnixNano()) - isUbiImage := "true" - nameUpdate := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - isPublicUpdate := "true" - managedByUpdate := "customer" - descriptionUpdate := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - passphraseUpdate := fmt.Sprintf("tf_passphrase_%d", time.Now().UnixNano()) - isUbiImageUpdate := "false" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMSccPostureCollectorsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureCollectorsConfig(name, isPublic, managedBy, description, passphrase, isUbiImage), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureCollectorsExists("ibm_scc_posture_collector.collectors", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "name", name), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_public", isPublic), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "managed_by", managedBy), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "description", description), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "passphrase", passphrase), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_ubi_image", isUbiImage), - ), - }, - { - Config: testAccCheckIBMSccPostureCollectorsConfig(nameUpdate, isPublicUpdate, managedByUpdate, descriptionUpdate, passphraseUpdate, isUbiImageUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_public", isPublicUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "managed_by", managedByUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "passphrase", passphraseUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_collector.collectors", "is_ubi_image", isUbiImageUpdate), - ), - }, - { - ResourceName: "ibm_scc_posture_collector.collectors", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccCheckIBMSccPostureCollectorsConfigBasic(name string, isPublic string, managedBy string) string { - return fmt.Sprintf(` - - resource "ibm_scc_posture_collector" "collectors" { - name = "%s" - is_public = %s - managed_by = "%s" - } - `, name, isPublic, managedBy) -} - -func testAccCheckIBMSccPostureCollectorsConfig(name string, isPublic string, managedBy string, description string, passphrase string, isUbiImage string) string { - return fmt.Sprintf(` - - resource "ibm_scc_posture_collector" "collectors" { - name = "%s" - is_public = %s - managed_by = "%s" - description = "%s" - passphrase = "%s" - is_ubi_image = %s - } - `, name, isPublic, managedBy, description, passphrase, isUbiImage) -} - -func testAccCheckIBMSccPostureCollectorsExists(n string, obj posturemanagementv2.Collector) resource.TestCheckFunc { - - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - - listCollectorsOptions := &posturemanagementv2.ListCollectorsOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - - listCollectorsOptions.SetAccountID(userDetails.UserAccount) - - newCollector, _, err := postureManagementClient.ListCollectors(listCollectorsOptions) - if err != nil { - return err - } - fmt.Println(rs) - obj = (newCollector.Collectors[0]) - return nil - } -} - -func testAccCheckIBMSccPostureCollectorsDestroy(s *terraform.State) error { - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - for _, rs := range s.RootModule().Resources { - if rs.Type != "ibm_scc_posture_collector" { - continue - } - - listCollectorsOptions := &posturemanagementv2.ListCollectorsOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - - listCollectorsOptions.SetAccountID(userDetails.UserAccount) - - // Try to find the key - _, response, err := postureManagementClient.ListCollectors(listCollectorsOptions) - - if err == nil { - return err //fmt.Errorf("collectors still exists: %s", rs.Primary.ID) - } else if response.StatusCode != 404 { - return fmt.Errorf("[ERROR] Error checking for collectors (%s) has been destroyed: %s", rs.Primary.ID, err) - } - } - - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_credential.go b/ibm/service/scc/resource_ibm_scc_posture_credential.go deleted file mode 100644 index 88a5713de9..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_credential.go +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/go-sdk-core/v5/core" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func ResourceIBMSccPostureCredentials() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceIBMSccPostureCredentialsCreate, - ReadContext: resourceIBMSccPostureCredentialsRead, - UpdateContext: resourceIBMSccPostureCredentialsUpdate, - DeleteContext: resourceIBMSccPostureCredentialsDelete, - Importer: &schema.ResourceImporter{}, - DeprecationMessage: "**Removal Notification** Resource Removal: Resource ibm_scc_posture_credential is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - Description: "Credentials status enabled/disbaled.", - }, - "type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_credential", "type"), - Description: "Credentials type.", - }, - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_credential", "name"), - Description: "Credentials name.", - }, - "description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_credential", "description"), - Description: "Credentials description.", - }, - "display_fields": { - Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, - Required: true, - Description: "Details the fields on the credential. This will change as per credential type selected.", - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ibm_api_key": { - Type: schema.TypeString, - Optional: true, - Description: "The IBM Cloud API Key. This is mandatory for IBM Credential Type ie when type=ibm_cloud.", - }, - }, - }, - }, - "purpose": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_credential", "purpose"), - Description: "Purpose for which the credential is created.", - }, - }, - } -} - -func ResourceIBMSccPostureCredentialsValidator() *validate.ResourceValidator { - validateSchema := make([]validate.ValidateSchema, 0) - validateSchema = append(validateSchema, - validate.ValidateSchema{ - Identifier: "type", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "aws_cloud, azure_cloud, database, ibm_cloud, kerberos_windows, ms_365, openstack_cloud, username_password", - }, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-._,\s]*$`, - MinValueLength: 3, - MaxValueLength: 30, - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-._,\s]*$`, - MinValueLength: 1, - MaxValueLength: 255, - }, - validate.ValidateSchema{ - Identifier: "purpose", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "discovery_collection, discovery_collection_remediation, discovery_fact_collection, discovery_fact_collection_remediation, remediation", - Regexp: `^[a-zA-Z0-9-\\.,_\\s]*$`, - MinValueLength: 1, - MaxValueLength: 100, - }, - ) - - resourceValidator := validate.ResourceValidator{ResourceName: "ibm_scc_posture_credentials", Schema: validateSchema} - return &resourceValidator -} - -func resourceIBMSccPostureCredentialsCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - createCredentialOptions := &posturemanagementv2.CreateCredentialOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - createCredentialOptions.SetAccountID(userDetails.UserAccount) - - createCredentialOptions.SetEnabled(d.Get("enabled").(bool)) - createCredentialOptions.SetType(d.Get("type").(string)) - createCredentialOptions.SetName(d.Get("name").(string)) - createCredentialOptions.SetDescription(d.Get("description").(string)) - displayFields := resourceIBMSccPostureCredentialsMapToNewCredentialDisplayFields(d.Get("display_fields.0").(map[string]interface{})) - createCredentialOptions.SetDisplayFields(&displayFields) - createCredentialOptions.SetPurpose(d.Get("purpose").(string)) - - credential, response, err := postureManagementClient.CreateCredentialWithContext(context, createCredentialOptions) - if err != nil { - log.Printf("[DEBUG] CreateCredentialWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateCredentialWithContext failed %s\n%s", err, response)) - } - - d.SetId(*credential.ID) - - return resourceIBMSccPostureCredentialsRead(context, d, meta) -} - -func resourceIBMSccPostureCredentialsMapToNewCredentialDisplayFields(newCredentialDisplayFieldsMap map[string]interface{}) posturemanagementv2.NewCredentialDisplayFields { - newCredentialDisplayFields := posturemanagementv2.NewCredentialDisplayFields{} - - if newCredentialDisplayFieldsMap["ibm_api_key"] != nil { - newCredentialDisplayFields.IBMAPIKey = core.StringPtr(newCredentialDisplayFieldsMap["ibm_api_key"].(string)) - } - - return newCredentialDisplayFields -} - -func resourceIBMSccPostureCredentialsMapToUpdateCredentialDisplayFields(updateCredentialDisplayFieldsMap map[string]interface{}) posturemanagementv2.UpdateCredentialDisplayFields { - updateCredentialDisplayFields := posturemanagementv2.UpdateCredentialDisplayFields{} - - if updateCredentialDisplayFieldsMap["ibm_api_key"] != nil { - updateCredentialDisplayFields.IBMAPIKey = core.StringPtr(updateCredentialDisplayFieldsMap["ibm_api_key"].(string)) - } - - return updateCredentialDisplayFields -} - -func resourceIBMSccPostureCredentialsRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getCredentialsOptions := &posturemanagementv2.GetCredentialOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getCredentialsOptions.SetAccountID(accountID) - getCredentialsOptions.SetID(d.Id()) - - credential, response, err := postureManagementClient.GetCredentialWithContext(context, getCredentialsOptions) - if err != nil { - if response != nil && response.StatusCode == 404 { - d.SetId("") - return nil - } - log.Printf("[DEBUG] GetCredentialWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetCredentialWithContext failed %s\n%s", err, response)) - } - d.SetId(*(credential.ID)) - return nil -} - -func resourceIBMSccPostureCredentialsNewCredentialDisplayFieldsToMap(newCredentialDisplayFields posturemanagementv2.NewCredentialDisplayFields) map[string]interface{} { - newCredentialDisplayFieldsMap := map[string]interface{}{} - - if newCredentialDisplayFields.IBMAPIKey != nil { - newCredentialDisplayFieldsMap["ibm_api_key"] = newCredentialDisplayFields.IBMAPIKey - } - - return newCredentialDisplayFieldsMap -} - -func resourceIBMSccPostureCredentialsUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - updateCredentialOptions := &posturemanagementv2.UpdateCredentialOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - updateCredentialOptions.SetAccountID(userDetails.UserAccount) - - updateCredentialOptions.SetID(d.Id()) - - updateCredentialOptions.SetEnabled(d.Get("enabled").(bool)) - - updateCredentialOptions.SetType(d.Get("type").(string)) - - updateCredentialOptions.SetName(d.Get("name").(string)) - - updateCredentialOptions.SetDescription(d.Get("description").(string)) - - updateCredentialDisplayFieldsModel := &posturemanagementv2.UpdateCredentialDisplayFields{ - IBMAPIKey: core.StringPtr("sample_api_key"), - } - //displayFields := resourceIBMSccPostureV2CredentialsMapToUpdateCredentialDisplayFields(d.Get("display_fields.0").(map[string]interface{})) - updateCredentialOptions.SetDisplayFields(updateCredentialDisplayFieldsModel) - - updateCredentialOptions.SetPurpose(d.Get("purpose").(string)) - - _, response, err := postureManagementClient.UpdateCredentialWithContext(context, updateCredentialOptions) - if err != nil { - log.Printf("[DEBUG] UpdateCredentialWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateCredentialWithContext failed %s\n%s", err, response)) - } - - return resourceIBMSccPostureCredentialsRead(context, d, meta) -} - -func resourceIBMSccPostureCredentialsDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - deleteCredentialOptions := &posturemanagementv2.DeleteCredentialOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - deleteCredentialOptions.SetAccountID(userDetails.UserAccount) - - deleteCredentialOptions.SetID(d.Id()) - - response, err := postureManagementClient.DeleteCredentialWithContext(context, deleteCredentialOptions) - if err != nil { - log.Printf("[DEBUG] DeleteCredentialWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteCredentialWithContext failed %s\n%s", err, response)) - } - - d.SetId("") - - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_credential_test.go b/ibm/service/scc/resource_ibm_scc_posture_credential_test.go deleted file mode 100644 index 9b8a2e12c6..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_credential_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func TestAccIBMSccPostureCredentialsBasic(t *testing.T) { - var conf posturemanagementv2.Credential - enabled := "true" - typeVar := "ibm_cloud" - name := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - description := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - purpose := "discovery_collection" - enabledUpdate := "true" - typeVarUpdate := "ibm_cloud" - nameUpdate := fmt.Sprintf("tf_name_%d", acctest.RandIntRange(10, 100)) - descriptionUpdate := fmt.Sprintf("tf_description_%d", acctest.RandIntRange(10, 100)) - purposeUpdate := "discovery_fact_collection_remediation" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMSccPostureCredentialsDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureCredentialsConfigBasic(enabled, typeVar, name, description, purpose), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureCredentialsExists("ibm_scc_posture_credential.credentials", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "enabled", enabled), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "type", typeVar), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "name", name), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "description", description), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "purpose", purpose), - ), - }, - { - Config: testAccCheckIBMSccPostureCredentialsConfigBasic(enabledUpdate, typeVarUpdate, nameUpdate, descriptionUpdate, purposeUpdate), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureCredentialsExists("ibm_scc_posture_credential.credentials", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "enabled", enabledUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "type", typeVarUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_credential.credentials", "purpose", purposeUpdate), - ), - }, - { - ResourceName: "ibm_scc_posture_credential.credentials", - ImportState: true, - //ImportStateVerify: true, - }, - }, - }) -} - -func testAccCheckIBMSccPostureCredentialsConfigBasic(enabled string, typeVar string, name string, description string, purpose string) string { - return fmt.Sprintf(` - - resource "ibm_scc_posture_credential" "credentials" { - enabled = %s - type = "%s" - name = "%s" - description = "%s" - display_fields { - ibm_api_key = "sample_api_key" - - } - purpose = "%s" - } - `, enabled, typeVar, name, description, purpose) -} - -func testAccCheckIBMSccPostureCredentialsExists(n string, obj posturemanagementv2.Credential) resource.TestCheckFunc { - - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - - listCredentialsOptions := &posturemanagementv2.ListCredentialsOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - - listCredentialsOptions.SetAccountID(userDetails.UserAccount) - - newCredential, _, err := postureManagementClient.ListCredentials(listCredentialsOptions) - if err != nil { - return err - } - fmt.Println(rs) - obj = (newCredential.Credentials[0]) - return nil - } -} - -func testAccCheckIBMSccPostureCredentialsDestroy(s *terraform.State) error { - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - for _, rs := range s.RootModule().Resources { - if rs.Type != "ibm_scc_posture_credential" { - continue - } - - listCredentialsOptions := &posturemanagementv2.ListCredentialsOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - listCredentialsOptions.SetAccountID(userDetails.UserAccount) - - // Try to find the key - _, response, err := postureManagementClient.ListCredentials(listCredentialsOptions) - - if err == nil { - return nil - } else if response.StatusCode != 404 { - return fmt.Errorf("[ERROR] Error checking for credentials (%s) has been destroyed: %s", rs.Primary.ID, err) - } - } - - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_import_profile.go b/ibm/service/scc/resource_ibm_scc_posture_import_profile.go deleted file mode 100644 index 20867e9a49..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_import_profile.go +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "os" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func ResourceIBMSccPostureProfileImport() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceIBMSccPostureProfileImport, - ReadContext: resourceIBMSccPostureProfileImportRead, - UpdateContext: resourceIBMSccPostureProfileImportRead, - DeleteContext: resourceIBMSccPostureProfileImportDelete, - Importer: &schema.ResourceImporter{}, - DeprecationMessage: "**Removal Notification** Resource Removal: Resource ibm_scc_posture_profile_import is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "file": { - Type: schema.TypeString, - Description: "File to import", - Required: true, - ForceNew: true, - }, - "name": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "The name of the profile.", - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: "A description of the profile.", - }, - "version": { - Type: schema.TypeInt, - Computed: true, - Description: "The version of the profile.", - }, - "created_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who created the profile.", - }, - "modified_by": { - Type: schema.TypeString, - Computed: true, - Description: "The user who last modified the profile.", - }, - "base_profile": { - Type: schema.TypeString, - Computed: true, - Description: "The base profile that the controls are pulled from.", - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: "The type of profile.", - }, - "no_of_controls": { - Type: schema.TypeInt, - Computed: true, - Description: "no of Controls.", - }, - "created_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was created in UTC.", - }, - "updated_at": { - Type: schema.TypeString, - Computed: true, - Description: "The time that the profile was most recently modified in UTC.", - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "The profile status. If the profile is enabled, the value is true. If the profile is disabled, the value is false.", - }, - }, - } -} - -func resourceIBMSccPostureProfileImport(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - importProfilesOptions := &posturemanagementv2.ImportProfilesOptions{} - accountID := userDetails.UserAccount - importProfilesOptions.SetAccountID(accountID) - - f, err := os.Open(d.Get("file").(string)) - if err != nil { - log.Printf("[DEBUG] ImportProfilesWithContext failed to read file %s", err) - return diag.FromErr(fmt.Errorf("ImportProfilesWithContext failed to read file %s", err)) - } - importProfilesOptions.SetFile(f) - - profile, response, err := postureManagementClient.ImportProfilesWithContext(context, importProfilesOptions) - if err != nil { - log.Printf("[DEBUG] ImportProfilesWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("ImportProfilesWithContext failed %s\n%s", err, response)) - } - - d.SetId(*profile.ProfileID) - - return resourceIBMSccPostureProfileImportRead(context, d, meta) -} - -func resourceIBMSccPostureProfileImportRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getProfileOptions := &posturemanagementv2.GetProfileOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getProfileOptions.SetAccountID(accountID) - - getProfileOptions.SetID(d.Id()) - getProfileOptions.SetProfileType("custom") - - profile, response, err := postureManagementClient.GetProfileWithContext(context, getProfileOptions) - if err != nil { - log.Printf("[DEBUG] GetProfileWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetProfileWithContext failed %s\n%s", err, response)) - } - - d.SetId(*profile.ID) - if err = d.Set("name", profile.Name); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting name: %s", err)) - } - if err = d.Set("description", profile.Description); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting description: %s", err)) - } - if err = d.Set("version", flex.IntValue(profile.Version)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting version: %s", err)) - } - if err = d.Set("created_by", profile.CreatedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_by: %s", err)) - } - if err = d.Set("modified_by", profile.ModifiedBy); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting modified_by: %s", err)) - } - if err = d.Set("base_profile", profile.BaseProfile); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting base_profile: %s", err)) - } - if err = d.Set("type", profile.Type); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting type: %s", err)) - } - if err = d.Set("no_of_controls", flex.IntValue(profile.NoOfControls)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting no_of_controls: %s", err)) - } - if err = d.Set("created_at", flex.DateTimeToString(profile.CreatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting created_at: %s", err)) - } - if err = d.Set("updated_at", flex.DateTimeToString(profile.UpdatedAt)); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting updated_at: %s", err)) - } - if err = d.Set("enabled", profile.Enabled); err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error setting enabled: %s", err)) - } - - return nil -} - -func resourceIBMSccPostureProfileImportDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - d.SetId("") - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_import_profile_test.go b/ibm/service/scc/resource_ibm_scc_posture_import_profile_test.go deleted file mode 100644 index 60c33c8745..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_import_profile_test.go +++ /dev/null @@ -1,77 +0,0 @@ -package scc_test - -import ( - "fmt" - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" -) - -func TestAccIBMSccPostureProfileImportBasic(t *testing.T) { - name := "ibm_scc_posture_profile_import." + "profiles" - file := "../../test-fixtures/import_profile.csv" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckSccPostureProfileImportConfigBasic(file), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(name, "file", file), - resource.TestCheckResourceAttr(name, "enabled", "true"), - resource.TestCheckResourceAttr(name, "type", "custom"), - testAccCheckSccPostureProfileImportRemoveImportedRecords(name), - ), - }, - { - ResourceName: name, - ImportState: true, - }, - }, - }) -} - -func testAccCheckSccPostureProfileImportConfigBasic(file string) string { - return fmt.Sprintf(` - resource "ibm_scc_posture_profile_import" "profiles" { - file = "%[1]s" - }`, file) -} - -func testAccCheckSccPostureProfileImportRemoveImportedRecords(n string) resource.TestCheckFunc { - return func(s *terraform.State) error { - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("[ERROR] Not found: %s", n) - } - - if rs.Primary.ID == "" { - return fmt.Errorf("[ERROR] No Record ID is set") - } - deleteProfileOptions := &posturemanagementv2.DeleteProfileOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - - accountID := userDetails.UserAccount - deleteProfileOptions.SetAccountID(accountID) - - deleteProfileOptions.SetID(rs.Primary.ID) - _, err = postureManagementClient.DeleteProfile(deleteProfileOptions) - if err != nil { - return err - } - return nil - } -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation.go b/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation.go deleted file mode 100644 index 6e2a6e32c1..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - "strings" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" - "github.com/go-openapi/strfmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func ResourceIBMSccPostureScanInitiateValidation() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceIBMSccPostureScanInitiateValidation, - ReadContext: resourceIBMSccPostureScanInitiateRead, - DeleteContext: resourceIBMSccPostureScanInitiateDelete, - Importer: &schema.ResourceImporter{}, - DeprecationMessage: "**Removal Notification** Resource Removal: Resource ibm_scc_posture_scan_initiate_validation is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "scope_id": { - Type: schema.TypeString, - Description: "The unique ID of the scope.", - ForceNew: true, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scan_initiate_validation", "scope_id"), - }, - "profile_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The unique ID of the profile.", - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scan_initiate_validation", "profile_id"), - }, - "group_profile_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "The ID of the profile group.", - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scan_initiate_validation", "group_profile_id"), - }, - "name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "The name of a scheduled scan.", - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scan_initiate_validation", "name"), - }, - "description": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "The description of a scheduled scan.", - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scan_initiate_validation", "description"), - }, - "frequency": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: "The frequency at which a scan is run specified in milliseconds.", - }, - "no_of_occurrences": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: "The number of times that a scan should be run.", - }, - "end_time": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "The date on which a scan should stop running specified in UTC.", - }, - "result": { - Type: schema.TypeString, - Computed: true, - Description: "The ID of the profile group.", - }, - }, - } -} - -func ResourceIBMSccPostureScanInitiateValidationValidator() *validate.ResourceValidator { - validateSchema := make([]validate.ValidateSchema, 0) - validateSchema = append(validateSchema, - validate.ValidateSchema{ - Identifier: "scope_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[0-9]*$`, - MinValueLength: 1, - MaxValueLength: 20, - }, - validate.ValidateSchema{ - Identifier: "profile_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[0-9]*$`, - MinValueLength: 1, - MaxValueLength: 20, - }, - validate.ValidateSchema{ - Identifier: "group_profile_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[0-9]*$`, - MinValueLength: 1, - MaxValueLength: 20, - }, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[a-zA-Z0-9-\.,_\s]*$`, - MinValueLength: 1, - MaxValueLength: 32, - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Optional: true, - Regexp: `^[a-zA-Z0-9-._,\s]*$`, - MinValueLength: 1, - MaxValueLength: 255, - }, - ) - - resourceValidator := validate.ResourceValidator{ResourceName: "ibm_scc_posture_scan_initiate_validation", Schema: validateSchema} - return &resourceValidator -} - -func resourceIBMSccPostureScanInitiateValidation(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - createValidationOptions := &posturemanagementv2.CreateValidationOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - createValidationOptions.SetAccountID(userDetails.UserAccount) - - createValidationOptions.SetScopeID(d.Get("scope_id").(string)) - createValidationOptions.SetProfileID(d.Get("profile_id").(string)) - - if _, ok := d.GetOk("group_profile_id"); ok { - createValidationOptions.SetGroupProfileID(d.Get("group_profile_id").(string)) - } - - if _, ok := d.GetOk("name"); ok { - createValidationOptions.SetName(d.Get("name").(string)) - } - - if _, ok := d.GetOk("description"); ok { - createValidationOptions.SetDescription(d.Get("description").(string)) - } - - if frequency, ok := d.GetOk("frequency"); ok { - createValidationOptions.SetFrequency(int64(frequency.(int))) - } - - if no_of_occurrences, ok := d.GetOk("no_of_occurrences"); ok { - createValidationOptions.SetNoOfOccurrences(int64(no_of_occurrences.(int))) - } - - if end_time, ok := d.GetOk("end_time"); ok { - createValidationOptions.SetEndTime(end_time.(*strfmt.DateTime)) - } - - result, response, err := postureManagementClient.CreateValidationWithContext(context, createValidationOptions) - if result == nil || err != nil { - log.Printf("[DEBUG] CreateValidationWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateValidationWithContext failed %s\n%s", err, response)) - } - - if *result.Result { - correlationId := strings.Split(*result.Message, "= ")[1] - d.SetId(correlationId) - d.Set("result", fmt.Sprintf("%v", *result.Result)) - return nil - } - - return diag.FromErr(fmt.Errorf("CreateValidationWithContext failed %s\n%s", err, *result.Message)) -} - -func resourceIBMSccPostureScanInitiateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - return nil -} - -func resourceIBMSccPostureScanInitiateDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - d.SetId("") - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation_test.go b/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation_test.go deleted file mode 100644 index 137f978e92..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_scan_initiate_validation_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package scc_test - -import ( - "testing" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" -) - -func TestAccIBMSccPostureScanInitiateValidationBasic(t *testing.T) { - name := "ibm_scc_posture_scan_initiate_validation." + "scans" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckSccPostureScanInitiateValidationConfigBasic(), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr(name, "result", "true"), - ), - }, - { - ResourceName: name, - ImportState: true, - }, - }, - }) -} - -func testAccCheckSccPostureScanInitiateValidationConfigBasic() string { - return `resource "ibm_scc_posture_scan_initiate_validation" "scans" { - scope_id = "70324" - profile_id = "425" - name = "Test1Sept22_Scan" - description = "Test1Sept22_Scan on scope 70324" - frequency = 6300 - no_of_occurrences = 9 - }` -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_scope.go b/ibm/service/scc/resource_ibm_scc_posture_scope.go deleted file mode 100644 index 37ee48143a..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_scope.go +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc - -import ( - "context" - "fmt" - "log" - - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func ResourceIBMSccPostureScopes() *schema.Resource { - return &schema.Resource{ - CreateContext: resourceIBMSccPostureScopesCreate, - ReadContext: resourceIBMSccPostureScopesRead, - UpdateContext: resourceIBMSccPostureScopesUpdate, - DeleteContext: resourceIBMSccPostureScopesDelete, - Importer: &schema.ResourceImporter{}, - DeprecationMessage: "**Removal Notification** Resource Removal: Resource ibm_scc_posture_scope is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).", - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scope", "name"), - Description: "A unique name for your scope.", - }, - "description": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scope", "description"), - Description: "A detailed description of the scope.", - }, - "collector_ids": { - Type: schema.TypeList, - Required: true, - Description: "The unique IDs of the collectors that are attached to the scope.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "credential_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scope", "credential_id"), - Description: "The unique identifier of the credential.", - }, - "credential_type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validate.InvokeValidator("ibm_scc_posture_scope", "credential_type"), - Description: "The environment that the scope is targeted to.", - }, - }, - } -} - -func ResourceIBMSccPostureScopesValidator() *validate.ResourceValidator { - validateSchema := make([]validate.ValidateSchema, 0) - validateSchema = append(validateSchema, - validate.ValidateSchema{ - Identifier: "name", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-\\.,_\s]*$`, - MinValueLength: 3, - MaxValueLength: 50, - }, - validate.ValidateSchema{ - Identifier: "description", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-\\.,_\s]*$`, - MinValueLength: 1, - MaxValueLength: 255, - }, - validate.ValidateSchema{ - Identifier: "credential_id", - ValidateFunctionIdentifier: validate.ValidateRegexpLen, - Type: validate.TypeString, - Required: true, - Regexp: `^[a-zA-Z0-9-\\.,_\\s]*$`, - MinValueLength: 1, - MaxValueLength: 50, - }, - validate.ValidateSchema{ - Identifier: "credential_type", - ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, - Type: validate.TypeString, - Required: true, - AllowedValues: "aws, azure, gcp, hosted, ibm, on_premise, openstack, services", - }, - ) - - resourceValidator := validate.ResourceValidator{ResourceName: "ibm_scc_posture_scope", Schema: validateSchema} - return &resourceValidator -} - -func resourceIBMSccPostureScopesCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - createScopeOptions := &posturemanagementv2.CreateScopeOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - createScopeOptions.SetAccountID(userDetails.UserAccount) - - createScopeOptions.SetName(d.Get("name").(string)) - createScopeOptions.SetDescription(d.Get("description").(string)) - collector_ids_int := d.Get("collector_ids").([]interface{}) - collector_ids := make([]string, len(collector_ids_int)) - for i, collector_id := range collector_ids_int { - collector_ids[i] = collector_id.(string) - } - createScopeOptions.SetCollectorIds(collector_ids) //[]string{ - createScopeOptions.SetCredentialID(d.Get("credential_id").(string)) - createScopeOptions.SetCredentialType(d.Get("credential_type").(string)) - - scope, response, err := postureManagementClient.CreateScopeWithContext(context, createScopeOptions) - if err != nil { - log.Printf("[DEBUG] CreateScopeWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("CreateScopeWithContext failed %s\n%s", err, response)) - } - - d.SetId(*scope.ID) - - return resourceIBMSccPostureScopesRead(context, d, meta) -} - -func resourceIBMSccPostureScopesRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - getScopesOptions := &posturemanagementv2.GetScopeDetailsOptions{} - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - - accountID := userDetails.UserAccount - getScopesOptions.SetAccountID(accountID) - getScopesOptions.SetID(d.Id()) - - scope, response, err := postureManagementClient.GetScopeDetailsWithContext(context, getScopesOptions) - - if err != nil { - if response != nil && response.StatusCode == 404 { - d.SetId("") - return nil - } - log.Printf("[DEBUG] GetScopeDetailsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("GetScopeDetailsWithContext failed %s\n%s", err, response)) - } - d.SetId(*scope.ID) - - return nil -} - -func resourceIBMSccPostureScopesUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - updateScopeDetailsOptions := &posturemanagementv2.UpdateScopeDetailsOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - updateScopeDetailsOptions.SetAccountID(userDetails.UserAccount) - - hasChange := false - - updateScopeDetailsOptions.SetID(d.Id()) - - if d.HasChange("name") { - updateScopeDetailsOptions.SetName(d.Get("name").(string)) - hasChange = true - } - if d.HasChange("description") { - updateScopeDetailsOptions.SetDescription(d.Get("description").(string)) - hasChange = true - } - - if hasChange { - _, response, err := postureManagementClient.UpdateScopeDetailsWithContext(context, updateScopeDetailsOptions) - if err != nil { - log.Printf("[DEBUG] UpdateScopeDetailsWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("UpdateScopeDetailsWithContext failed %s\n%s", err, response)) - } - } - - return resourceIBMSccPostureScopesRead(context, d, meta) -} - -func resourceIBMSccPostureScopesDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - postureManagementClient, err := meta.(conns.ClientSession).PostureManagementV2() - if err != nil { - return diag.FromErr(err) - } - - deleteScopeOptions := &posturemanagementv2.DeleteScopeOptions{} - - userDetails, err := meta.(conns.ClientSession).BluemixUserDetails() - if err != nil { - return diag.FromErr(fmt.Errorf("[ERROR] Error getting userDetails %s", err)) - } - deleteScopeOptions.SetAccountID(userDetails.UserAccount) - - deleteScopeOptions.SetID(d.Id()) - - response, err := postureManagementClient.DeleteScopeWithContext(context, deleteScopeOptions) - if err != nil { - log.Printf("[DEBUG] DeleteScopeWithContext failed %s\n%s", err, response) - return diag.FromErr(fmt.Errorf("DeleteScopeWithContext failed %s\n%s", err, response)) - } - - d.SetId("") - - return nil -} diff --git a/ibm/service/scc/resource_ibm_scc_posture_scope_test.go b/ibm/service/scc/resource_ibm_scc_posture_scope_test.go deleted file mode 100644 index 222466f456..0000000000 --- a/ibm/service/scc/resource_ibm_scc_posture_scope_test.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright IBM Corp. 2021 All Rights Reserved. -// Licensed under the Mozilla Public License v2.0 - -package scc_test - -import ( - "fmt" - "testing" - "time" - - acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" - "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - - "github.com/IBM/scc-go-sdk/v4/posturemanagementv2" -) - -func TestAccIBMSccPostureScopesBasic(t *testing.T) { - var conf posturemanagementv2.ScopeItem - name := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - description := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - credentialType := "ibm" - nameUpdate := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - descriptionUpdate := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - credentialTypeUpdate := "ibm" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMSccPostureScopesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureScopesConfigBasic(name, description, acc.Scc_posture_credential_id_scope, credentialType, acc.Scc_posture_collector_id_scope), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureScopesExists("ibm_scc_posture_scope.scopes", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "name", name), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "description", description), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_id", acc.Scc_posture_credential_id_scope), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_type", credentialType), - ), - }, - { - Config: testAccCheckIBMSccPostureScopesConfigBasic(nameUpdate, descriptionUpdate, acc.Scc_posture_credential_id_scope_update, credentialTypeUpdate, acc.Scc_posture_collector_id_scope_update), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_id", acc.Scc_posture_credential_id_scope_update), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_type", credentialTypeUpdate), - ), - }, - }, - }) -} - -func TestAccIBMScopesAllArgs(t *testing.T) { - var conf posturemanagementv2.ScopeItem - name := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - description := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - credentialType := "ibm" - nameUpdate := fmt.Sprintf("tf_name_%d", time.Now().UnixNano()) - descriptionUpdate := fmt.Sprintf("tf_description_%d", time.Now().UnixNano()) - credentialTypeUpdate := "ibm" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { acc.TestAccPreCheck(t) }, - Providers: acc.TestAccProviders, - CheckDestroy: testAccCheckIBMSccPostureScopesDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckIBMSccPostureScopesConfig(name, description, acc.Scc_posture_credential_id_scope, credentialType, acc.Scc_posture_collector_id_scope), - Check: resource.ComposeAggregateTestCheckFunc( - testAccCheckIBMSccPostureScopesExists("ibm_scc_posture_scope.scopes", conf), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "name", name), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "description", description), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_id", acc.Scc_posture_credential_id_scope), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_type", credentialType), - ), - }, - { - Config: testAccCheckIBMSccPostureScopesConfig(nameUpdate, descriptionUpdate, acc.Scc_posture_credential_id_scope_update, credentialTypeUpdate, acc.Scc_posture_collector_id_scope_update), - Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "name", nameUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "description", descriptionUpdate), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_id", acc.Scc_posture_credential_id_scope_update), - resource.TestCheckResourceAttr("ibm_scc_posture_scope.scopes", "credential_type", credentialTypeUpdate), - ), - }, - { - ResourceName: "ibm_scc_posture_scope.scopes", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func testAccCheckIBMSccPostureScopesConfigBasic(name string, description string, credentialID string, credentialType string, collectorID []string) string { - return fmt.Sprintf(` - - resource "ibm_scc_posture_scope" "scopes" { - name = "%s" - description = "%s" - credential_id = "%s" - credential_type = "%s" - collector_ids = %q - } - `, name, description, credentialID, credentialType, collectorID) -} - -func testAccCheckIBMSccPostureScopesConfig(name string, description string, credentialID string, credentialType string, collectorID []string) string { - return fmt.Sprintf(` - - resource "ibm_scc_posture_scope" "scopes" { - name = "%s" - description = "%s" - credential_id = "%s" - credential_type = "%s" - collector_ids = %q - } - `, name, description, credentialID, credentialType, collectorID) -} - -func testAccCheckIBMSccPostureScopesExists(n string, obj posturemanagementv2.ScopeItem) resource.TestCheckFunc { - - return func(s *terraform.State) error { - rs, ok := s.RootModule().Resources[n] - if !ok { - return fmt.Errorf("Not found: %s", n) - } - - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - - listScopesOptions := &posturemanagementv2.ListScopesOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - listScopesOptions.SetAccountID(userDetails.UserAccount) - - newScope, _, err := postureManagementClient.ListScopes(listScopesOptions) - if err != nil { - return err - } - fmt.Println(rs) - obj = (newScope.Scopes[0]) - return nil - } -} - -func testAccCheckIBMSccPostureScopesDestroy(s *terraform.State) error { - postureManagementClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).PostureManagementV2() - if err != nil { - return err - } - for _, rs := range s.RootModule().Resources { - if rs.Type != "ibm_scc_posture_scope" { - continue - } - - listScopesOptions := &posturemanagementv2.ListScopesOptions{} - - userDetails, err := acc.TestAccProvider.Meta().(conns.ClientSession).BluemixUserDetails() - if err != nil { - return err - } - - listScopesOptions.SetAccountID(userDetails.UserAccount) - - // Try to find the key - _, response, err := postureManagementClient.ListScopes(listScopesOptions) - - if err == nil { - return err - } else if response.StatusCode != 404 { - return fmt.Errorf("[ERROR] Error checking for scopes (%s) has been destroyed: %s", rs.Primary.ID, err) - } - } - - return nil -} From 6b57556239ce5ca07fd26633c8166d11e7436a49 Mon Sep 17 00:00:00 2001 From: jayvyas Date: Tue, 18 Jul 2023 12:17:36 +0530 Subject: [PATCH 3/3] review comments updated --- CHANGELOG.md | 114 ++++++++ .../d/scc_posture_collector.html.markdown | 98 ------- .../d/scc_posture_collectors.html.markdown | 86 ------ .../d/scc_posture_credential.html.markdown | 104 ------- .../d/scc_posture_credentials.html.markdown | 102 ------- .../d/scc_posture_group_profile.html.markdown | 60 ---- .../d/scc_posture_latest_scans.html.markdown | 75 ----- .../docs/d/scc_posture_profile.html.markdown | 68 ----- .../docs/d/scc_posture_profiles.html.markdown | 62 ----- .../scc_posture_scan_summaries.html.markdown | 93 ------- .../d/scc_posture_scans_summary.html.markdown | 75 ----- .../docs/d/scc_posture_scope.html.markdown | 262 ------------------ ...cc_posture_scope_correlation.html.markdown | 39 --- .../docs/d/scc_posture_scopes.html.markdown | 99 ------- .../r/scc_posture_collector.html.markdown | 61 ---- .../r/scc_posture_credential.html.markdown | 109 -------- .../scc_posture_profile_import.html.markdown | 46 --- ...ure_scan_initiate_validation.html.markdown | 59 ---- .../docs/r/scc_posture_scope.html.markdown | 64 ----- 19 files changed, 114 insertions(+), 1562 deletions(-) delete mode 100644 website/docs/d/scc_posture_collector.html.markdown delete mode 100644 website/docs/d/scc_posture_collectors.html.markdown delete mode 100644 website/docs/d/scc_posture_credential.html.markdown delete mode 100644 website/docs/d/scc_posture_credentials.html.markdown delete mode 100644 website/docs/d/scc_posture_group_profile.html.markdown delete mode 100644 website/docs/d/scc_posture_latest_scans.html.markdown delete mode 100644 website/docs/d/scc_posture_profile.html.markdown delete mode 100644 website/docs/d/scc_posture_profiles.html.markdown delete mode 100644 website/docs/d/scc_posture_scan_summaries.html.markdown delete mode 100644 website/docs/d/scc_posture_scans_summary.html.markdown delete mode 100644 website/docs/d/scc_posture_scope.html.markdown delete mode 100644 website/docs/d/scc_posture_scope_correlation.html.markdown delete mode 100644 website/docs/d/scc_posture_scopes.html.markdown delete mode 100644 website/docs/r/scc_posture_collector.html.markdown delete mode 100644 website/docs/r/scc_posture_credential.html.markdown delete mode 100644 website/docs/r/scc_posture_profile_import.html.markdown delete mode 100644 website/docs/r/scc_posture_scan_initiate_validation.html.markdown delete mode 100644 website/docs/r/scc_posture_scope.html.markdown diff --git a/CHANGELOG.md b/CHANGELOG.md index a895e502aa..6fc4eafa4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,77 @@ +# 1.55.0 (Jul 10, 2023) + +Features +* Support VPC + - **Resources** + - ibm_is_share_mount_target + - **Datasources** + - ibm_is_share_mount_target + - ibm_is_share_mount_targets + +* Support DNS + - **Resources** + - ibm_dns_linked_zone + +* Support IKS + - **Datasources** + - ibm_container_ingress_secret_tls + - ibm_container_ingress_secret_opaque + - **Resources** + - ibm_container_ingress_secret_tls + - ibm_container_ingress_secret_opaque + +* Support Metrics Router + - **Datasources** + - ibm_metrics_router_targets + - ibm_metrics_router_routes + - **Resources** + - ibm_metrics_router_route + - ibm_metrics_router_target + - ibm_metrics_router_settings + +* Support Code Engine + - **Datasources** + - ibm_code_engine_binding + - **Resources** + - ibm_code_engine_binding + +* Support CIS + - **Datasources** + - ibm_cis_bot_managements + - ibm_cis_bot_analytics + - **Resources** + - ibm_cis_bot_management + +Enhancements +* Secrets Manager - Additional tests ([4613](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4613)) +* Tekton: Improved property type handling ([4595](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4595)) +* Tagging for CD Toolchains ([4607](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4607)) +* Support for ODF Worker Replace ([4600](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4600)) +* Documentation for ODF Add-on and Worker Replace ([4627](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4627)) +* Document private net DNS limit on PER workspaces ([4629](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4629)) +* added support for vcpu manufacturer(vsi, dh) ([4637](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4637)) +* Adding changes for replacement of key_protect parameter ([4618](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4618)) +* Adding more examples and test cases for Atracker ([4645](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4645)) + +BugFixes +* fix(iam-service-api-key): added nil check on apikey *string ([4617](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4617)) +* update project_instance.html.markdown ([4621](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4621)) +* add import example of code engine ([4623](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4623)) +* Update pi_cloud_connection documentation ([4625](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4625)) +* Documenation correction instance group membership ([4632](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4632)) +* CIS - Documentation Update for plan ([4638](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4638)) +* Fix indentation ([4633](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4633)) +* managed_addons fix for container_addons ([4606](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4606)) +* cos: importing a bucket does not import the key_protect attribute ([3394](https://github.com/IBM-Cloud/terraform-provider-ibm/issues/3394)) +* Private cert attribute fixes ([4641](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4641)) +* auto_rotate fix ([4649](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4649)) +* Fix the private endpoint for global search API ([4666](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4666)) +* Fix dnssvcs module broken after SDK release ([4667](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4667)) +* DNS ut fix: strfmt to string conversion to fix broken UT ([4671](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4671)) +* fix: catalog management version resource patch fix to correct operation type ([4673](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4673)) +* Fix unclosed code block in r/iam_access_group_policy docs ([4659](https://github.com/IBM-Cloud/terraform-provider-ibm/pull/4659)) + + # 1.55.0-beta0(Jun 21, 2023) Features @@ -915,6 +989,12 @@ Features - **Resources** - ibm_pi_shared_processor_pool - ibm_pi_spp_placement_group +* Support Security and Compilance + - **DataSources** + - ibm_scc_posture_profile_import + - ibm_scc_posture_scan_initiate_validation + - **Resources** + - ibm_scc_posture_scan_initiate_validation * Support App Configuration - **DataSources** - ibm_app_config_collection @@ -967,6 +1047,12 @@ Features - **Resources** - ibm_pi_shared_processor_pool - ibm_pi_shared_processor_pool +* Support Security and Compilance + - **DataSources** + - ibm_scc_posture_profile_import + - ibm_scc_posture_scan_initiate_validation + - **Resources** + - ibm_scc_posture_scan_initiate_validation * Support App Configuration - **DataSources** - ibm_app_config_collection @@ -1123,6 +1209,13 @@ Features - **DataSources** - ibm_database_task - ibm_database_tasks +* Support Security and Compilance + - **DataSources** + - ibm_scc_posture_credential + - ibm_scc_posture_collector + - ibm_scc_posture_scope + - ibm_scc_posture_credentials + - ibm_scc_posture_collectors * Support Virtual Private Cloud - **DataSources** - ibm_is_backup_policy @@ -1180,6 +1273,13 @@ Features - **DataSources** - ibm_database_task - ibm_database_tasks +* Support Security and Compilance + - **DataSources** + - ibm_scc_posture_credential + - ibm_scc_posture_collector + - ibm_scc_posture_scope + - ibm_scc_posture_credentials + - ibm_scc_posture_collectors * Support Virtual Private Cloud - **DataSources** - ibm_is_backup_policy @@ -2035,6 +2135,15 @@ Features - ibm_pi_image_export - ibm_pi_placement_group - ibm_pi_capture +* Support Security and Compliance Center + - **DataSources** + - ibm_scc_posture_profile + - ibm_scc_posture_group_profile + - ibm_scc_posture_scope_correlation + - **Resources** + - ibm_scc_posture_collector + - ibm_scc_posture_scope + - ibm_scc_posture_credential * Support IAM Authorization Policies - **Datasources** - ibm_iam_authorization_policies @@ -2388,6 +2497,11 @@ FEATURES: - ibm_scc_si_note - ibm_scc_si_notes - ibm_scc_si_providers + - ibm_scc_posture_scopes + - ibm_scc_posture_latest_scans + - ibm_scc_posture_profiles + - ibm_scc_posture_scan_summary + -ibm_scc_posture_scan_summaries * Support Event Streams Schema - **Resources** diff --git a/website/docs/d/scc_posture_collector.html.markdown b/website/docs/d/scc_posture_collector.html.markdown deleted file mode 100644 index 466dab366b..0000000000 --- a/website/docs/d/scc_posture_collector.html.markdown +++ /dev/null @@ -1,98 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_collector" -description: |- - Get information about collector -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_collector - -Provides a read-only data source for collector. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_collector" "collector" { - collector_id = "collector_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `collector_id` - (Required, Forces new resource, String) The id for the given API. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the collector. -* `approved_internet_gateway_ip` - (Optional, String) The approved internet gateway ip of the collector. This field will be populated only when collector is installed. - -* `approved_local_gateway_ip` - (Optional, String) The approved local gateway ip of the collector. This field will be populated only when collector is installed. - -* `collector_version` - (Optional, String) The collector version. This field is populated when collector is installed. - -* `created_at` - (Required, String) The ISO Date/Time the collector was created. - -* `created_by` - (Required, String) The id of the user that created the collector. - -* `credential_public_key` - (Optional, String) The credential public key. - -* `description` - (Required, String) The description of the collector. - -* `display_name` - (Required, String) The user-friendly name of the collector. - -* `enabled` - (Required, Boolean) Identifies whether the collector is enabled or not(deleted). - -* `failure_count` - (Required, Integer) The number of times the collector has failed. - -* `hostname` - (Optional, String) The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name. - -* `image_version` - (Optional, String) The image version of the collector. This field is populated when collector is installed. ". - -* `install_path` - (Optional, String) The installation path of the collector. This field will be populated when collector is installed.The value will be folder path. - -* `is_public` - (Required, Boolean) Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network. - -* `is_ubi_image` - (Optional, Boolean) Determines whether the collector has a Ubi image. - -* `last_failed_internet_gateway_ip` - (Optional, String) The failed internet gateway ip of the collector. - -* `last_failed_local_gateway_ip` - (Optional, String) The failed local gateway ip. This field will be populated only when collector is installed. - -* `last_heartbeat` - (Optional, String) Stores the heartbeat time of a controller . This value exists when collector is installed and running. - -* `managed_by` - (Required, String) The entity that manages the collector. - * Constraints: Allowable values are: `ibm`, `customer`. - -* `name` - (Required, String) The name of the collector. - -* `public_key` - (Optional, String) The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed. - -* `registration_code` - (Required, String) The registration code of the collector.This is will be used for initial authentication during installation of collector. - -* `reset_reason` - (Optional, String) The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field . - -* `reset_time` - (Optional, String) The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field. - -* `status` - (Required, String) The status of collector. - * Constraints: Allowable values are: `ready_to_install`, `core_downloaded`, `approval_required`, `approved_download_in_progress`, `approved_install_in_progress`, `install_in_progress`, `installed`, `installed_credentials_required`, `installed_assigning_credentials`, `active`, `unable_to_connect`, `waiting_for_upgrade`, `suspended`, `installation_failed`. - -* `status_description` - (Required, String) The collector status. - -* `trial_expiry` - (Optional, String) The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed. - -* `type` - (Required, String) The type of the collector. - * Constraints: Allowable values are: `restricted`, `unrestricted`. - -* `updated_at` - (Required, String) The ISO Date/Time the collector was modified. - -* `updated_by` - (Required, String) The id of the user that modified the collector. - -* `use_private_endpoint` - (Required, Boolean) Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_collector is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_collectors.html.markdown b/website/docs/d/scc_posture_collectors.html.markdown deleted file mode 100644 index 7837b1532c..0000000000 --- a/website/docs/d/scc_posture_collectors.html.markdown +++ /dev/null @@ -1,86 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_collectors" -description: |- - Get information about list_collectors -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_collectors - -Provides a read-only data source for list_collectors. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_collectors" "list_collectors" { -} -``` - - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the list_collectors. -* `collectors` - (List) The array of items returned. -Nested scheme for **collectors**: - * `approved_internet_gateway_ip` - (String) The approved internet gateway ip of the collector. This field will be populated only when collector is installed. - * `approved_local_gateway_ip` - (String) The approved local gateway ip of the collector. This field will be populated only when collector is installed. - * `collector_version` - (String) The collector version. This field is populated when collector is installed. - * `created_at` - (String) The ISO Date/Time the collector was created. - * `created_by` - (String) The id of the user that created the collector. - * `credential_public_key` - (String) The credential public key. - * `description` - (String) The description of the collector. - * `display_name` - (String) The user-friendly name of the collector. - * `enabled` - (Boolean) Identifies whether the collector is enabled or not(deleted). - * `failure_count` - (Integer) The number of times the collector has failed. - * `hostname` - (String) The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name. - * `id` - (String) The id of the collector. - * `image_version` - (String) The image version of the collector. This field is populated when collector is installed. ". - * `install_path` - (String) The installation path of the collector. This field will be populated when collector is installed.The value will be folder path. - * `is_public` - (Boolean) Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network. - * `is_ubi_image` - (Boolean) Determines whether the collector has a Ubi image. - * `last_failed_internet_gateway_ip` - (String) The failed internet gateway ip of the collector. - * `last_failed_local_gateway_ip` - (String) The failed local gateway ip. This field will be populated only when collector is installed. - * `last_heartbeat` - (String) Stores the heartbeat time of a controller . This value exists when collector is installed and running. - * `managed_by` - (String) The entity that manages the collector. - * Constraints: Allowable values are: `ibm`, `customer`. - * `name` - (String) The name of the collector. - * `public_key` - (String) The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed. - * `registration_code` - (String) The registration code of the collector.This is will be used for initial authentication during installation of collector. - * `reset_reason` - (String) The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field . - * `reset_time` - (String) The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field. - * `status` - (String) The status of collector. - * Constraints: Allowable values are: `ready_to_install`, `core_downloaded`, `approval_required`, `approved_download_in_progress`, `approved_install_in_progress`, `install_in_progress`, `installed`, `installed_credentials_required`, `installed_assigning_credentials`, `active`, `unable_to_connect`, `waiting_for_upgrade`, `suspended`, `installation_failed`. - * `status_description` - (String) The collector status. - * `trial_expiry` - (String) The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed. - * `type` - (String) The type of the collector. - * Constraints: Allowable values are: `restricted`, `unrestricted`. - * `updated_at` - (String) The ISO Date/Time the collector was modified. - * `updated_by` - (String) The id of the user that modified the collector. - * `use_private_endpoint` - (Boolean) Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false. - -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `limit` - (Integer) The number of items to return. - -* `next` - (List) The URL of a page. -Nested scheme for **next**: - * `href` - (String) The URL of a page. - -* `offset` - (Integer) The offset from the start of the list (0-based). - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. - -* `total_count` - (Integer) The total number of items in the list. This will have value as 0 when no collectors are available and below values will not be populated in that case. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_collectors is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_credential.html.markdown b/website/docs/d/scc_posture_credential.html.markdown deleted file mode 100644 index 896a99b3cc..0000000000 --- a/website/docs/d/scc_posture_credential.html.markdown +++ /dev/null @@ -1,104 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_credential" -description: |- - Get information about credential -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_credential - -Provides a read-only data source for credential. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_credential" "credential" { - credential_id = "credential_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `id` - (Required, Forces new resource, String) The id for the given API. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `credential_id` - The unique identifier of the credential. -* `created_at` - (Required, String) The time that the credentials was created in UTC. - -* `created_by` - (Required, String) ID of the user who created the credentials. - -* `description` - (Required, String) Credentials description. - -* `display_fields` - (Required, List) Details the fields on the credential. This will change as per credential type selected. -Nested scheme for **display_fields**: - * `auth_url` - (Optional, String) auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_arn` - (Optional, String) AWS arn value. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_id` - (Optional, String) AWS client Id.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_secret` - (Optional, String) AWS client secret.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_region` - (Optional, String) AWS region. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_id` - (Optional, String) Azure client Id. This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_secret` - (Optional, String) Azure client secret.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_resource_group` - (Optional, String) Azure resource group. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_subscription_id` - (Optional, String) Azure subscription Id.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `database_name` - (Optional, String) Database name.This is mandatory for Database Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ibm_api_key` - (Optional, String) The IBM Cloud API Key. This is mandatory for IBM Credential Type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_client_id` - (Optional, String) The MS365 client Id.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_client_secret` - (Optional, String) The MS365 client secret.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_tenant_id` - (Optional, String) The MS365 tenantId.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `password` - (Optional, String) password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `pem_data` - (Optional, String) The base64 encoded data to associate with the PEM file. - * Constraints: The maximum length is `4000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `pem_file_name` - (Optional, String) The name of the PEM file. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `project_domain_name` - (Optional, String) project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `project_name` - (Optional, String) Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `user_domain_name` - (Optional, String) user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `username` - (Optional, String) username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_authtype` - (Optional, String) Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_port` - (Optional, String) Kerberos windows port.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - * `winrm_usessl` - (Optional, String) Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `enabled` - (Required, Boolean) Credentials status enabled/disbaled. - -* `name` - (Required, String) Credentials name. - -* `purpose` - (Required, String) Purpose for which the credential is created. - * Constraints: Allowable values are: `discovery_collection`, `discovery_fact_collection`, `remediation`, `discovery_collection_remediation`, `discovery_fact_collection_remediation`. - -* `type` - (Required, String) Credentials type. - * Constraints: Allowable values are: `username_password`, `aws_cloud`, `azure_cloud`, `database`, `kerberos_windows`, `ms_365`, `openstack_cloud`, `ibm_cloud`, `user_name_pem`. - -* `updated_at` - (Required, String) The modified time that the credentials was modified in UTC. - -* `updated_by` - (Required, String) ID of the user who modified the credentials. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_credential is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_credentials.html.markdown b/website/docs/d/scc_posture_credentials.html.markdown deleted file mode 100644 index cbcc1dbcc9..0000000000 --- a/website/docs/d/scc_posture_credentials.html.markdown +++ /dev/null @@ -1,102 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_credentials" -description: |- - Get information about list_credentials -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_credentials - -Provides a read-only data source for list_credentials. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_credentials" "list_credentials" { -} -``` - - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the list_credentials. -* `credentials` - (List) The details of a credentials. -Nested scheme for **credentials**: - * `created_at` - (String) The time that the credentials was created in UTC. - * `created_by` - (String) ID of the user who created the credentials. - * `description` - (String) Credentials description. - * `display_fields` - (List) Details the fields on the credential. This will change as per credential type selected. - Nested scheme for **display_fields**: - * `auth_url` - (String) auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_arn` - (String) AWS arn value. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_id` - (String) AWS client Id.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_secret` - (String) AWS client secret.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_region` - (String) AWS region. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_id` - (String) Azure client Id. This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_secret` - (String) Azure client secret.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_resource_group` - (String) Azure resource group. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_subscription_id` - (String) Azure subscription Id.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `database_name` - (String) Database name.This is mandatory for Database Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ibm_api_key` - (String) The IBM Cloud API Key. This is mandatory for IBM Credential Type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_client_id` - (String) The MS365 client Id.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_client_secret` - (String) The MS365 client secret.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_tenant_id` - (String) The MS365 tenantId.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `password` - (String) password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `pem_data` - (String) The base64 encoded data to associate with the PEM file. - * Constraints: The maximum length is `4000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `pem_file_name` - (String) The name of the PEM file. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `project_domain_name` - (String) project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `project_name` - (String) Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `user_domain_name` - (String) user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `username` - (String) username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_authtype` - (String) Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_port` - (String) Kerberos windows port.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - * `winrm_usessl` - (String) Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `enabled` - (Boolean) Credentials status enabled/disbaled. - * `id` - (String) Credentials ID. - * `name` - (String) Credentials name. - * `purpose` - (String) Purpose for which the credential is created. - * Constraints: Allowable values are: `discovery_collection`, `discovery_fact_collection`, `remediation`, `discovery_collection_remediation`, `discovery_fact_collection_remediation`. - * `type` - (String) Credentials type. - * Constraints: Allowable values are: `username_password`, `aws_cloud`, `azure_cloud`, `database`, `kerberos_windows`, `ms_365`, `openstack_cloud`, `ibm_cloud`, `user_name_pem`. - * `updated_at` - (String) The modified time that the credentials was modified in UTC. - * `updated_by` - (String) ID of the user who modified the credentials. - -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_credentials is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_group_profile.html.markdown b/website/docs/d/scc_posture_group_profile.html.markdown deleted file mode 100644 index 8b3bfc8539..0000000000 --- a/website/docs/d/scc_posture_group_profile.html.markdown +++ /dev/null @@ -1,60 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_group_profile" -description: |- - Get information about group_profile_details -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_group_profile - -Provides a read-only data source for group_profile_details. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_group_profile" "group_profile_details" { - profile_id = "profile_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `profile_id` - (Required, Forces new resource, String) The profile ID. This can be obtained from the Security and Compliance Center UI by clicking on the profile name. The URL contains the ID. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the group_profile_details. -* `controls` - (List) Profiles array. -Nested scheme for **controls**: - * `description` - (String) The description of the control. - * `external_control_id` - (String) The external identifier number of the control. - * `goals` - (List) Mapped goals aganist the control identifier. - Nested scheme for **goals**: - * `description` - (String) The description of the goal. - * `id` - (String) The goal ID. - * `is_auto_remediable` - (Boolean) The goal is autoremediable or not. - * `is_automatable` - (Boolean) The goal is automatable or not. - * `is_manual` - (Boolean) The goal is manual check. - * `is_remediable` - (Boolean) The goal is remediable or not. - * `is_reversible` - (Boolean) The goal is reversible or not. - * `severity` - (String) The severity of the goal. - * `id` - (String) The identifier number of the control. - -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_group_profile is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_latest_scans.html.markdown b/website/docs/d/scc_posture_latest_scans.html.markdown deleted file mode 100644 index 64082422ec..0000000000 --- a/website/docs/d/scc_posture_latest_scans.html.markdown +++ /dev/null @@ -1,75 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_latest_scans" -description: |- - Get information about list_latest_scans -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_latest_scans - -Provides a read-only data source for list_latest_scans. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_latest_scans" "list_latest_scans" { - scan_id = "262" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `scan_id` - (Optional, String) The ID of the scan. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the list_latest_scans. -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `latest_scans` - (List) The details of a scan. -Nested scheme for **latest_scans**: - * `end_time` - (String) The date and time the scan completed. - * `group_profile_id` - (String) The group ID of profile. - * `group_profile_name` - (String) The group name of the profile. - * `profiles` - (List) Profiles array. - Nested scheme for **profiles**: - * `id` - (String) An auto-generated unique identifier for the scope. - * `name` - (String) The name of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `type` - (String) The type of profile. - * Constraints: Allowable values are: `predefined`, `custom`, `template_group`. - * `report_run_by` - (String) The entity that ran the report. - * `report_setting_id` - (String) The unique ID for Scan that is created. - * `result` - (List) The result of a scan.The above values will not be avaialble if no scopes are available. - Nested scheme for **result**: - * `controls_fail_count` - (Integer) The number of controls that failed the scan. - * `controls_not_applicable_count` - (Integer) The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `controls_pass_count` - (Integer) The number of controls that passed the scan. - * `controls_total_count` - (Integer) The total number of controls that were included in the scan. - * `controls_unable_to_perform_count` - (Integer) The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `goals_fail_count` - (Integer) The number of goals that failed the scan. - * `goals_not_applicable_count` - (Integer) The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `goals_pass_count` - (Integer) The number of goals that passed the scan. - * `goals_total_count` - (Integer) The total number of goals that were included in the scan. - * `goals_unable_to_perform_count` - (Integer) The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `scan_id` - (String) The ID of the scan. - * `scan_name` - (String) A system generated name that is the combination of 12 characters in the scope name and 12 characters of a profile name. - * `scope_id` - (String) The scope ID of the scan. - * `scope_name` - (String) The name of the scope. - * `start_time` - (String) The date and time the scan was run. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_latest_scans is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_profile.html.markdown b/website/docs/d/scc_posture_profile.html.markdown deleted file mode 100644 index d5a0fde5c5..0000000000 --- a/website/docs/d/scc_posture_profile.html.markdown +++ /dev/null @@ -1,68 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_profile" -description: |- - Get information about profileDetails -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_profile - -Provides a read-only data source for profileDetails. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_profile" "profile_details" { - id = "id" - profile_type = "profile_type" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `id` - (Required, Forces new resource, String) The id for the given API. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. -* `profile_type` - (Required, String) The profile type ID. This will be 4 for profiles and 6 for group profiles. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the profileDetails. -* `base_profile` - (String) The base profile that the controls are pulled from. - -* `created_at` - (String) The time that the profile was created in UTC. - -* `created_by` - (String) The user who created the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `description` - (String) A description of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `enabled` - (Boolean) The profile status. If the profile is enabled, the value is true. If the profile is disabled, the value is false. - -* `modified_by` - (String) The user who last modified the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `name` - (String) The name of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `no_of_controls` - (Integer) no of Controls. - * Constraints: The minimum value is `1`. - -* `reason_for_delete` - (String) A reason that you want to delete a profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -* `type` - (String) The type of profile. - * Constraints: Allowable values are: `predefined`, `custom`, `template_group`. - -* `updated_at` - (String) The time that the profile was most recently modified in UTC. - -* `version` - (Integer) The version of the profile. - * Constraints: The minimum value is `1`. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_profile is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_profiles.html.markdown b/website/docs/d/scc_posture_profiles.html.markdown deleted file mode 100644 index bd78603e82..0000000000 --- a/website/docs/d/scc_posture_profiles.html.markdown +++ /dev/null @@ -1,62 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_profiles" -description: |- - Get information about list_profiles -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_profiles - -Provides a read-only data source for list_profiles. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_profiles" "list_profiles" { -} -``` - - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the list_profiles. -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. - -* `profiles` - (List) Profiles. -Nested scheme for **profiles**: - * `base_profile` - (String) The base profile that the controls are pulled from. - * `created_at` - (String) The time that the profile was created in UTC. - * `created_by` - (String) The user who created the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `description` - (String) A description of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `enabled` - (Boolean) The profile status. If the profile is enabled, the value is true. If the profile is disabled, the value is false. - * `id` - (String) An auto-generated unique identifying number of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `modified_by` - (String) The user who last modified the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `name` - (String) The name of the profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `no_of_controls` - (Integer) no of Controls. - * Constraints: The minimum value is `1`. - * `reason_for_delete` - (String) A reason that you want to delete a profile. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `type` - (String) The type of profile. - * Constraints: Allowable values are: `predefined`, `custom`, `template_group`. - * `updated_at` - (String) The time that the profile was most recently modified in UTC. - * `version` - (Integer) The version of the profile. - * Constraints: The minimum value is `1`. -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_profiles is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_scan_summaries.html.markdown b/website/docs/d/scc_posture_scan_summaries.html.markdown deleted file mode 100644 index 6a955a00a5..0000000000 --- a/website/docs/d/scc_posture_scan_summaries.html.markdown +++ /dev/null @@ -1,93 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scan_summaries" -description: |- - Get information about scan_summaries -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scan_summaries - -Provides a read-only data source for scan_summaries. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_scan_summaries" "scan_summaries" { - report_setting_id = "report_setting_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `report_setting_id` - (Required, String) The report setting ID. This can be obtained from the /validations/latest_scans API call. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the scan_summaries. -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. - -* `summaries` - (List) Summaries. -Nested scheme for **summaries**: - * `end_time` - (String) The date and time the scan completed. - * `group_profiles` - (List) The list of group profiles. - Nested scheme for **group_profiles**: - * `id` - (String) The ID of the profile. - * `name` - (String) The name of the profile. - * `type` - (String) The type of profile. To learn more about profile types, check out the [docs] (https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-profiles). - * Constraints: Allowable values are: `standard`, `authored`, `custom`, `standard_cv`, `temmplategroup`, `standard_certificate`, `predefined`. - * `validation_result` - (List) The result of a scan.The above values will not be avaialble if no scopes are available. - Nested scheme for **validation_result**: - * `controls_fail_count` - (Integer) The number of controls that failed the scan. - * `controls_not_applicable_count` - (Integer) The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `controls_pass_count` - (Integer) The number of controls that passed the scan. - * `controls_total_count` - (Integer) The total number of controls that were included in the scan. - * `controls_unable_to_perform_count` - (Integer) The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `goals_fail_count` - (Integer) The number of goals that failed the scan. - * `goals_not_applicable_count` - (Integer) The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `goals_pass_count` - (Integer) The number of goals that passed the scan. - * `goals_total_count` - (Integer) The total number of goals that were included in the scan. - * `goals_unable_to_perform_count` - (Integer) The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `id` - (String) The ID of the scan. - * `name` - (String) A system generated name that is the combination of 12 characters in the scope name and 12 characters of a profile name. - * `profiles` - (List) The list of profiles. - Nested scheme for **profiles**: - * `id` - (String) The ID of the profile. - * `name` - (String) The name of the profile. - * `type` - (String) The type of profile. To learn more about profile types, check out the [docs] (https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-profiles). - * Constraints: Allowable values are: `standard`, `authored`, `custom`, `standard_cv`, `temmplategroup`, `standard_certificate`, `predefined`. - * `validation_result` - (List) The result of a scan.The above values will not be avaialble if no scopes are available. - Nested scheme for **validation_result**: - * `controls_fail_count` - (Integer) The number of controls that failed the scan. - * `controls_not_applicable_count` - (Integer) The number of controls that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `controls_pass_count` - (Integer) The number of controls that passed the scan. - * `controls_total_count` - (Integer) The total number of controls that were included in the scan. - * `controls_unable_to_perform_count` - (Integer) The number of controls that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `goals_fail_count` - (Integer) The number of goals that failed the scan. - * `goals_not_applicable_count` - (Integer) The number of goals that are not relevant to the current scan. A scan is listed as 'Not applicable' when information about its associated resource can't be found. - * `goals_pass_count` - (Integer) The number of goals that passed the scan. - * `goals_total_count` - (Integer) The total number of goals that were included in the scan. - * `goals_unable_to_perform_count` - (Integer) The number of goals that could not be validated. A control is listed as 'Unable to perform' when information about its associated resource can't be collected. - * `report_run_by` - (String) The entity that ran the report. - * `scope_id` - (String) The ID of the scope. - * `scope_name` - (String) The name of the scope. - * `start_time` - (String) The date and time the scan was run. - * `status` - (String) The status of the collector as it completes a scan. - * Constraints: Allowable values are: `pending`, `discovery_started`, `discovery_completed`, `error_in_discovery`, `gateway_aborted`, `controller_aborted`, `not_accepted`, `waiting_for_refine`, `validation_started`, `validation_completed`, `sent_to_collector`, `discovery_in_progress`, `validation_in_progress`, `error_in_validation`, `discovery_result_posted_with_error`, `discovery_result_posted_no_error`, `validation_result_posted_with_error`, `validation_result_posted_no_error`, `fact_collection_started`, `fact_collection_in_progress`, `fact_collection_completed`, `error_in_fact_collection`, `fact_validation_started`, `fact_validation_in_progress`, `fact_validation_completed`, `error_in_fact_validation`, `abort_task_request_received`, `error_in_abort_task_request`, `abort_task_request_completed`, `user_aborted`, `abort_task_request_failed`, `remediation_started`, `remediation_in_progress`, `error_in_remediation`, `remediation_completed`, `inventory_started`, `inventory_in_progress`, `inventory_completed`, `error_in_inventory`, `inventory_completed_with_error`. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scan_summaries is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_scans_summary.html.markdown b/website/docs/d/scc_posture_scans_summary.html.markdown deleted file mode 100644 index d7cae8702a..0000000000 --- a/website/docs/d/scc_posture_scans_summary.html.markdown +++ /dev/null @@ -1,75 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scan_summary" -description: |- - Get information about scans_summary -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scan_summary - -Provides a read-only data source for scans_summary. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_scan_summary" "scans_summary" { - profile_id = "profile_id" - scan_id = "scan_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `profile_id` - (Required, String) The profile ID. This can be obtained from the Security and Compliance Center UI by clicking on the profile name. The URL contains the ID. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. -* `scan_id` - (Required, String) Your Scan ID. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the scans_summary. -* `controls` - (List) The list of controls on the scan summary. -Nested scheme for **controls**: - * `desciption` - (String) The scan profile name. - * `external_control_id` - (String) The external control ID. - * `goals` - (List) The list of goals on the control. - Nested scheme for **goals**: - * `completed_time` - (String) The report completed time. - * `description` - (String) The description of the goal. - * `error` - (String) The error on goal validation. - * `id` - (String) The goal ID. - * `resource_result` - (List) The list of resource results. - Nested scheme for **resource_result**: - * `actual_value` - (String) The actual results of a resource. - * `display_expected_value` - (String) The expected results of a resource. - * `name` - (String) The resource name. - * `not_applicable_reason` - (String) The reason for goal not applicable for a resource. - * `results_info` - (String) The results information. - * `status` - (String) The resource control result status. - * Constraints: Allowable values are: `pass`, `unable_to_perform`. - * `types` - (String) The resource type. - * `severity` - (String) The severity of the goal. - * `status` - (String) The goal status. - * Constraints: Allowable values are: `pass`, `fail`. - * `id` - (String) The scan summary control ID. - * `resource_statistics` - (List) A scans summary controls. - Nested scheme for **resource_statistics**: - * `fail_count` - (Integer) The resource count of fail controls. - * `not_applicable_count` - (Integer) The resource count of not applicable(na) controls. - * `pass_count` - (Integer) The resource count of pass controls. - * `unable_to_perform_count` - (Integer) The number of resources that were unable to be scanned against a control. - * `status` - (String) The control status. - * Constraints: Allowable values are: `pass`, `unable_to_perform`. - -* `discover_id` - (String) The scan discovery ID. - -* `profile_name` - (String) The scan profile name. - -* `scope_id` - (String) The scan summary scope ID. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scan_summary is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_scope.html.markdown b/website/docs/d/scc_posture_scope.html.markdown deleted file mode 100644 index b4d26e3f4c..0000000000 --- a/website/docs/d/scc_posture_scope.html.markdown +++ /dev/null @@ -1,262 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scope" -description: |- - Get information about scope -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scope - -Provides a read-only data source for scope. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_scope" "scope" { - scope_id = "scope_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `id` - (Required, Forces new resource, String) The id for the given API. - * Constraints: The maximum length is `20` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `scope_id` - The unique identifier of the scope. -* `cloud_type` - (Optional, String) Stores the value of scope_cloud_type .Will be displayed only when value exists. - -* `cloud_type_id` - (Optional, Integer) Stores the value of scope_cloud_type_id .Will be displayed only when value exists. - -* `collectors` - (Optional, List) Stores the value of collectors .Will be displayed only when value exists. -Nested scheme for **collectors**: - * `approved_internet_gateway_ip` - (Optional, String) The approved internet gateway ip of the collector. This field will be populated only when collector is installed. - * `approved_local_gateway_ip` - (Optional, String) The approved local gateway ip of the collector. This field will be populated only when collector is installed. - * `collector_version` - (Optional, String) The collector version. This field is populated when collector is installed. - * `created_at` - (Required, String) The ISO Date/Time the collector was created. - * `created_by` - (Required, String) The id of the user that created the collector. - * `credential_public_key` - (Optional, String) The credential public key. - * `description` - (Required, String) The description of the collector. - * `display_name` - (Required, String) The user-friendly name of the collector. - * `enabled` - (Required, Boolean) Identifies whether the collector is enabled or not(deleted). - * `failure_count` - (Required, Integer) The number of times the collector has failed. - * `hostname` - (Optional, String) The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name. - * `id` - (Required, String) The id of the collector. - * `image_version` - (Optional, String) The image version of the collector. This field is populated when collector is installed. ". - * `install_path` - (Optional, String) The installation path of the collector. This field will be populated when collector is installed.The value will be folder path. - * `is_public` - (Required, Boolean) Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network. - * `is_ubi_image` - (Optional, Boolean) Determines whether the collector has a Ubi image. - * `last_failed_internet_gateway_ip` - (Optional, String) The failed internet gateway ip of the collector. - * `last_failed_local_gateway_ip` - (Optional, String) The failed local gateway ip. This field will be populated only when collector is installed. - * `last_heartbeat` - (Optional, String) Stores the heartbeat time of a controller . This value exists when collector is installed and running. - * `managed_by` - (Required, String) The entity that manages the collector. - * Constraints: Allowable values are: `ibm`, `customer`. - * `name` - (Required, String) The name of the collector. - * `public_key` - (Optional, String) The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed. - * `registration_code` - (Required, String) The registration code of the collector.This is will be used for initial authentication during installation of collector. - * `reset_reason` - (Optional, String) The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field . - * `reset_time` - (Optional, String) The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field. - * `status` - (Required, String) The status of collector. - * Constraints: Allowable values are: `ready_to_install`, `core_downloaded`, `approval_required`, `approved_download_in_progress`, `approved_install_in_progress`, `install_in_progress`, `installed`, `installed_credentials_required`, `installed_assigning_credentials`, `active`, `unable_to_connect`, `waiting_for_upgrade`, `suspended`, `installation_failed`. - * `status_description` - (Required, String) The collector status. - * `trial_expiry` - (Optional, String) The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed. - * `type` - (Required, String) The type of the collector. - * Constraints: Allowable values are: `restricted`, `unrestricted`. - * `updated_at` - (Required, String) The ISO Date/Time the collector was modified. - * `updated_by` - (Required, String) The id of the user that modified the collector. - * `use_private_endpoint` - (Required, Boolean) Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false. - -* `collectors_by_type` - (Optional, Map) Stores the value of collectors_by_type .Will be displayed only when value exists. - -* `correlation_id` - (Optional, String) A correlation_Id is created when a scope is created and discovery task is triggered or when a validation is triggered on a Scope. This is used to get the status of the task(discovery or validation). - -* `created_at` - (Optional, String) Stores the value of scope_created_on .Will be displayed only when value exists. - -* `created_by` - (Optional, String) Stores the value of scope_created_by .Will be displayed only when value exists. - -* `credential_attributes` - (Optional, String) Stores the value of scope_credential_attributes .Will be displayed only when value exists. - -* `credentials_by_sub_categeory_type` - (Optional, Map) Stores the value of scope_credentials_by_sub_categeory_type .Will be displayed only when value exists. - -* `credentials_by_type` - (Optional, Map) Stores the value of scope_credentials_by_type .Will be displayed only when value exists. - -* `description` - (Optional, String) Stores the value of scope_description .Will be displayed only when value exists. - -* `discovery_method` - (Optional, String) Stores the value of scope_discovery_method .Will be displayed only when value exists. - -* `discovery_methods` - (Optional, List) Stores the value of scope_discovery_methods .Will be displayed only when value exists. - -* `discovery_setting_id` - (Optional, Integer) Stores the value of scope_discovery_setting_id .Will be displayed only when value exists. - -* `enabled` - (Optional, Boolean) Stores the value of scope_enabled .Will be displayed only when value exists. - -* `env_sub_category` - (Optional, String) Stores the value of scope_env_sub_category .Will be displayed only when value exists. - -* `file_format` - (Optional, String) Stores the value of scope_file_format .Will be displayed only when value exists. - -* `file_type` - (Optional, String) Stores the value of scope_file_type .Will be displayed only when value exists. - -* `first_level_scoped_data` - (Optional, List) Stores the value of scope_first_level_scoped_data .Will be displayed only when value exists. -Nested scheme for **first_level_scoped_data**: - * `scope` - (Optional, String) Stores the value of scope . - * `scope_changed` - (Optional, Boolean) Stores the value of scope_changed . - * `scope_children` - (Optional, Map) Stores the value of scope_children . - * `scope_collector_id` - (Optional, Integer) Stores the value of scope_collector_id . - * `scope_discovery_status` - (Optional, Map) Stores the value of scope_discovery_status . - * `scope_drift` - (Optional, String) Stores the value of scope_drift . - * `scope_fact_status` - (Optional, Map) Stores the value of scope_fact_status . - * `scope_facts` - (Optional, String) Stores the value of scope_facts . - * `scope_id` - (Optional, String) Stores the value of scope_id . - * `scope_init_scope` - (Optional, String) Stores the value of scope_init_scope . - * `scope_list_members` - (Optional, Map) Stores the value of scope_list_members . - * `scope_new_found` - (Optional, Boolean) Stores the value of scope_new_found . - * `scope_object` - (Optional, String) Stores the value of scope_object . - * `scope_overlay` - (Optional, String) Stores the value of scope_overlay . - * `scope_parse_status` - (Optional, String) Stores the value of scope_parse_status . - * `scope_properties` - (Optional, String) Stores the value of scope_properties . - * `scope_resource` - (Optional, String) Stores the value of scope_resource . - * `scope_resource_attributes` - (Optional, Map) Stores the value of scope_resource_attributes . - * `scope_resource_category` - (Optional, String) Stores the value of scope_resource_category . - * `scope_resource_type` - (Optional, String) Stores the value of scope_resource_type . - * `scope_transformed_facts` - (Optional, Map) Stores the value of scope_transformed_facts . - -* `include_new_eagerly` - (Optional, Boolean) Stores the value of scope_include_new_eagerly .Will be displayed only when value exists. - -* `interval` - (Optional, Integer) Stores the value of scope_freq .Will be displayed only when value exists. - -* `is_discovery_scheduled` - (Optional, Boolean) Stores the value of scope_is_discovery_scheduled .Will be displayed only when value exists. - -* `last_discover_completed_time` - (Optional, String) Stores the value of scope_last_discover_completed_time .Will be displayed only when value exists. - -* `last_discover_start_time` - (Optional, String) Stores the value of scope_last_discover_start_time .Will be displayed only when value exists. - -* `last_successful_discover_completed_time` - (Optional, String) Stores the value of scope_last_successful_discover_completed_time .Will be displayed only when value exists. - -* `last_successful_discover_start_time` - (Optional, String) Stores the value of scope_last_successful_discover_start_time .Will be displayed only when value exists. - -* `modified_at` - (Optional, String) Stores the value of scope_modified_on .Will be displayed only when value exists. - -* `modified_by` - (Optional, String) Stores the value of scope_modified_by .Will be displayed only when value exists. - -* `name` - (Required, String) Stores the value of scope_name . - -* `org_id` - (Optional, Integer) Stores the value of scope_org_id .Will be displayed only when value exists. - -* `partner_uuid` - (Optional, String) Stores the value of partner_uuid .Will be displayed only when value exists. - -* `region_names` - (Optional, String) Stores the value of scope_region_names .Will be displayed only when value exists. - -* `resource_groups` - (Optional, String) Stores the value of scope_resource_groups .Will be displayed only when value exists. - -* `status` - (Optional, String) Stores the value of scope_status .Will be displayed only when value exists. - * Constraints: Allowable values are: `pending`, `discovery_started`, `discovery_completed`, `error_in_discover`, `gateway_aborted`, `controller_aborted`, `not_accepted`, `waiting_for_refine`, `validation_started`, `validation_completed`, `sent_to_collector`, `discovery_in_progress`, `validation_in_progress`, `error_in_validation`, `discovery_result_posted_with_error`, `discovery_result_posted_no_error`, `validation_result_posted_with_error`, `validation_result_posted_no_error`, `fact_collection_started`, `fact_collection_in_progress`, `fact_collection_completed`, `error_in_fact_collection`, `fact_validation_started`, `fact_validation_in_progress`, `fact_validation_completed`, `error_in_fact_validation`, `abort_task_request_received`, `error_in_abort_task_request`, `abort_task_request_completed`, `user_aborted`, `abort_task_request_failed`, `cve_validation_started`, `cve_validation_completed`, `cve_validation_error`, `eol_validation_started`, `eol_validation_completed`, `eol_validation_error`, `cve_regular_validation_started`, `cve_regular_validation_completed`, `cve_regular_validation_error`, `eol_regular_validation_started`, `eol_regular_validation_completed`, `eol_regular_validation_error`, `cert_validation_started`, `cert_validation_completed`, `cert_validation_error`, `cert_regular_validation_started`, `cert_regular_validation_completed`, `cert_regular_validation_error`, `remediation_started`, `remediation_in_progress`, `error_in_remediation`, `remediation_completed`, `inventory_started`, `inventory_in_progress`, `inventory_completed`, `error_in_inventory`, `inventory_completed_with_error`, `location_change_aborted`. - -* `status_msg` - (Optional, String) Stores the value of scope_status_msg .Will be displayed only when value exists. - -* `status_updated_time` - (Optional, String) Stores the value of scope_status_updated_time .Will be displayed only when value exists. - -* `sub_categories_by_type` - (Optional, Map) Stores the value of scope_sub_categories_by_type .Will be displayed only when value exists. - -* `subset_selected` - (Optional, Boolean) Stores the value of scope_subset_selected .Will be displayed only when value exists. - -* `task_type` - (Optional, String) Stores the value of scope_task_type .Will be displayed only when value exists. - * Constraints: Allowable values are: `nop`, `discover`, `evidence`, `factcollection`, `script`, `tldiscover`, `subsetvalidate`, `factvalidation`, `aborttasks`, `cve_validation`, `eol_validation`, `cve_regular_validation`, `eol_regular_validation`, `cert_regular_validation`, `cert_validation`, `remediation`, `inventory`. - -* `tasks` - (Optional, List) Stores the value of scope_tasks .Will be displayed only when value exists. -Nested scheme for **tasks**: - * `task_created_by` - (Optional, String) Stores the value of task_created_by . - * `task_derived_status` - (Optional, String) Stores the value of task_derived_status . - * Constraints: Allowable values are: `pending`, `discovery_started`, `discovery_completed`, `error_in_discover`, `gateway_aborted`, `controller_aborted`, `not_accepted`, `waiting_for_refine`, `validation_started`, `validation_completed`, `sent_to_collector`, `discovery_in_progress`, `validation_in_progress`, `error_in_validation`, `discovery_result_posted_with_error`, `discovery_result_posted_no_error`, `validation_result_posted_with_error`, `validation_result_posted_no_error`, `fact_collection_started`, `fact_collection_in_progress`, `fact_collection_completed`, `error_in_fact_collection`, `fact_validation_started`, `fact_validation_in_progress`, `fact_validation_completed`, `error_in_fact_validation`, `abort_task_request_received`, `error_in_abort_task_request`, `abort_task_request_completed`, `user_aborted`, `abort_task_request_failed`, `cve_validation_started`, `cve_validation_completed`, `cve_validation_error`, `eol_validation_started`, `eol_validation_completed`, `eol_validation_error`, `cve_regular_validation_started`, `cve_regular_validation_completed`, `cve_regular_validation_error`, `eol_regular_validation_started`, `eol_regular_validation_completed`, `eol_regular_validation_error`, `cert_validation_started`, `cert_validation_completed`, `cert_validation_error`, `cert_regular_validation_started`, `cert_regular_validation_completed`, `cert_regular_validation_error`, `remediation_started`, `remediation_in_progress`, `error_in_remediation`, `remediation_completed`, `inventory_started`, `inventory_in_progress`, `inventory_completed`, `error_in_inventory`, `inventory_completed_with_error`, `location_change_aborted`. - * `task_discover_id` - (Optional, Integer) Stores the value of task_discover_id . - * `task_gateway_id` - (Optional, Integer) Stores the value of task_gateway_id . - * `task_gateway_name` - (Optional, String) Stores the value of task_gateway_name . - * `task_gateway_schema_id` - (Optional, Integer) Stores the value of task_gateway_schema_id . - * `task_id` - (Optional, Integer) Stores the value of task_id . - * `task_logs` - (Optional, List) Stores the value of task_logs . - Nested scheme for **task_logs**: - * `task_schema_name` - (Optional, String) Stores the value of task_schema_name . - * `task_start_time` - (Optional, Integer) Stores the value of task_start_time . - * `task_status` - (Optional, String) Stores the value of task_status . - * Constraints: Allowable values are: `pending`, `discovery_started`, `discovery_completed`, `error_in_discover`, `gateway_aborted`, `controller_aborted`, `not_accepted`, `waiting_for_refine`, `validation_started`, `validation_completed`, `sent_to_collector`, `discovery_in_progress`, `validation_in_progress`, `error_in_validation`, `discovery_result_posted_with_error`, `discovery_result_posted_no_error`, `validation_result_posted_with_error`, `validation_result_posted_no_error`, `fact_collection_started`, `fact_collection_in_progress`, `fact_collection_completed`, `error_in_fact_collection`, `fact_validation_started`, `fact_validation_in_progress`, `fact_validation_completed`, `error_in_fact_validation`, `abort_task_request_received`, `error_in_abort_task_request`, `abort_task_request_completed`, `user_aborted`, `abort_task_request_failed`, `cve_validation_started`, `cve_validation_completed`, `cve_validation_error`, `eol_validation_started`, `eol_validation_completed`, `eol_validation_error`, `cve_regular_validation_started`, `cve_regular_validation_completed`, `cve_regular_validation_error`, `eol_regular_validation_started`, `eol_regular_validation_completed`, `eol_regular_validation_error`, `cert_validation_started`, `cert_validation_completed`, `cert_validation_error`, `cert_regular_validation_started`, `cert_regular_validation_completed`, `cert_regular_validation_error`, `remediation_started`, `remediation_in_progress`, `error_in_remediation`, `remediation_completed`, `inventory_started`, `inventory_in_progress`, `inventory_completed`, `error_in_inventory`, `inventory_completed_with_error`, `location_change_aborted`. - * `task_status_msg` - (Optional, String) Stores the value of task_status_msg . - * `task_task_type` - (Optional, String) Stores the value of task_task_type . - * Constraints: Allowable values are: `nop`, `discover`, `evidence`, `factcollection`, `script`, `tldiscover`, `subsetvalidate`, `factvalidation`, `aborttasks`, `cve_validation`, `eol_validation`, `cve_regular_validation`, `eol_regular_validation`, `cert_regular_validation`, `cert_validation`, `remediation`, `inventory`. - * `task_updated_time` - (Optional, Integer) Stores the value of task_updated_time . - -* `tld_credentail` - (Optional, List) Stores the value of ScopeDetailsCredential . -Nested scheme for **tld_credentail**: - * `data` - (Optional, Map) Stores the value of credential_data . - * `description` - (Optional, String) Stores the value of credential_description . - * `display_fields` - (Optional, List) Details the fields on the credential. This will change as per credential type selected. - Nested scheme for **display_fields**: - * `auth_url` - (Optional, String) auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_arn` - (Optional, String) AWS arn value. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_id` - (Optional, String) AWS client Id.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `aws_client_secret` - (Optional, String) AWS client secret.This is mandatory for AWS Cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_region` - (Optional, String) AWS region. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_id` - (Optional, String) Azure client Id. This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_client_secret` - (Optional, String) Azure client secret.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_resource_group` - (Optional, String) Azure resource group. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `azure_subscription_id` - (Optional, String) Azure subscription Id.This is mandatory for Azure Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `database_name` - (Optional, String) Database name.This is mandatory for Database Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ibm_api_key` - (Optional, String) The IBM Cloud API Key. This is mandatory for IBM Credential Type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `ms_365_client_id` - (Optional, String) The MS365 client Id.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_client_secret` - (Optional, String) The MS365 client secret.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `ms_365_tenant_id` - (Optional, String) The MS365 tenantId.This is mandatory for Windows MS365 Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `password` - (Optional, String) password of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `pem_data` - (Optional, String) The base64 encoded data to associate with the PEM file. - * Constraints: The maximum length is `4000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `pem_file_name` - (Optional, String) The name of the PEM file. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `project_domain_name` - (Optional, String) project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `project_name` - (Optional, String) Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `user_domain_name` - (Optional, String) user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `username` - (Optional, String) username of the user.This is mandatory for DataBase, Kerbros,OpenStack Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_authtype` - (Optional, String) Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `winrm_port` - (Optional, String) Kerberos windows port.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - * `winrm_usessl` - (Optional, String) Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `gateway_key` - (Optional, String) Stores the value of credential_gateway_key . - * `id` - (Optional, String) Stores the value of credential_id . - * `is_enabled` - (Optional, Boolean) Stores the value of credential_is_enabled . - * `name` - (Optional, String) Stores the value of credential_name . - * `purpose` - (Optional, String) Stores the value of credential_purpose . - * `type` - (Optional, String) Stores the value of credential_type . - * `uuid` - (Optional, String) Stores the value of credential_uuid . - * `version_timestamp` - (Optional, Map) Stores the value of credential_version_timestamp . - -* `tld_credential_id` - (Optional, Integer) Stores the value of scope_tld_credential_id .Will be displayed only when value exists. - -* `type` - (Optional, String) Stores the value of scope_type .Will be displayed only when value exists. - * Constraints: Allowable values are: `validation`, `inventory`. - -* `uuid` - (Optional, String) Stores the value of scope_uuid .Will be displayed only when value exists. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scope is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_scope_correlation.html.markdown b/website/docs/d/scc_posture_scope_correlation.html.markdown deleted file mode 100644 index 0f3031946b..0000000000 --- a/website/docs/d/scc_posture_scope_correlation.html.markdown +++ /dev/null @@ -1,39 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scope_correlation" -description: |- - Get information about scope_correlation -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scope_correlation - -Provides a read-only data source for scope_correlation. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_scope_correlation" "scope_correlation" { - correlation_id = "correlation_id" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your data source. - -* `correlation_id` - (Required, Forces new resource, String) A correlation_Id is created when a scope is created and discovery task is triggered or when a validation is triggered on a Scope. This is used to get the status of the task(discovery or validation). - * Constraints: The maximum length is `50` characters. The minimum length is `3` characters. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the scope_correlation. -* `last_heartbeat` - (String) Returns the time that the scope was last updated. This value exists when collector is installed and running. - -* `start_time` - (String) Returns the time that task started. - -* `status` - (String) Returns the current status of a task. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scope_correlation is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/d/scc_posture_scopes.html.markdown b/website/docs/d/scc_posture_scopes.html.markdown deleted file mode 100644 index 725135bab1..0000000000 --- a/website/docs/d/scc_posture_scopes.html.markdown +++ /dev/null @@ -1,99 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scopes" -description: |- - Get information about list_scopes -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scopes - -Provides a read-only data source for list_scopes. You can then reference the fields of the data source in other resources within the same configuration using interpolation syntax. - -## Example Usage - -```hcl -data "ibm_scc_posture_scopes" "list_scopes" { -} -``` - - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your data source is created. - -* `id` - The unique identifier of the list_scopes. -* `first` - (List) The URL of a page. -Nested scheme for **first**: - * `href` - (String) The URL of a page. - -* `last` - (List) The URL of a page. -Nested scheme for **last**: - * `href` - (String) The URL of a page. - -* `limit` - (Integer) The number of scopes displayed per page. - -* `next` - (List) The URL of a page. -Nested scheme for **next**: - * `href` - (String) The URL of a page. - -* `offset` - (Integer) The offset of the page. - -* `previous` - (List) The URL of a page. -Nested scheme for **previous**: - * `href` - (String) The URL of a page. - -* `scopes` - (List) Scopes. -Nested scheme for **scopes**: - * `collectors` - (List) Stores the value of collectors .Will be displayed only when value exists. - Nested scheme for **collectors**: - * `approved_internet_gateway_ip` - (String) The approved internet gateway ip of the collector. This field will be populated only when collector is installed. - * `approved_local_gateway_ip` - (String) The approved local gateway ip of the collector. This field will be populated only when collector is installed. - * `collector_version` - (String) The collector version. This field is populated when collector is installed. - * `created_at` - (String) The ISO Date/Time the collector was created. - * `created_by` - (String) The id of the user that created the collector. - * `credential_public_key` - (String) The credential public key. - * `description` - (String) The description of the collector. - * `display_name` - (String) The user-friendly name of the collector. - * `enabled` - (Boolean) Identifies whether the collector is enabled or not(deleted). - * `failure_count` - (Integer) The number of times the collector has failed. - * `hostname` - (String) The collector host name. This field will be populated when collector is installed.This will have fully qualified domain name. - * `id` - (String) The id of the collector. - * `image_version` - (String) The image version of the collector. This field is populated when collector is installed. ". - * `install_path` - (String) The installation path of the collector. This field will be populated when collector is installed.The value will be folder path. - * `is_public` - (Boolean) Determines whether the collector endpoint is accessible on a public network.If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network. - * `is_ubi_image` - (Boolean) Determines whether the collector has a Ubi image. - * `last_failed_internet_gateway_ip` - (String) The failed internet gateway ip of the collector. - * `last_failed_local_gateway_ip` - (String) The failed local gateway ip. This field will be populated only when collector is installed. - * `last_heartbeat` - (String) Stores the heartbeat time of a controller . This value exists when collector is installed and running. - * `managed_by` - (String) The entity that manages the collector. - * Constraints: Allowable values are: `ibm`, `customer`. - * `name` - (String) The name of the collector. - * `public_key` - (String) The public key of the collector.Will be used for ssl communciation between collector and orchestrator .This will be populated when collector is installed. - * `registration_code` - (String) The registration code of the collector.This is will be used for initial authentication during installation of collector. - * `reset_reason` - (String) The reason for the collector reset .User resets the collector with a reason for reset. The reason entered by the user is saved in this field . - * `reset_time` - (String) The ISO Date/Time of the collector reset. This value will be populated when a collector is reset. The data-time when the reset event is occured is captured in this field. - * `status` - (String) The status of collector. - * Constraints: Allowable values are: `ready_to_install`, `core_downloaded`, `approval_required`, `approved_download_in_progress`, `approved_install_in_progress`, `install_in_progress`, `installed`, `installed_credentials_required`, `installed_assigning_credentials`, `active`, `unable_to_connect`, `waiting_for_upgrade`, `suspended`, `installation_failed`. - * `status_description` - (String) The collector status. - * `trial_expiry` - (String) The trial expiry. This holds the expiry date of registration_code. This field will be populated when collector is installed. - * `type` - (String) The type of the collector. - * Constraints: Allowable values are: `restricted`, `unrestricted`. - * `updated_at` - (String) The ISO Date/Time the collector was modified. - * `updated_by` - (String) The id of the user that modified the collector. - * `use_private_endpoint` - (Boolean) Whether the collector should use a public or private endpoint. This value is generated based on is_public field value during collector creation. If is_public is set to true, this value will be false. - * `created_at` - (String) The time that the scope was created in UTC. - * `created_by` - (String) The user who created the scope. - * `credential_type` - (String) The environment that the scope is targeted to. - * Constraints: Allowable values are: `ibm`, `aws`, `azure`, `on_premise`, `hosted`, `services`, `openstack`, `gcp`. - * `description` - (String) A detailed description of the scope. - * `enabled` - (Boolean) Indicates whether scope is enabled/disabled. - * `id` - (String) An auto-generated unique identifier for the scope. - * `modified_by` - (String) The user who most recently modified the scope. - * `name` - (String) A unique name for your scope. - * `updated_at` - (String) The time that the scope was last modified in UTC. - * `uuid` - (String) Stores the value of scope_uuid . - -* `total_count` - (Integer) The total number of scopes. This value is 0 if no scopes are available and below fields will not be available in that case. - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scopes is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/r/scc_posture_collector.html.markdown b/website/docs/r/scc_posture_collector.html.markdown deleted file mode 100644 index 70a8400568..0000000000 --- a/website/docs/r/scc_posture_collector.html.markdown +++ /dev/null @@ -1,61 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_collector" -description: |- - Manages collectors. -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_collector - -Provides a resource for collectors. This allows collectors to be created, updated and deleted. - -## Example Usage - -```hcl -resource "ibm_scc_posture_collector" "collectors" { - description = "sample collector" - is_public = true - managed_by = "ibm" - name = "IBM-collector-sample" - passphrase = "secret" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your resource. - -* `description` - (Optional, String) A detailed description of the collector. - * Constraints: The default value is ``. The maximum length is `1000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\._,\\s]*$/`. - !> **Removal Notification** Resource Removal: Resource ibm_scc_posture_collector is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). -* `is_public` - (Required, Boolean) Determines whether the collector endpoint is accessible on a public network. If set to `true`, the collector connects to resources in your account over a public network. If set to `false`, the collector connects to resources by using a private IP that is accessible only through the IBM Cloud private network. -* `is_ubi_image` - (Optional, Boolean) Determines whether the collector has a Ubi image. -* `managed_by` - (Required, String) Determines whether the collector is an IBM or customer-managed virtual machine. Use `ibm` to allow Security and Compliance Center to create, install, and manage the collector on your behalf. The collector is installed in an OpenShift cluster and approved automatically for use. Use `customer` if you would like to install the collector by using your own virtual machine. For more information, check out the [docs](https://cloud.ibm.com/docs/security-compliance?topic=security-compliance-collector). - * Constraints: Allowable values are: `ibm`, `customer`. -* `name` - (Required, String) A unique name for your collector. - * Constraints: The maximum length is `32` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. -* `passphrase` - (Optional, String) To protect the credentials that you add to the service, a passphrase is used to generate a data encryption key. The key is used to securely store your credentials and prevent anyone from accessing them. - * Constraints: The maximum length is `200` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\._,\\s]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your resource is created. - -* `id` - The unique identifier of the collectors. - -## Import - -You can import the `ibm_scc_posture_collector` resource by using `id`. An identifier of the collector. - -# Syntax -``` -$ terraform import ibm_scc_posture_collector.collectors -``` - -# Example -``` -$ terraform import ibm_scc_posture_collector.collectors 1 -``` - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_collector is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/r/scc_posture_credential.html.markdown b/website/docs/r/scc_posture_credential.html.markdown deleted file mode 100644 index 6b8a525209..0000000000 --- a/website/docs/r/scc_posture_credential.html.markdown +++ /dev/null @@ -1,109 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_credential" -description: |- - Manages credentials. -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_credential - -Provides a resource for credentials. This allows credentials to be created, updated and deleted. - -## Example Usage - -```hcl -resource "ibm_scc_posture_credential" "credentials" { - description = "This credential is used for testing." - display_fields {"password":"testpassword","username":"test"} - enabled = true - name = "test_create" - purpose = "discovery_fact_collection_remediation" - type = "username_password" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your resource. - -* `description` - (Required, String) Credentials description. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\._,\\s]*$/`. -* `display_fields` - (Required, List) Details the fields on the credential. This will change as per credential type selected. -Nested scheme for **display_fields**: - * `auth_url` - (Optional, String) auth url of the Open Stack cloud.This is mandatory for Open Stack Credential type ie when type=openstack_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_arn` - (Optional, String) AWS arn value.This is used for AWS Cloud ie when type=aws_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_client_id` - (Optional, String) AWS client Id.This is mandatory for AWS Cloud ie when type=aws_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_client_secret` - (Optional, String) AWS client secret.This is mandatory for AWS Cloud ie when type=aws_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `aws_region` - (Optional, String) AWS region.This is used for AWS Cloud ie when type=aws_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_client_id` - (Optional, String) Azure client Id. This is mandatory for Azure Credential type ie when type=azure_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_client_secret` - (Optional, String) Azure client secret.This is mandatory for Azure Credential type ie when type=azure_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_resource_group` - (Optional, String) Azure resource group.This field is used for Azure Credential type ie when type=azure_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `azure_subscription_id` - (Optional, String) Azure subscription Id.This is mandatory for Azure Credential type ie when type=azure_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `database_name` - (Optional, String) Database name.This is mandatory for Database Credential type ie when type=database. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `ibm_api_key` - (Optional, String) The IBM Cloud API Key. This is mandatory for IBM Credential Type ie when type=ibm_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `ms_365_client_id` - (Optional, String) The MS365 client Id.This is mandatory for Windows MS365 Credential type ie when type=ms_365. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `ms_365_client_secret` - (Optional, String) The MS365 client secret.This is mandatory for Windows MS365 Credential type ie when type=ms_365. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `ms_365_tenant_id` - (Optional, String) The MS365 tenantId.This is mandatory for Windows MS365 Credential type ie when type=ms_365. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `password` - (Optional, String) password of the user.This is mandatory for DataBase(ie type=database), Kerbros(ie type=kerberos_windows),OpenStack(ie type=openstack_cloud) and Username-Password(type=username_password) Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `pem_data` - (Optional, String) The base64 encoded data to associate with the PEM file. - * Constraints: The maximum length is `4000` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - * `pem_file_name` - (Optional, String) The name of the PEM file. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `project_domain_name` - (Optional, String) project domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type ie when type=openstack_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `project_name` - (Optional, String) Project name of the Open Stack cloud.This is mandatory for Open Stack Credential type ie when type=openstack_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `user_domain_name` - (Optional, String) user domain name of the Open Stack cloud.This is mandatory for Open Stack Credential type ie when type=openstack_cloud. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `username` - (Optional, String) username of the user.This is mandatory for DataBase(ie type=database), Kerbros(ie type=kerberos_windows),OpenStack(ie type=openstack_cloud) and Username-Password(type=username_password) Credentials. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `winrm_authtype` - (Optional, String) Kerberos windows auth type.This is mandatory for Windows Kerberos Credential type ie when type=kerberos_windows. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. - * `winrm_port` - (Optional, String) Kerberos windows port.This is mandatory for Windows Kerberos Credential type ie when type=kerberos_windows. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9]*$/`. - * `winrm_usessl` - (Optional, String) Kerberos windows ssl.This is mandatory for Windows Kerberos Credential type ie when type=kerberos_windows. - * Constraints: The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.\\*,_\\s]*$/`. -* `enabled` - (Required, Boolean) Credentials status enabled/disbaled. -* `name` - (Required, String) Credentials name. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\._,\\s]*$/`. -* `purpose` - (Required, String) Purpose for which the credential is created. - * Constraints: Allowable values are: `discovery_collection`, `discovery_fact_collection`, `remediation`, `discovery_collection_remediation`, `discovery_fact_collection_remediation`. The maximum length is `100` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. -* `type` - (Required, String) Credentials type. - * Constraints: Allowable values are: `username_password`, `aws_cloud`, `azure_cloud`, `database`, `kerberos_windows`, `ms_365`, `openstack_cloud`, `ibm_cloud`, `user_name_pem`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your resource is created. - -* `id` - The unique identifier of the credentials. - -## Import - -You can import the `ibm_scc_posture_credential` resource by using `id`. An identifier of the credential. - -# Syntax -``` -$ terraform import ibm_scc_posture_credential.credentials -``` - -# Example -``` -$ terraform import ibm_scc_posture_credential.credentials 1 -``` -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_credential is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/r/scc_posture_profile_import.html.markdown b/website/docs/r/scc_posture_profile_import.html.markdown deleted file mode 100644 index aacca5e85c..0000000000 --- a/website/docs/r/scc_posture_profile_import.html.markdown +++ /dev/null @@ -1,46 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_profile_import" -description: |- - To Import profile. -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_profile_import - -Provides a resource for profiles. This allows profiles to be import a profile that you formatted locally. - -## Example Usage - -```hcl -resource "ibm_scc_posture_profile_import" "profiles" { - file = "/local_path_to_import_profile.csv" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your resource. - -* `file` - (Required, Forces new resource, String) The import data file that you want to use to import a profile. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your resource is created. - -* `id` - The unique identifier of the profiles. - -## Import - -You can import the `ibm_scc_posture_profile_import` resource by using `id`. An identifier of the profile. - -# Syntax -``` -$ terraform import ibm_scc_posture_profile_import.profiles -``` - -# Example -``` -$ terraform import ibm_scc_posture_profile_import.profiles 1 -``` -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_profile_import is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/r/scc_posture_scan_initiate_validation.html.markdown b/website/docs/r/scc_posture_scan_initiate_validation.html.markdown deleted file mode 100644 index 0f3a958820..0000000000 --- a/website/docs/r/scc_posture_scan_initiate_validation.html.markdown +++ /dev/null @@ -1,59 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scan_initiate_validation" -description: |- - To initiate a validation scan. -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scan_initiate_validation - -Provides a resource for initiate a validation scan. This allows to initiate validation scans determine a specified scope's adherence to regulatory controls by validating the configuration of the resources in your scope to the attached profile. - -## Example Usage - -```hcl -resource "ibm_scc_posture_scan_initiate_validation" "scanInitiateValidation" { - scope_id = "scope_id" - profile_id = "profile_id" - group_profile_id = "group_profile_id" - name = "name" - description = "description" - frequency = 1 - no_of_occurrences = 1 -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your resource. - -* `scope_id` - (Required, Forces new resource, String) - The unique ID of the scope. -* `profile_id` - (Required, Forces new resource, String) - The unique ID of the profile. -* `group_profile_id` - (Optional, String) - The ID of the profile group. -* `name` - (Optional, String) - The name of a scheduled scan. -* `description` - (Optional, String) - The description of a scheduled scan. -* `frequency` - (Optional, int) - The frequency at which a scan is run specified in milliseconds. -* `no_of_occurrences` - (Optional, int) - The number of times that a scan should be run. -* `end_time` - (Optional, String) - The date on which a scan should stop running specified in UTC. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your resource is created. - -* `id` - The correlation identifier of the initiated validation scan. - -## Import - -You can import the `ibm_scc_posture_scan_initiate_validation` resource by using `id`. An identifier of the initiated validation scan. - -# Syntax -``` -$ terraform import ibm_scc_posture_scan_initiate_validation.scans -``` - -# Example -``` -$ terraform import ibm_scc_posture_scan_initiate_validation.scans 1 -``` -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scan_initiate_validation is deprecated and being removed.\n This resource will not be available from future release (v1.54.0). diff --git a/website/docs/r/scc_posture_scope.html.markdown b/website/docs/r/scc_posture_scope.html.markdown deleted file mode 100644 index 6a8682cb52..0000000000 --- a/website/docs/r/scc_posture_scope.html.markdown +++ /dev/null @@ -1,64 +0,0 @@ ---- -layout: "ibm" -page_title: "IBM : ibm_scc_posture_scope" -description: |- - Manages scopes. -subcategory: "Security and Compliance Center" ---- - -# ibm_scc_posture_scope - -Provides a resource for scopes. This allows scopes to be created, updated and deleted. Before creation of the scope, we need to create credential and collector. - -## Example Usage - -```hcl -resource "ibm_scc_posture_scope" "scopes" { - credential_id = "5" - credential_type = "on_premise" - description = "IBMSchema" - interval = 10 - is_discovery_scheduled = true - name = "IBMSchema-new-048-test" -} -``` - -## Argument Reference - -Review the argument reference that you can specify for your resource. - -* `collector_ids` - (Required, List) The unique IDs of the collectors that are attached to the scope. - * Constraints: The list items must match regular expression `/^[0-9]*$/`. -* `credential_id` - (Required, String) The unique identifier of the credential. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. -* `credential_type` - (Required, String) The environment that the scope is targeted to. - * Constraints: Allowable values are: `ibm`, `aws`, `azure`, `on_premise`, `hosted`, `services`, `openstack`, `gcp`. -* `description` - (Required, String) A detailed description of the scope. - * Constraints: The maximum length is `255` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. -* `interval` - (Optional, Integer) Stores the value of Frequency. This is used in case of on-prem Scope if the user wants to schedule a discovery task.The unit is seconds. Example if a user wants to trigger discovery every hour, this value will be set to 3600. -* `is_discovery_scheduled` - (Optional, Boolean) Stores the value of Discovery Scheduled.This is used in case of on-prem Scope if the user wants to schedule a discovery task. - * Constraints: The default value is `false`. -* `name` - (Required, String) A unique name for your scope. - * Constraints: The maximum length is `50` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9-\\.,_\\s]*$/`. - -## Attribute Reference - -In addition to all argument references listed, you can access the following attribute references after your resource is created. - -* `id` - The unique identifier of the scopes. - -## Import - -You can import the `ibm_scc_posture_scope` resource by using `id`. An identifier of the scope. - -# Syntax -``` -$ terraform import ibm_scc_posture_scope.scopes -``` - -# Example -``` -$ terraform import ibm_scc_posture_scope.scopes 1 -``` - -!> **Removal Notification** Resource Removal: Resource ibm_scc_posture_scope is deprecated and being removed.\n This resource will not be available from future release (v1.54.0).