Skip to content

Commit

Permalink
fix(scc): added posture profile import and intitiate validation scan (I…
Browse files Browse the repository at this point in the history
…BM-Cloud#4003)

* fix(scc): added posture profile import and intitiate validation scan

* fix: review comments

* fix: review comments

Co-authored-by: Pavan Kumar Manda <[email protected]>
  • Loading branch information
pavanm87 and Pavan Kumar Manda authored Sep 7, 2022
1 parent 9d4edfc commit 4c19e32
Show file tree
Hide file tree
Showing 33 changed files with 734 additions and 103 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/IBM/platform-services-go-sdk v0.28.2
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5
github.com/IBM/scc-go-sdk/v3 v3.1.6
github.com/IBM/scc-go-sdk/v4 v4.0.0 // indirect
github.com/IBM/schematics-go-sdk v0.2.1
github.com/IBM/secrets-manager-go-sdk v0.1.19
github.com/IBM/vpc-go-sdk v0.22.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 h1:N
github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5/go.mod h1:b07XHUVh0XYnQE9s2mqgjYST1h9buaQNqN4EcKhOsX0=
github.com/IBM/scc-go-sdk/v3 v3.1.6 h1:wg7yujuJJ1O1pcGrIn8ITq6i6GeXb7GRBPNq6kLrkMU=
github.com/IBM/scc-go-sdk/v3 v3.1.6/go.mod h1:cBxkth9AIOcKQx4Gy9bWgyGYa7vYwHAalUBvY+O8xAE=
github.com/IBM/scc-go-sdk/v4 v4.0.0 h1:Fes2/SVzhrNkD8U12W75MQeOzAZmhSPJHmq6+Txsn4A=
github.com/IBM/scc-go-sdk/v4 v4.0.0/go.mod h1:ufqf/kBtRn3Pq/pFXF6zQGHXV2P2EzPsntw1Sw19clE=
github.com/IBM/schematics-go-sdk v0.2.1 h1:byATysGD+Z1k/wdtNqQmKALcAPjgSLuSyzcabh1jRAw=
github.com/IBM/schematics-go-sdk v0.2.1/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ=
github.com/IBM/secrets-manager-go-sdk v0.1.19 h1:0GPs5EoTaWNsjo4QPj64GNxlWfN8VHJy4RDFLqddSe8=
Expand Down
4 changes: 2 additions & 2 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import (
"github.com/IBM/push-notifications-go-sdk/pushservicev1"
"github.com/IBM/scc-go-sdk/v3/adminserviceapiv1"
"github.com/IBM/scc-go-sdk/v3/configurationgovernancev1"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
schematicsv1 "github.com/IBM/schematics-go-sdk/schematicsv1"
"github.com/IBM/secrets-manager-go-sdk/secretsmanagerv1"
vpc "github.com/IBM/vpc-go-sdk/vpcv1"
Expand Down Expand Up @@ -114,7 +114,7 @@ import (
"github.com/IBM/event-notifications-go-admin-sdk/eventnotificationsv1"
"github.com/IBM/eventstreams-go-sdk/pkg/schemaregistryv1"
"github.com/IBM/ibm-hpcs-uko-sdk/ukov4"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv1"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv1"
)

// RetryAPIDelay - retry api delay
Expand Down
161 changes: 82 additions & 79 deletions ibm/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,11 @@ func Provider() *schema.Provider {
"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_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(),
Expand Down Expand Up @@ -1198,82 +1200,83 @@ 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_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_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_route": vpc.ResourceIBMISRouteValidator(),
"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_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_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_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_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_route": vpc.ResourceIBMISRouteValidator(),
"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_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(),

// // Added for Event Notifications
"ibm_en_destination": eventnotification.ResourceIBMEnDestinationValidator(),
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/scc/data_source_ibm_scc_posture_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureCollector() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/scc/data_source_ibm_scc_posture_collectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureCollectors() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/scc/data_source_ibm_scc_posture_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureCredential() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/scc/data_source_ibm_scc_posture_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureCredentials() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

//"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureGroupProfileDetails() *schema.Resource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/go-sdk-core/v5/core"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureLatestScans() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion ibm/service/scc/data_source_ibm_scc_posture_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
"github.com/IBM/scc-go-sdk/v4/posturemanagementv2"
)

func DataSourceIBMSccPostureProfileDetails() *schema.Resource {
Expand Down
Loading

0 comments on commit 4c19e32

Please sign in to comment.