Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Resource] Network Security Group Rule #159

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c7c3d8d
Update dependencies
ismirlia Aug 19, 2024
ddedb39
Connect new resource and tests
ismirlia Aug 19, 2024
e8e487b
Add network security group rule resource
ismirlia Aug 19, 2024
f496990
Add network security group rule markdown
ismirlia Aug 19, 2024
02ee544
Add constants and fix member/rule mixup
ismirlia Aug 20, 2024
d7a8976
Fix network security group rule delete
ismirlia Aug 20, 2024
ce1028c
Beta 10 fixes
ismirlia Aug 26, 2024
d5a3fdc
Remove commented out code
ismirlia Aug 26, 2024
6ea40e5
Merge branch 'master' into nsg-member
ismirlia Aug 27, 2024
b10d13e
Beta 11 fixes
ismirlia Aug 27, 2024
5f0f3f9
Merge branch 'master' of github.com:powervs-ibm/terraform-provider-ib…
ismirlia Sep 5, 2024
4bd772c
Fix nsg rule schema
ismirlia Sep 5, 2024
4eab5f0
Add nsg rule test
ismirlia Sep 5, 2024
e777c9f
Update to beta13
ismirlia Sep 5, 2024
b23bf29
Update icmp_types
ismirlia Sep 6, 2024
e162e8d
Fix tcp flag case
ismirlia Sep 6, 2024
7366870
Update tcg flag schema
ismirlia Sep 9, 2024
76bd323
Update nsg rule integration tests
ismirlia Sep 9, 2024
4c0f269
Update markdown
ismirlia Sep 9, 2024
90e1c9f
Fix member set
ismirlia Sep 9, 2024
f12d668
Remove unused code
ismirlia Sep 9, 2024
4d37ade
Merge branch 'master' of github.com:powervs-ibm/terraform-provider-ib…
ismirlia Sep 9, 2024
966e7aa
Update to beta15
ismirlia Sep 9, 2024
ae4f8cb
Remove duplicate constants
ismirlia Sep 9, 2024
c080474
Update nsg with beta 17 changes
ismirlia Sep 16, 2024
d0a153b
Fix nsg markdown
ismirlia Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.5
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113
github.com/IBM-Cloud/power-go-client v1.7.0
github.com/IBM-Cloud/power-go-client v1.8.0-beta13
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.3.0
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ github.com/IBM-Cloud/bluemix-go v0.0.0-20240719075425-078fcb3a55be/go.mod h1:/7h
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113 h1:f2Erqfea1dKpaTFagTJM6W/wnD3JGq/Vn9URh8nuRwk=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20240725064144-454a2ae23113/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.7.0 h1:/GuGwPMTKoCZACfnwt7b6wKr4v32q1VO1AMFGNETRN4=
github.com/IBM-Cloud/power-go-client v1.7.0/go.mod h1:9izycYAmNQ+NAdVPXDC3fHYxqWLjlR2YiwqKYveMv5Y=
github.com/IBM-Cloud/power-go-client v1.8.0-beta13 h1:DYogFiTNamIHKXmXZ6BmaoTSP4OLKU1eYO8uCKZc5LQ=
github.com/IBM-Cloud/power-go-client v1.8.0-beta13/go.mod h1:oAkZiHX25cmr2Yun5V0q6CpnUemegvSrpcEy/oQcjzU=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand Down
95 changes: 62 additions & 33 deletions ibm/acctest/acctest.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,39 +203,43 @@ var (
// For Power Colo

var (
Pi_auxiliary_volume_name string
Pi_cloud_instance_id string
Pi_dhcp_id string
Pi_host_group_id string
Pi_host_id string
Pi_image string
Pi_image_bucket_access_key string
Pi_image_bucket_file_name string
Pi_image_bucket_name string
Pi_image_bucket_region string
Pi_image_bucket_secret_key string
Pi_instance_name string
Pi_key_name string
Pi_network_name string
Pi_placement_group_name string
Pi_replication_volume_name string
Pi_resource_group_id string
Pi_sap_image string
Pi_shared_processor_pool_id string
Pi_snapshot_id string
Pi_spp_placement_group_id string
Pi_target_storage_tier string
Pi_volume_clone_task_id string
Pi_volume_group_id string
Pi_volume_group_name string
Pi_volume_id string
Pi_volume_name string
Pi_volume_onboarding_id string
Pi_volume_onboarding_source_crn string
PiCloudConnectionName string
PiSAPProfileID string
PiStoragePool string
PiStorageType string
Pi_auxiliary_volume_name string
Pi_cloud_instance_id string
Pi_dhcp_id string
Pi_host_group_id string
Pi_host_id string
Pi_image string
Pi_image_bucket_access_key string
Pi_image_bucket_file_name string
Pi_image_bucket_name string
Pi_image_bucket_region string
Pi_image_bucket_secret_key string
Pi_instance_name string
Pi_key_name string
Pi_network_name string
Pi_network_security_group_id string
Pi_network_security_group_rule_id string
Pi_placement_group_name string
Pi_remote_id string
Pi_remote_type string
Pi_replication_volume_name string
Pi_resource_group_id string
Pi_sap_image string
Pi_shared_processor_pool_id string
Pi_snapshot_id string
Pi_spp_placement_group_id string
Pi_target_storage_tier string
Pi_volume_clone_task_id string
Pi_volume_group_id string
Pi_volume_group_name string
Pi_volume_id string
Pi_volume_name string
Pi_volume_onboarding_id string
Pi_volume_onboarding_source_crn string
PiCloudConnectionName string
PiSAPProfileID string
PiStoragePool string
PiStorageType string
)

var (
Expand Down Expand Up @@ -1061,6 +1065,18 @@ func init() {
fmt.Println("[INFO] Set the environment variable PI_NETWORK_NAME for testing ibm_pi_network_name resource else it is set to default value 'terraform-test-power'")
}

Pi_network_security_group_id = os.Getenv("PI_NETWORK_SECURITY_GROUP_ID")
if Pi_network_security_group_id == "" {
Pi_network_security_group_id = "terraform-test-power"
fmt.Println("[INFO] Set the environment variable PI_NETWORK_SECURITY_GROUP_ID for testing ibm_pi_network_security_group resource else it is set to default value 'terraform-test-power'")
}

Pi_network_security_group_rule_id = os.Getenv("PI_NETWORK_SECURITY_GROUP_RULE_ID")
if Pi_network_security_group_rule_id == "" {
Pi_network_security_group_rule_id = "terraform-test-power"
fmt.Println("[INFO] Set the environment variable PI_NETWORK_SECURITY_GROUP_RULE_ID for testing ibm_pi_network_security_group resource else it is set to default value 'terraform-test-power'")
}

Pi_volume_name = os.Getenv("PI_VOLUME_NAME")
if Pi_volume_name == "" {
Pi_volume_name = "terraform-test-power"
Expand Down Expand Up @@ -1150,6 +1166,19 @@ func init() {
Pi_placement_group_name = "tf-pi-placement-group"
fmt.Println("[WARN] Set the environment variable PI_PLACEMENT_GROUP_NAME for testing ibm_pi_placement_group resource else it is set to default value 'tf-pi-placement-group'")
}

Pi_remote_id = os.Getenv("PI_REMOTE_ID")
if Pi_remote_id == "" {
Pi_remote_id = "tf-pi-placement-group"
fmt.Println("[WARN] Set the environment variable PI_REMOTE_ID for testing ibm_pi_placement_group resource else it is set to default value 'tf-pi-placement-group'")
}

Pi_remote_type = os.Getenv("PI_REMOTE_TYPE")
if Pi_remote_type == "" {
Pi_remote_type = "tf-pi-placement-group"
fmt.Println("[WARN] Set the environment variable PI_REMOTE_TYPE for testing ibm_pi_placement_group resource else it is set to default value 'tf-pi-placement-group'")
}

Pi_spp_placement_group_id = os.Getenv("PI_SPP_PLACEMENT_GROUP_ID")
if Pi_spp_placement_group_id == "" {
Pi_spp_placement_group_id = "tf-pi-spp-placement-group"
Expand Down
32 changes: 32 additions & 0 deletions ibm/flex/structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,38 @@ func FlattenIntList(list []int) []interface{} {
return vs
}

func ExpandInt64List(input []interface{}) []int64 {
vs := make([]int64, len(input))
for i, v := range input {
vs[i] = v.(int64)
}
return vs
}

func FlattenInt64List(list []int64) []interface{} {
vs := make([]interface{}, len(list))
for i, v := range list {
vs[i] = v
}
return vs
}

func ExpandFloat64List(input []interface{}) []float64 {
vs := make([]float64, len(input))
for i, v := range input {
vs[i] = v.(float64)
}
return vs
}

func FlattenFloat64List(list []float64) []interface{} {
vs := make([]interface{}, len(list))
for i, v := range list {
vs[i] = v
}
return vs
}

ismirlia marked this conversation as resolved.
Show resolved Hide resolved
func NewStringSet(f schema.SchemaSetFunc, in []string) *schema.Set {
var out = make([]interface{}, len(in), len(in))
for i, v := range in {
Expand Down
1 change: 1 addition & 0 deletions ibm/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,7 @@ func Provider() *schema.Provider {
"ibm_pi_ipsec_policy": power.ResourceIBMPIIPSecPolicy(),
"ibm_pi_key": power.ResourceIBMPIKey(),
"ibm_pi_network_port_attach": power.ResourceIBMPINetworkPortAttach(),
"ibm_pi_network_security_group_rule": power.ResourceIBMPINetworkSecurityGroupRule(),
"ibm_pi_network": power.ResourceIBMPINetwork(),
"ibm_pi_placement_group": power.ResourceIBMPIPlacementGroup(),
"ibm_pi_shared_processor_pool": power.ResourceIBMPISharedProcessorPool(),
Expand Down
39 changes: 39 additions & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ const (
Arg_DeploymentTarget = "pi_deployment_target"
Arg_DeploymentType = "pi_deployment_type"
Arg_Description = "pi_description"
Arg_DestinationPorts = "pi_destination_ports"
Arg_DhcpID = "pi_dhcp_id"
Arg_DhcpName = "pi_dhcp_name"
Arg_DhcpSnatEnabled = "pi_dhcp_snat_enabled"
Arg_DnsServer = "pi_dns_server"
Arg_Flag = "pi_flag"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_HealthStatus = "pi_health_status"
Arg_Host = "pi_host"
Arg_HostGroupID = "pi_host_group_id"
Expand All @@ -32,6 +34,8 @@ const (
Arg_IBMiCSS = "pi_ibmi_css"
Arg_IBMiPHA = "pi_ibmi_pha"
Arg_IBMiRDSUsers = "pi_ibmi_rds_users"
Arg_ICMPTypes = "pi_icmp_types"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_ID = "pi_id"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_ImageID = "pi_image_id"
Arg_ImageImportDetails = "pi_image_import_details"
Arg_ImageName = "pi_image_name"
Expand All @@ -42,26 +46,35 @@ const (
Arg_KeyPairName = "pi_key_pair_name"
Arg_LanguageCode = "pi_language_code"
Arg_LicenseRepositoryCapacity = "pi_license_repository_capacity"
Arg_Maximum = "pi_maximum"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_Memory = "pi_memory"
Arg_Minimum = "pi_minimum"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_Name = "pi_name"
Arg_Network = "pi_network"
Arg_NetworkName = "pi_network_name"
Arg_NetworkSecurityGroupID = "pi_network_security_group_id"
Arg_NetworkSecurityGroupRuleID = "pi_network_security_group_rule_id"
Arg_PinPolicy = "pi_pin_policy"
Arg_PlacementGroupID = "pi_placement_group_id"
Arg_PlacementGroupName = "pi_placement_group_name"
Arg_PlacementGroupPolicy = "pi_placement_group_policy"
Arg_Plan = "pi_plan"
Arg_Processors = "pi_processors"
Arg_ProcType = "pi_proc_type"
Arg_Protocol = "pi_protocol"
Arg_PVMInstanceActionType = "pi_action"
Arg_PVMInstanceHealthStatus = "pi_health_status"
Arg_PVMInstanceId = "pi_instance_id"
Arg_Remote = "pi_remote"
Arg_RemoteID = "pi_remote_id"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be removed. Not in use.

Arg_Remove = "pi_remove"
Arg_Replicants = "pi_replicants"
Arg_ReplicationEnabled = "pi_replication_enabled"
Arg_ReplicationPolicy = "pi_replication_policy"
Arg_ReplicationScheme = "pi_replication_scheme"
Arg_ResourceGroupID = "pi_resource_group_id"
Arg_RuleID = "pi_rule_id"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be removed. Not in use.

Arg_RuleName = "pi_rule_name"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be removed. Not in use.

Arg_SAP = "sap"
Arg_SAPDeploymentType = "pi_sap_deployment_type"
Arg_SAPProfileID = "pi_sap_profile_id"
Expand All @@ -74,6 +87,7 @@ const (
Arg_SharedProcessorPoolReservedCores = "pi_shared_processor_pool_reserved_cores"
Arg_SnapshotID = "pi_snapshot_id"
Arg_SnapShotName = "pi_snap_shot_name"
Arg_SourcePorts = "pi_source_ports"
Arg_SPPPlacementGroupID = "pi_spp_placement_group_id"
Arg_SPPPlacementGroupName = "pi_spp_placement_group_name"
Arg_SPPPlacementGroupPolicy = "pi_spp_placement_group_policy"
Expand All @@ -84,6 +98,7 @@ const (
Arg_StorageType = "pi_storage_type"
Arg_SysType = "pi_sys_type"
Arg_TargetStorageTier = "pi_target_storage_tier"
Arg_Type = "pi_type"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Arg_UserData = "pi_user_data"
Arg_VirtualCoresAssigned = "pi_virtual_cores_assigned"
Arg_VirtualOpticalDevice = "pi_virtual_optical_device"
Expand Down Expand Up @@ -160,6 +175,7 @@ const (
Attr_DeleteOnTermination = "delete_on_termination"
Attr_DeploymentType = "deployment_type"
Attr_Description = "description"
Attr_DestinationPort = "destination_port"
Attr_Details = "details"
Attr_DhcpID = "dhcp_id"
Attr_DhcpManaged = "dhcp_managed"
Expand All @@ -174,6 +190,7 @@ const (
Attr_FailureMessage = "failure_message"
Attr_FailureReason = "failure_reason"
Attr_Fault = "fault"
Attr_Flag = "flag"
Attr_FlashCopyMappings = "flash_copy_mappings"
Attr_FlashCopyName = "flash_copy_name"
Attr_FreezeTime = "freeze_time"
Expand All @@ -197,6 +214,7 @@ const (
Attr_IBMiPHA = "ibmi_pha"
Attr_IBMiRDS = "ibmi_rds"
Attr_IBMiRDSUsers = "ibmi_rds_users"
Attr_ICMPTypes = "icmp_types"
Attr_ID = "id"
Attr_ImageID = "image_id"
Attr_ImageInfo = "image_info"
Expand Down Expand Up @@ -235,19 +253,23 @@ const (
Attr_MaxAllocationSize = "max_allocation_size"
Attr_MaxAvailable = "max_available"
Attr_MaxCoresAvailable = "max_cores_available"
Attr_Maximum = "maximum"
Attr_MaximumStorageAllocation = "max_storage_allocation"
Attr_MaxMem = "maxmem"
Attr_MaxMemory = "max_memory"
Attr_MaxMemoryAvailable = "max_memory_available"
Attr_MaxProc = "maxproc"
Attr_MaxProcessors = "max_processors"
Attr_MaxVirtualCores = "max_virtual_cores"
Attr_MemberNetworkSecurityGroupID = "member_network_security_group_id"
Attr_Members = "members"
Attr_MemberType = "member_type"
Attr_Memory = "memory"
Attr_Message = "message"
Attr_Metered = "metered"
Attr_MigrationStatus = "migration_status"
Attr_Min = "min"
Attr_Minimum = "minimum"
Attr_MinMem = "minmem"
Attr_MinMemory = "min_memory"
Attr_MinProc = "minproc"
Expand All @@ -260,6 +282,10 @@ const (
Attr_NetworkName = "network_name"
Attr_NetworkPorts = "network_ports"
Attr_Networks = "networks"
Attr_NetworkSecurityGroupID = "network_security_group_id"
Attr_NetworkSecurityGroupMembers = "network_security_group_members"
Attr_NetworkSecurityGroupRules = "network_security_group_rules"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved
Attr_NetworkSecurityGroups = "network_security_groups"
Attr_NumberOfVolumes = "number_of_volumes"
Attr_Onboardings = "onboardings"
Attr_OperatingSystem = "operating_system"
Expand All @@ -282,11 +308,13 @@ const (
Attr_ProfileID = "profile_id"
Attr_Profiles = "profiles"
Attr_Progress = "progress"
Attr_Protocol = "protocol"
Attr_PublicIP = "public_ip"
Attr_PVMInstanceID = "pvm_instance_id"
Attr_PVMInstances = "pvm_instances"
Attr_PVMSnapshots = "pvm_snapshots"
Attr_Region = "region"
Attr_Remote = "remote"
Attr_RemoteCopyID = "remote_copy_id"
Attr_RemoteCopyRelationshipNames = "remote_copy_relationship_names"
Attr_RemoteCopyRelationships = "remote_copy_relationships"
Expand All @@ -299,6 +327,7 @@ const (
Attr_ReservedMemory = "reserved_memory"
Attr_ResultsOnboardedVolumes = "results_onboarded_volumes"
Attr_ResultsVolumeOnboardingFailures = "results_volume_onboarding_failures"
Attr_Rules = "rules"
Attr_SAPS = "saps"
Attr_Secondaries = "secondaries"
Attr_ServerName = "server_name"
Expand All @@ -325,6 +354,7 @@ const (
Attr_SharedProcessorPoolStatusDetail = "status_detail"
Attr_Size = "size"
Attr_SnapshotID = "snapshot_id"
Attr_SourcePort = "source_port"
Attr_SourceVolumeID = "source_volume_id"
Attr_SourceVolumeName = "source_volume_name"
Attr_Speed = "speed"
Expand All @@ -351,8 +381,10 @@ const (
Attr_Systems = "systems"
Attr_SysType = "sys_type"
Attr_Systype = "systype"
Attr_Target = "target"
Attr_TargetVolumeName = "target_volume_name"
Attr_TaskID = "task_id"
Attr_TCPFlags = "tcp_flags"
Attr_TenantID = "tenant_id"
Attr_TenantName = "tenant_name"
Attr_TotalCapacity = "total_capacity"
Expand All @@ -371,6 +403,7 @@ const (
Attr_UsedIPPercent = "used_ip_percent"
Attr_UsedMemory = "used_memory"
Attr_UserIPAddress = "user_ip_address"
Attr_UserTags = "user_tags"
Attr_VCPUs = "vcpus"
Attr_Vendor = "vendor"
Attr_VirtualCoresAssigned = "virtual_cores_assigned"
Expand Down Expand Up @@ -447,6 +480,12 @@ const (
vSCSI = "vSCSI"
Warning = "WARNING"

// Protocol Type
All = "all"
ICMP = "icmp"
TCP = "tcp"
UDP = "udp"
ismirlia marked this conversation as resolved.
Show resolved Hide resolved

// Actions
Action_HardReboot = "hard-reboot"
Action_ImmediateShutdown = "immediate-shutdown"
Expand Down
Loading
Loading