From 3fb1178ff138d3c2febeb6c4478996bca50dd94a Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 15:57:34 -0500 Subject: [PATCH 01/55] Add all resources as free --- internal/providers/terraform/ibm/registry.go | 88 ++++++++++++++----- .../resource_instance_test.tf | 16 ++++ 2 files changed, 80 insertions(+), 24 deletions(-) diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index a05e4e57c99..3ba3488c3b5 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -31,9 +31,9 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ var FreeResources = []string{ "ibm_appid_action_url", "ibm_appid_apm", - "ibm_appid_application", "ibm_appid_application_roles", "ibm_appid_application_scopes", + "ibm_appid_application", "ibm_appid_audit_status", "ibm_appid_cloud_directory_template", "ibm_appid_cloud_directory_user", @@ -43,8 +43,8 @@ var FreeResources = []string{ "ibm_appid_idp_google", "ibm_appid_idp_saml", "ibm_appid_languages", - "ibm_appid_mfa", "ibm_appid_mfa_channel", + "ibm_appid_mfa", "ibm_appid_password_regex", "ibm_appid_redirect_urls", "ibm_appid_role", @@ -56,12 +56,11 @@ var FreeResources = []string{ "ibm_atracker_target", "ibm_cbr_rule", "ibm_cbr_zone", - "ibm_cd_tekton_pipeline", "ibm_cd_tekton_pipeline_definition", "ibm_cd_tekton_pipeline_property", - "ibm_cd_tekton_pipeline_trigger", "ibm_cd_tekton_pipeline_trigger_property", - "ibm_cd_toolchain", + "ibm_cd_tekton_pipeline_trigger", + "ibm_cd_tekton_pipeline", "ibm_cd_toolchain_tool_appconfig", "ibm_cd_toolchain_tool_artifactory", "ibm_cd_toolchain_tool_bitbucketgit", @@ -83,9 +82,10 @@ var FreeResources = []string{ "ibm_cd_toolchain_tool_securitycompliance", "ibm_cd_toolchain_tool_slack", "ibm_cd_toolchain_tool_sonarqube", + "ibm_cd_toolchain", "ibm_cloud_shell_account_settings", "ibm_cloudant_database", - "ibm_code_engine_binding", + "ibm_code_engine_binding", "ibm_code_engine_config_map", "ibm_code_engine_domain_mapping", "ibm_code_engine_project", @@ -93,53 +93,95 @@ var FreeResources = []string{ "ibm_container_addons", "ibm_cos_bucket_object_lock_configuration", "ibm_dns_custom_resolver", + "ibm_en_destination_android", + "ibm_en_destination_ce", + "ibm_en_destination_cf", + "ibm_en_destination_chrome", + "ibm_en_destination_cos", + "ibm_en_destination_custom_email", + "ibm_en_destination_custom_sms", + "ibm_en_destination_firefox", + "ibm_en_destination_huawei", + "ibm_en_destination_ios", + "ibm_en_destination_msteams", + "ibm_en_destination_pagerduty", + "ibm_en_destination_safari", + "ibm_en_destination_slack", + "ibm_en_destination_sn", + "ibm_en_destination_webhook", + "ibm_en_email_template", + "ibm_en_ibmsource", + "ibm_en_integration_cos", + "ibm_en_integration", + "ibm_en_source", + "ibm_en_subscription_android", + "ibm_en_subscription_ce", + "ibm_en_subscription_cf", + "ibm_en_subscription_chrome", + "ibm_en_subscription_cos", + "ibm_en_subscription_custom_email", + "ibm_en_subscription_custom_sms", + "ibm_en_subscription_email", + "ibm_en_subscription_firefox", + "ibm_en_subscription_huawei", + "ibm_en_subscription_ios", + "ibm_en_subscription_msteams", + "ibm_en_subscription_pagerduty", + "ibm_en_subscription_safari", + "ibm_en_subscription_slack", + "ibm_en_subscription_sms", + "ibm_en_subscription_sn", + "ibm_en_subscription_webhook", + "ibm_en_topic", "ibm_event_streams_schema", "ibm_event_streams_topic", - "ibm_iam_access_group", "ibm_iam_access_group_account_settings", "ibm_iam_access_group_dynamic_rule", "ibm_iam_access_group_members", "ibm_iam_access_group_policy", + "ibm_iam_access_group", "ibm_iam_account_settings", "ibm_iam_authorization_policy", "ibm_iam_service_api_key", "ibm_iam_service_id", "ibm_iam_service_policy", - "ibm_iam_trusted_profile", "ibm_iam_trusted_profile_claim_rule", "ibm_iam_trusted_profile_link", "ibm_iam_trusted_profile_policy", + "ibm_iam_trusted_profile", "ibm_is_lb_listener", - "ibm_is_lb_pool", "ibm_is_lb_pool_member", - "ibm_is_network_acl", + "ibm_is_lb_pool", "ibm_is_network_acl_rule", + "ibm_is_network_acl", "ibm_is_placement_group", "ibm_is_public_gateway", - "ibm_is_security_group", "ibm_is_security_group_rule", "ibm_is_security_group_target", + "ibm_is_security_group", "ibm_is_share_delete_accessor_binding", "ibm_is_share_mount_target", "ibm_is_share_replica_operations", "ibm_is_ssh_key", - "ibm_is_subnet", "ibm_is_subnet_public_gateway_attachment", "ibm_is_subnet_reserved_ip", - "ibm_is_virtual_endpoint_gateway", + "ibm_is_subnet", "ibm_is_virtual_endpoint_gateway_ip", + "ibm_is_virtual_endpoint_gateway", "ibm_is_vpc_address_prefix", "ibm_is_vpc_dns_resolution_binding", - "ibm_is_vpc_routing_table", "ibm_is_vpc_routing_table_route", + "ibm_is_vpc_routing_table", "ibm_is_vpn_gateway_connection", + "ibm_is_vpn_server_client", + "ibm_is_vpn_server_route", "ibm_kms_instance_policies", - "ibm_kms_key", "ibm_kms_key_policies", "ibm_kms_key_rings", + "ibm_kms_key", "ibm_pi_capture", - "ibm_pi_cloud_connection", "ibm_pi_cloud_connection_network_attach", + "ibm_pi_cloud_connection", "ibm_pi_console_language", "ibm_pi_dhcp", "ibm_pi_ike_policy", @@ -147,9 +189,9 @@ var FreeResources = []string{ "ibm_pi_instance_action", "ibm_pi_ipsec_policy", "ibm_pi_key", - "ibm_pi_network", - "ibm_pi_network_port", "ibm_pi_network_port_attach", + "ibm_pi_network_port", + "ibm_pi_network", "ibm_pi_placement_group", "ibm_pi_shared_processor_pool", "ibm_pi_spp_placement_group", @@ -166,29 +208,27 @@ var FreeResources = []string{ "ibm_scc_posture_profile_import", "ibm_scc_posture_scan_initiate_validation", "ibm_scc_posture_scope", - "ibm_scc_profile", "ibm_scc_profile_attachment", + "ibm_scc_profile", "ibm_scc_provider_type_instance", - "ibm_scc_rule", "ibm_scc_rule_attachment", - "ibm_scc_template", + "ibm_scc_rule", "ibm_scc_template_attachment", + "ibm_scc_template", "ibm_sm_arbitrary_secret", "ibm_sm_en_registration", "ibm_sm_iam_credentials_configuration", "ibm_sm_imported_certificate", - "ibm_sm_private_certificate", "ibm_sm_private_certificate_configuration_intermediate_ca", "ibm_sm_private_certificate_configuration_root_ca", "ibm_sm_private_certificate_configuration_template", + "ibm_sm_private_certificate", "ibm_sm_public_certificate_configuration_ca_lets_encrypt", "ibm_sm_public_certificate_configuration_dns_cis", "ibm_sm_secret_group", "ibm_sm_service_credentials_secret", "ibm_sm_username_password_secret", "ibm_tg_connection", - "ibm_is_vpn_server_client", - "ibm_is_vpn_server_route", } var UsageOnlyResources = []string{ diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf index 3d96aabb015..cb4afc530a7 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf @@ -328,3 +328,19 @@ resource "ibm_resource_instance" "messagehub_satellite" { location = "satcon_dal" resource_group_id = "default" } + +resource "ibm_resource_instance" "event_notifications_lite" { + name = "event-notifications-lite" + service = "event-notifications" + plan = "lite" + location = "us-south" + resource_group_id = "default" +} + +resource "ibm_resource_instance" "event_notifications_standard" { + name = "event-notifications-standard" + service = "event-notifications" + plan = "standard" + location = "us-south" + resource_group_id = "default" +} From 54cf463a3af0371a594f48a9d22dc418323253f8 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:40:11 -0500 Subject: [PATCH 02/55] Add usage variables to root yml --- infracost-usage-example.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index b63a5753e5a..ce6e7a0b5c0 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -105,6 +105,17 @@ resource_type_default_usage: messagehub_TERABYTE_HOURS: 1 messagehub_qty_terabytes: 1 messagehub_GIGABYTE_TRANSMITTED_OUTBOUNDS: 1 + event-notifications_MILLION_INGESTED_EVENTS: 1 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 + event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 + event-notifications_PUSH_DESTINATION_INSTANCES: 1 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 ibm_tg_gateway: connection: 3 @@ -1388,6 +1399,18 @@ resource_usage: messagehub_qty_terabytes: 1 messagehub_GIGABYTE_TRANSMITTED_OUTBOUNDS: 1 + ibm_resource_instance.event_notifications: + event-notifications_MILLION_INGESTED_EVENTS: 1 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 + event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 + event-notifications_PUSH_DESTINATION_INSTANCES: 1 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 ibm_tg_gateway.tg_gateway: connection: 25 # Monthly number of connections to the gateway From 825844f7ed3da4820695023dc7a126c3e66ffb9f Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:40:35 -0500 Subject: [PATCH 03/55] Fix root usage yml formatting --- infracost-usage-example.yml | 616 ++++++++++++++++++------------------ 1 file changed, 308 insertions(+), 308 deletions(-) diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index ce6e7a0b5c0..8f6f590f621 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -7,11 +7,11 @@ resource_type_default_usage: aws_lambda_function: monthly_requests: 100000 # Monthly requests to the Lambda function. request_duration_ms: 500 # Average duration of each request in milliseconds. - ibm_container_vpc_cluster: + ibm_container_vpc_cluster: monthly_instance_hours: 730 - ibm_container_vpc_worker_pool: + ibm_container_vpc_worker_pool: monthly_instance_hours: 730 - ibm_cos_bucket: + ibm_cos_bucket: accelerated_archive_capacity: 1000 accelerated_archive_restore: 0 archive_capacity: 1000 @@ -23,21 +23,21 @@ resource_type_default_usage: monthly_average_capacity: 1000 monthly_data_retrieval: 1000 public_standard_egress: 1 - ibm_is_flow_log: + ibm_is_flow_log: transmitted_gb: 100 - ibm_is_instance: + ibm_is_instance: monthly_instance_hours: 730 ibm_is_lb: gigabyte_processed: 5 monthly_instance_hours: 730 - ibm_is_volume: + ibm_is_volume: monthly_instance_hours: 730 - ibm_is_vpc: + ibm_is_vpc: gigabyte_transmitted_outbounds: 5 - ibm_is_vpn_gateway: + ibm_is_vpn_gateway: monthly_connection_hours: 730 monthly_instance_hours: 730 - ibm_pi_instance: + ibm_pi_instance: cloud_storage_solution: 0 db2_web_query: 0 epic: 0 @@ -45,9 +45,9 @@ resource_type_default_usage: monthly_instance_hours: 730 rational_dev_studio_licenses: 0 storage: 20 - ibm_pi_volume: + ibm_pi_volume: monthly_instance_hours: 730 - ibm_resource_instance: + ibm_resource_instance: appconnect_gigabyte_transmitted_outbounds: 1 appconnect_thousand_runs: 1 appconnect_vcpu_hours: 730 @@ -97,7 +97,7 @@ resource_type_default_usage: messagehub_CAPACITY_UNIT_HOURS: 1 messagehub_qty_capacity_units: 1 messagehub_CAPACITY_UNIT_HOURS_ADDITIONAL: 1 - messagehub_qty_capacity_units_additional: 1 + messagehub_qty_capacity_units_additional: 1 messagehub_CAPACITY_UNIT_HOURS_MIRRORING: 1 messagehub_qty_capacity_units_mirroring: 1 messagehub_INSTANCE_HOURS: 1 @@ -117,7 +117,7 @@ resource_type_default_usage: event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 - ibm_tg_gateway: + ibm_tg_gateway: connection: 3 data_transfer_global: 1000 data_transfer_local: 1000 @@ -137,13 +137,13 @@ resource_usage: monthly_requests: 20000 # Monthly private certificate requests. aws_api_gateway_rest_api.my_rest_api: - monthly_requests: 100000000 # Monthly requests to the Rest API Gateway. + monthly_requests: 100000000 # Monthly requests to the Rest API Gateway. aws_apigatewayv2_api.my_v2_api: - monthly_requests: 100000000 # Monthly requests to the HTTP API Gateway. - request_size_kb: 512 # Average request size sent to the HTTP API Gateway in KB. Requests are metered in 512KB increments, maximum size is 10MB. - monthly_messages: 1500000000 # Monthly number of messages sent to the Websocket API Gateway. - message_size_kb: 32 # Average size of the messages sent to the Websocket API Gateway in KB. Messages are metered in 32 KB increments, maximum size is 128KB. + monthly_requests: 100000000 # Monthly requests to the HTTP API Gateway. + request_size_kb: 512 # Average request size sent to the HTTP API Gateway in KB. Requests are metered in 512KB increments, maximum size is 10MB. + monthly_messages: 1500000000 # Monthly number of messages sent to the Websocket API Gateway. + message_size_kb: 32 # Average size of the messages sent to the Websocket API Gateway in KB. Messages are metered in 32 KB increments, maximum size is 128KB. monthly_connection_mins: 10000000 # Monthly total connection minutes to Websockets. aws_autoscaling_group.my_asg: @@ -183,16 +183,16 @@ resource_usage: monthly_insight_events: 400000 # Monthly CloudTrail Insight events aws_cloudwatch_event_bus.my_events: - monthly_custom_events: 1000000 # Monthly custom events published. Each 64 KB chunk of payload is billed as 1 event. - monthly_third_party_events: 2000000 # Monthly third-party and cross-account events published. Each 64 KB chunk of payload is billed as 1 event. - monthly_archive_processing_gb: 100 # Monthly archive event processing in GB. - archive_storage_gb: 200 # Archive storage used for event replay in GB. - monthly_schema_discovery_events: 1000000 # Monthly events ingested for schema discovery. Each 8 KB chunk of payload is billed as 1 event. + monthly_custom_events: 1000000 # Monthly custom events published. Each 64 KB chunk of payload is billed as 1 event. + monthly_third_party_events: 2000000 # Monthly third-party and cross-account events published. Each 64 KB chunk of payload is billed as 1 event. + monthly_archive_processing_gb: 100 # Monthly archive event processing in GB. + archive_storage_gb: 200 # Archive storage used for event replay in GB. + monthly_schema_discovery_events: 1000000 # Monthly events ingested for schema discovery. Each 8 KB chunk of payload is billed as 1 event. aws_cloudwatch_log_group.my_log_group: - storage_gb: 1000 # Total data stored by CloudWatch logs in GB. + storage_gb: 1000 # Total data stored by CloudWatch logs in GB. monthly_data_ingested_gb: 1000 # Monthly data ingested by CloudWatch logs in GB. - monthly_data_scanned_gb: 200 # Monthly data scanned by CloudWatch logs insights in GB. + monthly_data_scanned_gb: 200 # Monthly data scanned by CloudWatch logs insights in GB. aws_codebuild_project.my_project: monthly_build_mins: 10000 # Monthly total duration of builds in minutes. Each build is rounded up to the nearest minute. @@ -201,7 +201,7 @@ resource_usage: monthly_rule_evaluations: 1000000 # Monthly config rule evaluations. aws_config_configuration_recorder.my_config: - monthly_config_items: 10000 # Monthly config item records. + monthly_config_items: 10000 # Monthly config item records. monthly_custom_config_items: 20000 # Monthly custom config item records. aws_config_organization_custom_rule.my_config: @@ -211,63 +211,63 @@ resource_usage: monthly_rule_evaluations: 10000 # Monthly config rule evaluations. aws_data_transfer.my_region: - region: us-east-1 # Region the data transfer is originating from. - monthly_intra_region_gb: 1000 # Monthly data transferred between availability zones in the region. Infracost multiplies this by two to account for AWS charging in-bound and out-bound rates. + region: us-east-1 # Region the data transfer is originating from. + monthly_intra_region_gb: 1000 # Monthly data transferred between availability zones in the region. Infracost multiplies this by two to account for AWS charging in-bound and out-bound rates. monthly_outbound_us_east_to_us_east_gb: 500 # Monthly data transferred between US east regions. NOTE: this is only valid if the region is a us-east region. - monthly_outbound_other_regions_gb: 750 # Monthly data transferred to other AWS regions. - monthly_outbound_internet_gb: 5000 # Monthly data transferred to the Internet. + monthly_outbound_other_regions_gb: 750 # Monthly data transferred to other AWS regions. + monthly_outbound_internet_gb: 5000 # Monthly data transferred to the Internet. aws_db_instance.my_db: - additional_backup_storage_gb: 1000 # Amount of backup storage used that is in excess of 100% of the storage size for all databases in GB. + additional_backup_storage_gb: 1000 # Amount of backup storage used that is in excess of 100% of the storage size for all databases in GB. monthly_standard_io_requests: 10000 # Monthly number of input/output requests for database. monthly_additional_performance_insights_requests: 10000 # Monthly Performance Insights API requests above the 1000000 requests included in the free tier. - reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. - reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances, can be: no_upfront (only for 1_year term), partial_upfront, all_upfront. + reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. + reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances, can be: no_upfront (only for 1_year term), partial_upfront, all_upfront. aws_directory_service_directory.my_directory: additional_domain_controllers: 3 # The number of domain controllers in the directory service provisioned in addition to the minimum 2 controllers shared_accounts: 8 # Number of accounts that Microsoft AD directory is shared with aws_docdb_cluster.my_cluster: - backup_storage_gb: 10000 # Amount of backup storage that is in excess of 100% of the storage size for the cluster in GB. + backup_storage_gb: 10000 # Amount of backup storage that is in excess of 100% of the storage size for the cluster in GB. aws_docdb_cluster_instance.my_db: - data_storage_gb: 1000 # Total storage for cluster in GB. + data_storage_gb: 1000 # Total storage for cluster in GB. monthly_io_requests: 100000000 # Monthly number of input/output requests for cluster. monthly_cpu_credit_hrs: 100 # Monthly CPU credits used over the instance baseline in vCPU-hours, only applicable for T3 instances. aws_docdb_cluster_snapshot.my_snapshot: - backup_storage_gb: 10000 # Amount of backup storage that is in excess of 100% of the storage size for the cluster in GB. + backup_storage_gb: 10000 # Amount of backup storage that is in excess of 100% of the storage size for the cluster in GB. aws_dx_connection.my_dx_connection: monthly_outbound_region_to_dx_location_gb: 100 # (DEPRECATED use monthly_outbound_from_region_to_dx_connection_location instead) Monthly outbound data transferred from AWS region to DX location in GB. monthly_outbound_from_region_to_dx_connection_location: us_east_1: 200 # Monthly outbound data transferred to the DX location from us-east-1 in GB eu_west_2: 100 # Monthly outbound data transferred to the DX location from eu-west-2 in GB - dx_virtual_interface_type: private # Interface type impacts outbound data transfer costs over DX, can be: private, public. - dx_connection_type: dedicated # Connection type impacts the per-port hourly price, can be: dedicated, hosted. + dx_virtual_interface_type: private # Interface type impacts outbound data transfer costs over DX, can be: private, public. + dx_connection_type: dedicated # Connection type impacts the per-port hourly price, can be: dedicated, hosted. aws_dx_gateway_association.my_gateway: monthly_data_processed_gb: 100 # Monthly data processed by the DX gateway association per month in GB. aws_dynamodb_table.my_table: - monthly_write_request_units: 3000000 # Monthly write request units in (used for on-demand DynamoDB). - monthly_read_request_units: 8000000 # Monthly read request units in (used for on-demand DynamoDB). - storage_gb: 230 # Total storage for tables in GB. - pitr_backup_storage_gb: 2300 # Total storage for Point-In-Time Recovery (PITR) backups in GB. - on_demand_backup_storage_gb: 460 # Total storage for on-demand backups in GB. - monthly_data_restored_gb: 230 # Monthly size of restored data in GB. + monthly_write_request_units: 3000000 # Monthly write request units in (used for on-demand DynamoDB). + monthly_read_request_units: 8000000 # Monthly read request units in (used for on-demand DynamoDB). + storage_gb: 230 # Total storage for tables in GB. + pitr_backup_storage_gb: 2300 # Total storage for Point-In-Time Recovery (PITR) backups in GB. + on_demand_backup_storage_gb: 460 # Total storage for on-demand backups in GB. + monthly_data_restored_gb: 230 # Monthly size of restored data in GB. monthly_streams_read_request_units: 2 # Monthly streams read request units. aws_ebs_snapshot.my_snapshot: - monthly_list_block_requests: 1000000 # Monthly number of ListChangedBlocks and ListSnapshotBlocks requests. - monthly_get_block_requests: 100000 # Monthly number of GetSnapshotBlock requests (block size is 512KiB). - monthly_put_block_requests: 100000 # Monthly number of PutSnapshotBlock requests (block size is 512KiB). - fast_snapshot_restore_hours: 100 # Monthly number of DSU-hours for Fast snapshot restore + monthly_list_block_requests: 1000000 # Monthly number of ListChangedBlocks and ListSnapshotBlocks requests. + monthly_get_block_requests: 100000 # Monthly number of GetSnapshotBlock requests (block size is 512KiB). + monthly_put_block_requests: 100000 # Monthly number of PutSnapshotBlock requests (block size is 512KiB). + fast_snapshot_restore_hours: 100 # Monthly number of DSU-hours for Fast snapshot restore aws_ebs_volume.my_standard_volume: monthly_standard_io_requests: 10000000 # Monthly I/O requests for standard volume (Magnetic storage). - + aws_ec2_host.my_host: reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances, can be: no_upfront, partial_upfront, all_upfront. @@ -279,9 +279,9 @@ resource_usage: storage_gb: 1 # Total size of ECR repository in GB. aws_efs_file_system.my_file_system: - storage_gb: 230 # Total storage for Standard class in GB. - infrequent_access_storage_gb: 100 # Total storage for Infrequent Access class in GB. - monthly_infrequent_access_read_gb: 50 # Monthly infrequent access read requests in GB. + storage_gb: 230 # Total storage for Standard class in GB. + infrequent_access_storage_gb: 100 # Total storage for Infrequent Access class in GB. + monthly_infrequent_access_read_gb: 50 # Monthly infrequent access read requests in GB. monthly_infrequent_access_write_gb: 100 # Monthly infrequent access write requests in GB. aws_eks_node_group.my_instance: @@ -295,32 +295,32 @@ resource_usage: aws_elastic_beanstalk_environment.my_eb_environment: db: - additional_backup_storage_gb: 1000 # Amount of backup storage used that is in excess of 100% of the storage size for all databases in GB. + additional_backup_storage_gb: 1000 # Amount of backup storage used that is in excess of 100% of the storage size for all databases in GB. monthly_standard_io_requests: 10000 # Monthly number of input/output requests for database. monthly_additional_performance_insights_requests: 10000 # Monthly Performance Insights API requests above the 1000000 requests included in the free tier. ec2: monthly_cpu_credit_hrs: 350 # Number of hours in the month where the instance is expected to burst. Only applicable with t2, t3 & t4 Instance types. T2 requires credit_specification to be unlimited. cloudwatch: - storage_gb: 1000 # Total data stored by CloudWatch logs in GB. + storage_gb: 1000 # Total data stored by CloudWatch logs in GB. monthly_data_ingested_gb: 1000 # Monthly data ingested by CloudWatch logs in GB. - monthly_data_scanned_gb: 200 # Monthly data scanned by CloudWatch logs insights in GB. + monthly_data_scanned_gb: 200 # Monthly data scanned by CloudWatch logs insights in GB. lb: - new_connections: 500000 # Number of newly established connections per second on average. + new_connections: 500000 # Number of newly established connections per second on average. active_connections: 100000 # Number of active connections per minute on average. - processed_bytes_gb: 25000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. - rule_evaluations: 10000 # Number of rule evaluations on application/network load balancers + processed_bytes_gb: 25000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. + rule_evaluations: 10000 # Number of rule evaluations on application/network load balancers elb: monthly_data_processed_gb: 10000 # Monthly data processed on classic loadbalaner - + aws_elasticache_cluster.my_redis_snapshot: snapshot_storage_size_gb: 10000 # Size of Redis snapshots in GB. - reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. - reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances. Can be: no_upfront, partial_upfront, all_upfront for standard offering class. Can be: heavy_utilization, medium_utilization, light utilization for legacy offering class. + reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. + reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances. Can be: no_upfront, partial_upfront, all_upfront for standard offering class. Can be: heavy_utilization, medium_utilization, light utilization for legacy offering class. aws_elasticache_replication_group.my_redis_replication_snapshot: snapshot_storage_size_gb: 10000 # Size of Redis snapshots in GB. - reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. - reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances. Can be: no_upfront, partial_upfront, all_upfront for standard offering class. Can be: heavy_utilization, medium_utilization, light utilization for legacy offering class. + reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. + reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances. Can be: no_upfront, partial_upfront, all_upfront for standard offering class. Can be: heavy_utilization, medium_utilization, light utilization for legacy offering class. aws_elb.my_elb: monthly_data_processed_gb: 10000 # Monthly data processed by a Classic Load Balancer in GB. @@ -346,7 +346,7 @@ resource_usage: india: 7234 # India, Indonesia, Philippines, Thailand aws_glue_catalog_database.my_db: - monthly_objects: 100000 # Monthly number of objects stored above the free one million object storage limit. + monthly_objects: 100000 # Monthly number of objects stored above the free one million object storage limit. monthly_requests: 100000 # Monthly number of requests to the db beyond the free one million requests limit. aws_glue_crawler.my_crawler: @@ -386,30 +386,30 @@ resource_usage: request_duration_ms: 500 # Average duration of each request in milliseconds. aws_alb.my_alb: - new_connections: 10000 # Number of newly established connections per second on average. + new_connections: 10000 # Number of newly established connections per second on average. active_connections: 10000 # Number of active connections per minute on average. - processed_bytes_gb: 1000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. - rule_evaluations: 10000 # The product of number of rules processed by the load balancer and the request rate. + processed_bytes_gb: 1000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. + rule_evaluations: 10000 # The product of number of rules processed by the load balancer and the request rate. aws_lb.my_lb: - new_connections: 10000 # Number of newly established connections per second on average. + new_connections: 10000 # Number of newly established connections per second on average. active_connections: 10000 # Number of active connections per minute on average. - processed_bytes_gb: 1000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. - rule_evaluations: 10000 # The product of number of rules processed by the load balancer and the request rate. + processed_bytes_gb: 1000 # The number of bytes processed by the load balancer for HTTP(S) requests and responses in GB. + rule_evaluations: 10000 # The product of number of rules processed by the load balancer and the request rate. aws_nat_gateway.my_nat_gateway: monthly_data_processed_gb: 10 # Monthly data processed by the NAT Gateway in GB. aws_neptune_cluster.my_cluster: - storage_gb: 100 # Total storage for the cluster in GB. - monthly_io_requests: 10000000 # Monthly number of input/output requests for cluster. - backup_storage_gb: 1000 # Total storage used for backups in GB. + storage_gb: 100 # Total storage for the cluster in GB. + monthly_io_requests: 10000000 # Monthly number of input/output requests for cluster. + backup_storage_gb: 1000 # Total storage used for backups in GB. aws_neptune_cluster_instance.my_cluster_instance: - monthly_cpu_credit_hrs: 10 # Number of hours in a month, where you expect to burst the baseline credit balance of a "t3" instance type. + monthly_cpu_credit_hrs: 10 # Number of hours in a month, where you expect to burst the baseline credit balance of a "t3" instance type. aws_neptune_cluster_snapshot.my_cluster_snapshot: - backup_storage_gb: 1000 # Total storage used for backup snapshots in GB. + backup_storage_gb: 1000 # Total storage used for backup snapshots in GB. aws_networkfirewall_firewall.my_firewall: monthly_data_processed_gb: 100 # Monthly data processed by the Network Firewall in GB. @@ -418,27 +418,27 @@ resource_usage: storage_size_gb: 12 # Data storage per instance in GB. aws_mwaa_environment.my_aws_mwaa_environment: - additional_workers: 2.5 # Average number of monthly additional worker instances - additional_schedulers: 2 # Average number of monthly additional scheduler instances - meta_database_gb: 1000 # Total storage used for meta database + additional_workers: 2.5 # Average number of monthly additional worker instances + additional_schedulers: 2 # Average number of monthly additional scheduler instances + meta_database_gb: 1000 # Total storage used for meta database aws_rds_cluster.my_cluster: - capacity_units_per_hr: 50 # Number of aurora capacity units per hour. Only used when engine_mode is "serverless" - storage_gb: 200 # Storage amount in GB allocated to the aurora cluster. - write_requests_per_sec: 100 # Total number of reads per second for the cluster. - read_requests_per_sec: 100 # Total number of writes per second for the cluster. - backup_snapshot_size_gb: 200 # Individual storage size for backup snapshots, used in conjunction with resource parameter "backup_retention_period". - average_statements_per_hr: 10000 # Number of statements generated per hour when backtrack is enabled. Only available for MySQl-compatible Aurora + capacity_units_per_hr: 50 # Number of aurora capacity units per hour. Only used when engine_mode is "serverless" + storage_gb: 200 # Storage amount in GB allocated to the aurora cluster. + write_requests_per_sec: 100 # Total number of reads per second for the cluster. + read_requests_per_sec: 100 # Total number of writes per second for the cluster. + backup_snapshot_size_gb: 200 # Individual storage size for backup snapshots, used in conjunction with resource parameter "backup_retention_period". + average_statements_per_hr: 10000 # Number of statements generated per hour when backtrack is enabled. Only available for MySQl-compatible Aurora change_records_per_statement: 0.38 # Records changed per statement executed. - backtrack_window_hrs: 24 # The duration window for which Aurora will support rewinding the DB cluster to a specific point in time. - snapshot_export_size_gb: 200 # Size of snapshot that's exported to s3 in parquet format. + backtrack_window_hrs: 24 # The duration window for which Aurora will support rewinding the DB cluster to a specific point in time. + snapshot_export_size_gb: 200 # Size of snapshot that's exported to s3 in parquet format. aws_rds_cluster_instance.my_cluster: - monthly_cpu_credit_hrs: 24 # Number of hours in a month, where you expect to burst the baseline credit balance of a "t3" instance type. + monthly_cpu_credit_hrs: 24 # Number of hours in a month, where you expect to burst the baseline credit balance of a "t3" instance type. vcpu_count: 2 # # (DEPRECATED this is now calculated automatically) Number of virtual CPUs allocated to your "t3" instance type. Currently instances with 2 vCPUs are available. monthly_additional_performance_insights_requests: 10000 # Monthly Performance Insights API requests above the 1000000 requests included in the free tier. - reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. - reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances, can be: no_upfront (only for 1_year term), partial_upfront, all_upfront. + reserved_instance_term: 1_year # Term for Reserved Instances, can be: 1_year, 3_year. + reserved_instance_payment_option: partial_upfront # Payment option for Reserved Instances, can be: no_upfront (only for 1_year term), partial_upfront, all_upfront. aws_redshift_cluster.with_usage: managed_storage_gb: 10000 @@ -450,9 +450,9 @@ resource_usage: endpoint_type: aws # Type of health check endpoint to query, can be: aws, non_aws. aws_route53_record.my_record: - monthly_standard_queries: 1100000000 # Monthly number of Standard queries. + monthly_standard_queries: 1100000000 # Monthly number of Standard queries. monthly_latency_based_queries: 1200000000 # Monthly number of Latency Based Routing queries. - monthly_geo_queries: 1500000000 # Monthly number of Geo DNS and Geoproximity queries. + monthly_geo_queries: 1500000000 # Monthly number of Geo DNS and Geoproximity queries. aws_route53_resolver_endpoint.my_endpoint: monthly_queries: 20000000000 # Monthly number of DNS queries processed through the endpoints. @@ -466,63 +466,63 @@ resource_usage: aws_s3_bucket_lifecycle_configuration.my_bucket_lifecycle_config: object_tags: 10000000 # Total object tags. standard: # Usages of S3 Standard: - storage_gb: 10000 # Total storage in GB. - monthly_tier_1_requests: 1000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 100000 # Monthly GET, SELECT, and all other requests (Tier 2). + storage_gb: 10000 # Total storage in GB. + monthly_tier_1_requests: 1000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 100000 # Monthly GET, SELECT, and all other requests (Tier 2). monthly_select_data_scanned_gb: 10000 # Monthly data scanned by S3 Select in GB. monthly_select_data_returned_gb: 1000 # Monthly data returned by S3 Select in GB. intelligent_tiering: # Usages of S3 Intelligent - Tiering: - frequent_access_storage_gb: 20000 # Total storage for Frequent Access Tier in GB. - infrequent_access_storage_gb: 20000 # Total storage for Infrequent Access Tier in GB. - monitored_objects: 2000 # Total objects monitored by the Intelligent Tiering. - monthly_tier_1_requests: 2000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 200000 # Monthly GET, SELECT, and all other requests (Tier 2). + frequent_access_storage_gb: 20000 # Total storage for Frequent Access Tier in GB. + infrequent_access_storage_gb: 20000 # Total storage for Infrequent Access Tier in GB. + monitored_objects: 2000 # Total objects monitored by the Intelligent Tiering. + monthly_tier_1_requests: 2000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 200000 # Monthly GET, SELECT, and all other requests (Tier 2). monthly_lifecycle_transition_requests: 200000 # Monthly Lifecycle Transition requests. - monthly_select_data_scanned_gb: 20000 # Monthly data scanned by S3 Select in GB. - monthly_select_data_returned_gb: 2000 # Monthly data returned by S3 Select in GB. - early_delete_gb: 200000 # If an archive is deleted within 1 months of being uploaded, you will be charged an early deletion fee per GB. + monthly_select_data_scanned_gb: 20000 # Monthly data scanned by S3 Select in GB. + monthly_select_data_returned_gb: 2000 # Monthly data returned by S3 Select in GB. + early_delete_gb: 200000 # If an archive is deleted within 1 months of being uploaded, you will be charged an early deletion fee per GB. standard_infrequent_access: # Usages of S3 Standard - Infrequent Access: - storage_gb: 30000 # Total storage in GB. - monthly_tier_1_requests: 3000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 300000 # Monthly GET, SELECT, and all other requests (Tier 2). + storage_gb: 30000 # Total storage in GB. + monthly_tier_1_requests: 3000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 300000 # Monthly GET, SELECT, and all other requests (Tier 2). monthly_lifecycle_transition_requests: 300000 # Monthly Lifecycle Transition requests. - monthly_data_retrieval_gb: 30000 # Monthly data retrievals in GB - monthly_select_data_scanned_gb: 30000 # Monthly data scanned by S3 Select in GB. - monthly_select_data_returned_gb: 3000 # Monthly data returned by S3 Select in GB. + monthly_data_retrieval_gb: 30000 # Monthly data retrievals in GB + monthly_select_data_scanned_gb: 30000 # Monthly data scanned by S3 Select in GB. + monthly_select_data_returned_gb: 3000 # Monthly data returned by S3 Select in GB. one_zone_infrequent_access: # Usages of S3 One Zone - Infrequent Access: - storage_gb: 40000 # Total storage in GB. - monthly_tier_1_requests: 4000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 400000 # Monthly GET, SELECT, and all other requests (Tier 2). + storage_gb: 40000 # Total storage in GB. + monthly_tier_1_requests: 4000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 400000 # Monthly GET, SELECT, and all other requests (Tier 2). monthly_lifecycle_transition_requests: 400000 # Monthly Lifecycle Transition requests. - monthly_data_retrieval_gb: 40000 # Monthly data retrievals in GB - monthly_select_data_scanned_gb: 40000 # Monthly data scanned by S3 Select in GB. - monthly_select_data_returned_gb: 4000 # Monthly data returned by S3 Select in GB. + monthly_data_retrieval_gb: 40000 # Monthly data retrievals in GB + monthly_select_data_scanned_gb: 40000 # Monthly data scanned by S3 Select in GB. + monthly_select_data_returned_gb: 4000 # Monthly data returned by S3 Select in GB. glacier_flexible_retrieval: # Usages of S3 Glacier Flexible Retrieval: - storage_gb: 50000 # Total storage in GB. - monthly_tier_1_requests: 5000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 500000 # Monthly GET, SELECT, and all other requests (Tier 2). - monthly_lifecycle_transition_requests: 500000 # Monthly Lifecycle Transition requests. - monthly_standard_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for standard level of S3 Glacier). - monthly_standard_select_data_returned_gb: 500000 # Monthly data returned by S3 Select in GB (for standard level of S3 Glacier). - monthly_bulk_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for bulk level of S3 Glacier) - monthly_bulk_select_data_returned_gb: 500000 # Monthly data returned by S3 Select in GB (for bulk level of S3 Glacier) - monthly_expedited_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for expedited level of S3 Glacier) + storage_gb: 50000 # Total storage in GB. + monthly_tier_1_requests: 5000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 500000 # Monthly GET, SELECT, and all other requests (Tier 2). + monthly_lifecycle_transition_requests: 500000 # Monthly Lifecycle Transition requests. + monthly_standard_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for standard level of S3 Glacier). + monthly_standard_select_data_returned_gb: 500000 # Monthly data returned by S3 Select in GB (for standard level of S3 Glacier). + monthly_bulk_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for bulk level of S3 Glacier) + monthly_bulk_select_data_returned_gb: 500000 # Monthly data returned by S3 Select in GB (for bulk level of S3 Glacier) + monthly_expedited_select_data_scanned_gb: 500000 # Monthly data scanned by S3 Select in GB (for expedited level of S3 Glacier) monthly_expedited_select_data_returned_gb: 500000 # Monthly data returned by S3 Select in GB (for expedited level of S3 Glacier) - monthly_standard_data_retrieval_requests: 500000 # Monthly data Retrieval requests (for standard level of S3 Glacier). + monthly_standard_data_retrieval_requests: 500000 # Monthly data Retrieval requests (for standard level of S3 Glacier). monthly_expedited_data_retrieval_requests: 500000 # Monthly data Retrieval requests (for expedited level of S3 Glacier). - monthly_standard_data_retrieval_gb: 5000 # Monthly data retrievals in GB (for standard level of S3 Glacier). - monthly_expedited_data_retrieval_gb: 5000 # Monthly data retrievals in GB (for expedited level of S3 Glacier). - early_delete_gb: 500000 # If an archive is deleted within 3 months of being uploaded, you will be charged an early deletion fee per GB. + monthly_standard_data_retrieval_gb: 5000 # Monthly data retrievals in GB (for standard level of S3 Glacier). + monthly_expedited_data_retrieval_gb: 5000 # Monthly data retrievals in GB (for expedited level of S3 Glacier). + early_delete_gb: 500000 # If an archive is deleted within 3 months of being uploaded, you will be charged an early deletion fee per GB. glacier_deep_archive: # Usages of S3 Glacier Deep Archive: - storage_gb: 60000 # Total storage in GB. - monthly_tier_1_requests: 6000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). - monthly_tier_2_requests: 600000 # Monthly GET, SELECT, and all other requests (Tier 2). - monthly_lifecycle_transition_requests: 600000 # Monthly Lifecycle Transition requests. + storage_gb: 60000 # Total storage in GB. + monthly_tier_1_requests: 6000000 # Monthly PUT, COPY, POST, LIST requests (Tier 1). + monthly_tier_2_requests: 600000 # Monthly GET, SELECT, and all other requests (Tier 2). + monthly_lifecycle_transition_requests: 600000 # Monthly Lifecycle Transition requests. monthly_standard_data_retrieval_requests: 600000 # Monthly data Retrieval requests (for standard level of S3 Glacier). - monthly_bulk_data_retrieval_requests: 600000 # Monthly data Retrieval requests (for bulk level of S3 Glacier). - monthly_standard_data_retrieval_gb: 6000 # Monthly data retrievals in GB (for standard level of S3 Glacier). - monthly_bulk_data_retrieval_gb: 6000 # Monthly data retrievals in GB (for bulk level of S3 Glacier). - early_delete_gb: 600000 # If an archive is deleted within 6 months of being uploaded, you will be charged an early deletion fee per GB. + monthly_bulk_data_retrieval_requests: 600000 # Monthly data Retrieval requests (for bulk level of S3 Glacier). + monthly_standard_data_retrieval_gb: 6000 # Monthly data retrievals in GB (for standard level of S3 Glacier). + monthly_bulk_data_retrieval_gb: 6000 # Monthly data retrievals in GB (for bulk level of S3 Glacier). + early_delete_gb: 600000 # If an archive is deleted within 6 months of being uploaded, you will be charged an early deletion fee per GB. aws_s3_bucket.my_bucket: object_tags: 10000000 # Total object tags. Only for AWS provider V3. @@ -601,20 +601,20 @@ resource_usage: aws_sns_topic_subscription.my_topic_subscription: monthly_requests: 1000000 # (DEPRECATED use aws_sns_topic.monthly_requests instead) Monthly requests to SNS. - request_size_kb: 64 # (DEPRECATED use aws_sns_topic.request_size_kb instead) Size of requests to SNS, billed in 64KB chunks. So 1M requests at 128KB uses 2M requests. + request_size_kb: 64 # (DEPRECATED use aws_sns_topic.request_size_kb instead) Size of requests to SNS, billed in 64KB chunks. So 1M requests at 128KB uses 2M requests. aws_sqs_queue.my_queue: monthly_requests: 1000000 # Monthly requests to SQS. - request_size_kb: 64 # Size of requests to SQS, billed in 64KB chunks. So 1M requests at 128KB uses 2M requests. + request_size_kb: 64 # Size of requests to SQS, billed in 64KB chunks. So 1M requests at 128KB uses 2M requests. aws_ssm_parameter.my_ssm_parameter: - api_throughput_limit: standard # SSM Parameter Throughput limit, can be: standard, advanced, higher. + api_throughput_limit: standard # SSM Parameter Throughput limit, can be: standard, advanced, higher. monthly_api_interactions: 1000000 # Monthly API interactions. - parameter_storage_hrs: 730 # Number of hours in the month parameters will be stored for. + parameter_storage_hrs: 730 # Number of hours in the month parameters will be stored for. aws_ssm_activation.my_activations: instance_tier: standard # Instance tier being used, can be: standard, advanced. - instances: 100 # Number of instances being managed. + instances: 100 # Number of instances being managed. aws_transfer_server.my_transfer_server: monthly_data_downloaded_gb: 50 # Monthly data downloaded over enabled protocols in GB. @@ -628,59 +628,59 @@ resource_usage: aws_cloudfront_distribution.my_s3_distribution: monthly_data_transfer_to_internet_gb: # Monthly regional data transfer out to internet from the following, in GB: - us: 51200000 # United States, Mexico, Canada - europe: 220000 # Europe, Israel - south_africa: 10000 # South Africa, Kenya, Middle East - south_america: 50000 # South America - japan: 387000 # Japan - australia: 500000 # Australia, New Zealand + us: 51200000 # United States, Mexico, Canada + europe: 220000 # Europe, Israel + south_africa: 10000 # South Africa, Kenya, Middle East + south_america: 50000 # South America + japan: 387000 # Japan + australia: 500000 # Australia, New Zealand asia_pacific: 1200000 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand - india: 200000 # India + india: 200000 # India monthly_data_transfer_to_origin_gb: # Monthly regional data transfer out to origin from the following, in GB: - us: 2200 # United States, Mexico, Canada - europe: 1000 # Europe, Israel - south_africa: 300 # South Africa, Kenya, Middle East + us: 2200 # United States, Mexico, Canada + europe: 1000 # Europe, Israel + south_africa: 300 # South Africa, Kenya, Middle East south_america: 200 # South America - japan: 10 # Japan - australia: 100 # Australia, New Zealand - asia_pacific: 30 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand - india: 80 # India + japan: 10 # Japan + australia: 100 # Australia, New Zealand + asia_pacific: 30 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand + india: 80 # India monthly_http_requests: # Monthly number of HTTP requests to: - us: 80000 # United States, Mexico, Canada - europe: 40000 # Europe, Israel - south_africa: 20000 # South Africa, Kenya, Middle East + us: 80000 # United States, Mexico, Canada + europe: 40000 # Europe, Israel + south_africa: 20000 # South Africa, Kenya, Middle East south_america: 10000 # South America - japan: 3000 # Japan - australia: 15000 # Australia, New Zealand - asia_pacific: 45000 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand - india: 10000 # India + japan: 3000 # Japan + australia: 15000 # Australia, New Zealand + asia_pacific: 45000 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand + india: 10000 # India monthly_https_requests: # Monthly number of HTTPS requests to: - us: 180000 # United States, Mexico, Canada - europe: 10000 # Europe, Israel - south_africa: 50000 # South Africa, Kenya, Middle East + us: 180000 # United States, Mexico, Canada + europe: 10000 # Europe, Israel + south_africa: 50000 # South Africa, Kenya, Middle East south_america: 30000 # South America - japan: 1000 # Japan - australia: 45000 # Australia, New Zealand - asia_pacific: 25000 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand - india: 30000 # India + japan: 1000 # Japan + australia: 45000 # Australia, New Zealand + asia_pacific: 25000 # Hong Kong, Philippines, Singapore, South Korea, Taiwan, Thailand + india: 30000 # India monthly_shield_requests: # Monthly number of shield requests to: - us: 90000 # United States - europe: 30000 # Europe + us: 90000 # United States + europe: 30000 # Europe south_america: 200 # South America - japan: 12300 # Japan - australia: 2300 # Australia - singapore: 58600 # Singapore + japan: 12300 # Japan + australia: 2300 # Australia + singapore: 58600 # Singapore south_korea: 24000 # South Korea - india: 10000 # India + india: 10000 # India monthly_invalidation_requests: 1200 # Monthly number of invalidation requests. monthly_encryption_requests: 100000 # Monthly number of field level encryption requests. - monthly_log_lines: 5000000 # Monthly number of real-time log lines. - custom_ssl_certificates: 3 # Number of dedicated IP custom SSL certificates. + monthly_log_lines: 5000000 # Monthly number of real-time log lines. + custom_ssl_certificates: 3 # Number of dedicated IP custom SSL certificates. aws_sfn_state_machine.my_sfn_state_machine: monthly_transitions: 1000 # Monthly number of state transitions. Only applicable for Standard Workflows. - monthly_requests: 10000 # Monthly number of workflow requests. Only applicable for Express Workflows. - memory_mb: 128 # Average amount of memory consumed by workflow in MB. Only applicable for Express Workflows. + monthly_requests: 10000 # Monthly number of workflow requests. Only applicable for Express Workflows. + memory_mb: 128 # Average amount of memory consumed by workflow in MB. Only applicable for Express Workflows. workflow_duration_ms: 500 # Average duration of workflow in milliseconds. Only applicable for Express Workflows. aws_waf_web_acl.my_waf: @@ -688,7 +688,7 @@ resource_usage: monthly_requests: 1000000 # Monthly number of web requests received. aws_wafv2_web_acl.my_waf2: - rule_group_rules: 5 # Total number of Rule Group rules used by the Web ACL. + rule_group_rules: 5 # Total number of Rule Group rules used by the Web ACL. managed_rule_group_rules: 10 # Total number of Managed Rule Group rules used by the Web ACL. monthly_requests: 1000000 # Monthly number of web requests received. @@ -705,69 +705,69 @@ resource_usage: monthly_queries_tb: 100 # Monthly number of bytes processed (also referred to as bytes read) in TB. google_bigquery_table.usage: - monthly_active_storage_gb: 1000 # Monthly number of active storage modifications in GB. + monthly_active_storage_gb: 1000 # Monthly number of active storage modifications in GB. monthly_long_term_storage_gb: 1000 # Monthly number of long-term storage modifications in GB. monthly_streaming_inserts_mb: 1000 # Monthly number of streaming data inserts in MB. monthly_storage_write_api_gb: 1000 # Monthly number of storage write api in GB. - monthly_storage_read_api_tb: 1000 # Monthly number of storage read api in TB. + monthly_storage_read_api_tb: 1000 # Monthly number of storage read api in TB. google_cloudfunctions_function.my_function: - request_duration_ms: 300 # Average duration of each request in milliseconds. + request_duration_ms: 300 # Average duration of each request in milliseconds. monthly_function_invocations: 10000000 # Monthly number of function invocations. - monthly_outbound_data_gb: 100 # Monthly data transferred from the function out to somewhere else in GB. + monthly_outbound_data_gb: 100 # Monthly data transferred from the function out to somewhere else in GB. google_compute_router_nat.my_nat: - assigned_vms: 4 # Number of VM instances assigned to the NAT gateway + assigned_vms: 4 # Number of VM instances assigned to the NAT gateway monthly_data_processed_gb: 1000 # Monthly data processed (ingress and egress) by the NAT gateway in GB google_container_cluster.my_cluster: - autopilot_vcpu_count: 10 # Number of vCPUs used by Autopilot pods. Only relevant for Autopilot mode. - autopilot_memory_gb: 50 # Total memory used by Autopilot pods. Only relevant for Autopilot mode. + autopilot_vcpu_count: 10 # Number of vCPUs used by Autopilot pods. Only relevant for Autopilot mode. + autopilot_memory_gb: 50 # Total memory used by Autopilot pods. Only relevant for Autopilot mode. autopilot_ephemeral_storage_gb: 100 # Total ephemeral storage used by Autopilot pods. Only relevant for Autopilot mode. - nodes: 4 # Node count per zone for the default node pool. Only relevant for Standard mode. + nodes: 4 # Node count per zone for the default node pool. Only relevant for Standard mode. node_pool[0]: - nodes: 2 # Node count per zone for the first node pool. Only relevant for Standard mode. + nodes: 2 # Node count per zone for the first node pool. Only relevant for Standard mode. google_container_node_pool.my_node_pool: nodes: 4 # Node count per zone for the node pool google_container_registry.my_registry: - storage_gb: 150 # Total size of bucket in GB. + storage_gb: 150 # Total size of bucket in GB. monthly_class_a_operations: 40000 # Monthly number of class A operations (object adds, bucket/object list). monthly_class_b_operations: 20000 # Monthly number of class B operations (object gets, retrieve bucket/object metadata). - monthly_data_retrieval_gb: 500 # Monthly amount of data retrieved in GB. - monthly_egress_data_transfer_gb: # Monthly data transfer from Cloud Storage to the following, in GB: - same_continent: 550 # Same continent. - worldwide: 12500 # Worldwide excluding Asia, Australia. - asia: 1500 # Asia excluding China, but including Hong Kong. - china: 50 # China excluding Hong Kong. - australia: 250 # Australia. + monthly_data_retrieval_gb: 500 # Monthly amount of data retrieved in GB. + monthly_egress_data_transfer_gb: # Monthly data transfer from Cloud Storage to the following, in GB: + same_continent: 550 # Same continent. + worldwide: 12500 # Worldwide excluding Asia, Australia. + asia: 1500 # Asia excluding China, but including Hong Kong. + china: 50 # China excluding Hong Kong. + australia: 250 # Australia. google_compute_external_vpn_gateway.my_compute_external_vpn_gateway: - monthly_egress_data_transfer_gb: # Monthly data transfer from VPN gateway to the following, in GB: - worldwide: 12500 # Worldwide excluding China, Australia but including Hong Kong. - china: 8500 # China excluding Hong Kong. - australia: 250 # Australia. + monthly_egress_data_transfer_gb: # Monthly data transfer from VPN gateway to the following, in GB: + worldwide: 12500 # Worldwide excluding China, Australia but including Hong Kong. + china: 8500 # China excluding Hong Kong. + australia: 250 # Australia. google_compute_vpn_gateway.my_compute_vpn_gateway: - monthly_egress_data_transfer_gb: # Monthly VM-VM data transfer from VPN gateway to the following, in GB: - same_region: 250 # VMs in the same Google Cloud region. - us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. - europe: 70 # Between Google Cloud regions within Europe. - asia: 50 # Between Google Cloud regions within Asia. - south_america: 100 # Between Google Cloud regions within South America. - oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. - worldwide: 200 # to a Google Cloud region on another continent. + monthly_egress_data_transfer_gb: # Monthly VM-VM data transfer from VPN gateway to the following, in GB: + same_region: 250 # VMs in the same Google Cloud region. + us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. + europe: 70 # Between Google Cloud regions within Europe. + asia: 50 # Between Google Cloud regions within Asia. + south_america: 100 # Between Google Cloud regions within South America. + oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. + worldwide: 200 # to a Google Cloud region on another continent. google_compute_ha_vpn_gateway.my_compute_ha_vpn_gateway: - monthly_egress_data_transfer_gb: # Monthly VM-VM data transfer from VPN gateway to the following, in GB: - same_region: 250 # VMs in the same Google Cloud region. - us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. - europe: 70 # Between Google Cloud regions within Europe. - asia: 50 # Between Google Cloud regions within Asia. - south_america: 100 # Between Google Cloud regions within South America. - oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. - worldwide: 200 # to a Google Cloud region on another continent. + monthly_egress_data_transfer_gb: # Monthly VM-VM data transfer from VPN gateway to the following, in GB: + same_region: 250 # VMs in the same Google Cloud region. + us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. + europe: 70 # Between Google Cloud regions within Europe. + asia: 50 # Between Google Cloud regions within Asia. + south_america: 100 # Between Google Cloud regions within South America. + oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. + worldwide: 200 # to a Google Cloud region on another continent. google_compute_forwarding_rule.my_forwarding: monthly_ingress_data_gb: 100 @@ -816,51 +816,51 @@ resource_usage: monthly_data_processed_gb: 100 google_dns_record_set.my_record_set: - monthly_queries: 1000000 # Monthly DNS queries. + monthly_queries: 1000000 # Monthly DNS queries. google_kms_crypto_key.my_keys: - key_versions: 10000 # Number of key versions. + key_versions: 10000 # Number of key versions. monthly_key_operations: 1000000 # Monthly number of key operations. google_logging_billing_account_bucket_config.my_config: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_billing_account_sink.my_sink: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_folder_bucket_config.my_config: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_folder_sink.my_sink: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_organization_bucket_config.my.config: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_organization_sink.my_sink: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_project_bucket_config.my_config: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_logging_project_sink.my_sink: - monthly_logging_data_gb: 100 # Monthly logging data in GB. + monthly_logging_data_gb: 100 # Monthly logging data in GB. google_monitoring_metric_descriptor.my_monitoring: monthly_monitoring_data_mb: 5000 # Monthly monitoring data in MB (only for chargeable metrics). - monthly_api_calls: 1000000 # Monthly read API calls (write calls are free). + monthly_api_calls: 1000000 # Monthly read API calls (write calls are free). google_pubsub_subscription.my_subscription: monthly_message_data_tb: 7.416 # Monthly amount of message data pulled by the subscription in TB. - storage_gb: 605 # Storage for retaining acknowledged messages in GB. - snapshot_storage_gb: 70.6 # Snapshot storage for unacknowledged messages in GB. + storage_gb: 605 # Storage for retaining acknowledged messages in GB. + snapshot_storage_gb: 70.6 # Snapshot storage for unacknowledged messages in GB. google_pubsub_topic.my_topic: monthly_message_data_tb: 7.416 # Monthly amount of message data published to the topic in TB. google_secret_manager_secret.my_secret: - active_secret_versions: 10000 # Number of active secret versions in each month. NOTE: this is used only when secret versions are not defined. - monthly_access_operations: 20000 # Monthly number of access operations + active_secret_versions: 10000 # Number of active secret versions in each month. NOTE: this is used only when secret versions are not defined. + monthly_access_operations: 20000 # Monthly number of access operations monthly_rotation_notifications: 100 # Monthly number of rotation notifications google_secret_manager_secret_version.my_secret_version: @@ -868,28 +868,28 @@ resource_usage: google_service_networking_connection.my_connection: monthly_egress_data_transfer_gb: # Monthly VM-VM data transfer from VPN gateway to the following, in GB: - same_region: 250 # VMs in the same Google Cloud region. - us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. - europe: 70 # Between Google Cloud regions within Europe. - asia: 50 # Between Google Cloud regions within Asia. - south_america: 100 # Between Google Cloud regions within South America. - oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. - worldwide: 200 # to a Google Cloud region on another continent. + same_region: 250 # VMs in the same Google Cloud region. + us_or_canada: 100 # From a Google Cloud region in the US or Canada to another Google Cloud region in the US or Canada. + europe: 70 # Between Google Cloud regions within Europe. + asia: 50 # Between Google Cloud regions within Asia. + south_america: 100 # Between Google Cloud regions within South America. + oceania: 50 # Indonesia and Oceania to/from any Google Cloud region. + worldwide: 200 # to a Google Cloud region on another continent. google_sql_database_instance.my_instance: backup_storage_gb: 1000 # Amount of backup storage in GB. google_storage_bucket.my_storage_bucket: - storage_gb: 150 # Total size of bucket in GB. + storage_gb: 150 # Total size of bucket in GB. monthly_class_a_operations: 40000 # Monthly number of class A operations (object adds, bucket/object list). monthly_class_b_operations: 20000 # Monthly number of class B operations (object gets, retrieve bucket/object metadata). - monthly_data_retrieval_gb: 500 # Monthly amount of data retrieved in GB. - monthly_egress_data_transfer_gb: # Monthly data transfer from Cloud Storage to the following, in GB: - same_continent: 550 # Same continent. - worldwide: 12500 # Worldwide excluding Asia, Australia. - asia: 1500 # Asia excluding China, but including Hong Kong. - china: 50 # China excluding Hong Kong. - australia: 250 # Australia. + monthly_data_retrieval_gb: 500 # Monthly amount of data retrieved in GB. + monthly_egress_data_transfer_gb: # Monthly data transfer from Cloud Storage to the following, in GB: + same_continent: 550 # Same continent. + worldwide: 12500 # Worldwide excluding Asia, Australia. + asia: 1500 # Asia excluding China, but including Hong Kong. + china: 50 # China excluding Hong Kong. + australia: 250 # Australia. # # Terraform AzureRM resources @@ -899,7 +899,7 @@ resource_usage: self_hosted_gateway_count: 5 # Number of self-hosted gateways (only for premium tier). azurerm_app_service_environment.my_service: - operating_system: linux # Override the operating system of the instance, can be: linux, windows. + operating_system: linux # Override the operating system of the instance, can be: linux, windows. azurerm_application_insights.my_insights: monthly_data_ingested_gb: 1000 # Monthly amount of data ingested in GB. @@ -917,7 +917,7 @@ resource_usage: azurerm_application_gateway.my_gateway: monthly_data_processed_gb: 100000 # Monthly data processed by the Application Gateway in GB. - monthly_v2_capacity_units: 10000 # Number capacity(for v2) units gateway. + monthly_v2_capacity_units: 10000 # Number capacity(for v2) units gateway. azurerm_automation_job_schedule.my_schedule: monthly_job_run_mins: 0 # Monthly number of job run minutes. @@ -933,8 +933,8 @@ resource_usage: azurerm_function_app.my_functions: monthly_executions: 100000 # Monthly executions to the function. Only applicable for Consumption plan. execution_duration_ms: 500 # Average duration of each execution in milliseconds. Only applicable for Consumption plan. - memory_mb: 128 # Average amount of memory consumed by function in MB. Only applicable for Consumption plan. - instances: 1 # Number of instances. Only applicable for Premium plan. + memory_mb: 128 # Average amount of memory consumed by function in MB. Only applicable for Consumption plan. + instances: 1 # Number of instances. Only applicable for Premium plan. azurerm_cdn_endpoint.my_endpoint: monthly_outbound_gb: 1000000 # Monthly number of outbound data transfers in GB. @@ -1014,7 +1014,7 @@ resource_usage: azurerm_data_factory.my_data_factory: monthly_read_write_operation_entities: 100000 # Monthly entities for Read/Write operations. - monthly_monitoring_operation_entities: 25000 # Monthly entities for Monitoring operations. + monthly_monitoring_operation_entities: 25000 # Monthly entities for Monitoring operations. azurerm_data_factory_integration_runtime_azure.my_runtime: monthly_orchestration_runs: 10000 # Monthly Orchestration runs for runtime. @@ -1026,56 +1026,56 @@ resource_usage: monthly_orchestration_runs: 10000 # Monthly Orchestration runs for runtime. azurerm_dns_a_record.my_a_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_aaaa_record.my_aaaa_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_caa_record.my_caa_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_cname_record.my_cname_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_mx_record.my_mx_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_ns_record.my_ns_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_ptr_record.my_ptr_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_srv_record.my_srv_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_dns_txt_record.my_txt_record: - monthly_queries: 11500000000 # Monthly number of DNS queries + monthly_queries: 11500000000 # Monthly number of DNS queries azurerm_eventhub_namespace.my_event_hub: monthly_ingress_events: 100000000 # Monthly number of ingress events, only applicable for Basic and Standard namespaces. - retention_storage_gb: 10000 # Total data stored for retention in GB, used to calculate Extended Retention costs, only applicable for Dedicated namespaces. - throughput_or_capacity_units: 10 # Number of Throughput Units (for Basic and Standard) and Capacity units (for Dedicated) namespaces. - capture_enabled: false # Defines if capture is enabled for the Event Hub Standard namespaces, can be: true, false. + retention_storage_gb: 10000 # Total data stored for retention in GB, used to calculate Extended Retention costs, only applicable for Dedicated namespaces. + throughput_or_capacity_units: 10 # Number of Throughput Units (for Basic and Standard) and Capacity units (for Dedicated) namespaces. + capture_enabled: false # Defines if capture is enabled for the Event Hub Standard namespaces, can be: true, false. azurerm_frontdoor.my_frontdoor: monthly_outbound_data_transfer_gb: # Monthly outbound data transfer from the following, in GB: - us_gov: 190000 # US Gov - north_america_europe_africa: 200000 # North America, Europe and Africa - asia_pacific: 220000 # Asia Pacific (including Japan) - south_america: 10000 # South America - australia: 50000 # Australia - india: 387000 # India + us_gov: 190000 # US Gov + north_america_europe_africa: 200000 # North America, Europe and Africa + asia_pacific: 220000 # Asia Pacific (including Japan) + south_america: 10000 # South America + australia: 50000 # Australia + india: 387000 # India monthly_inbound_data_transfer_gb: 1000 # Monthly inbound data transfer in GB azurerm_log_analytics_workspace.my_workspace: - monthly_log_data_ingestion_gb: 20 # Monthly log data ingested by the workspace in GB (only used for Pay-as-you-go workspaces). + monthly_log_data_ingestion_gb: 20 # Monthly log data ingested by the workspace in GB (only used for Pay-as-you-go workspaces). monthly_additional_log_data_retention_gb: 30 # Monthly additional GB of data retained past the free allowance. - monthly_log_data_export_gb: 40 # Monthly data in GB exported from the workspace. - monthly_sentinel_data_ingestion_gb: 40 # Monthly data in GB exported from Microsoft Sentinel, this only applies when it is enabled. + monthly_log_data_export_gb: 40 # Monthly data in GB exported from the workspace. + monthly_sentinel_data_ingestion_gb: 40 # Monthly data in GB exported from Microsoft Sentinel, this only applies when it is enabled. azurerm_frontdoor_firewall_policy.my_frontdoor_firewall_policy: - monthly_custom_rule_requests: 11000 # Monthly number of custom rule requests + monthly_custom_rule_requests: 11000 # Monthly number of custom rule requests monthly_managed_ruleset_requests: 10000 # Monthly number of managed ruleset requests azurerm_kubernetes_cluster.my_cluster: @@ -1107,14 +1107,14 @@ resource_usage: monthly_disk_operations: 2000000 # Number of disk operations (writes, reads, deletes) using a unit size of 256KiB. azurerm_key_vault_certificate.my_certificate: - monthly_certificate_renewal_requests: 100 # Monthly number of certificate renewal requests. + monthly_certificate_renewal_requests: 100 # Monthly number of certificate renewal requests. monthly_certificate_other_operations: 100000 # Monthly number of non-renewal certificate operations. azurerm_key_vault_key.my_keys: - monthly_secrets_operations: 10000 # Monthly number of secrets transactions. - monthly_key_rotation_renewals: 50 # Monthly number of Managed Azure Storage account key rotation renewals. + monthly_secrets_operations: 10000 # Monthly number of secrets transactions. + monthly_key_rotation_renewals: 50 # Monthly number of Managed Azure Storage account key rotation renewals. monthly_protected_keys_operations: 1000000 # Monthly number of Software or HSM transactions. - hsm_protected_keys: 3000 # Number of protected keys. + hsm_protected_keys: 3000 # Number of protected keys. azurerm_linux_virtual_machine_scale_set.standard_f2: instances: 10 # Override the number of instances in the scale set. @@ -1131,9 +1131,9 @@ resource_usage: additional_backup_storage_gb: 2000 # Additional consumption of backup storage in GB. azurerm_mssql_database.my_database: - monthly_vcore_hours: 600 # Monthly number of used vCore-hours for serverless compute. + monthly_vcore_hours: 600 # Monthly number of used vCore-hours for serverless compute. long_term_retention_storage_gb: 1000 # Number of GBs used by long-term retention backup storage. - extra_data_storage_gb: 250 # Override number of GBs used by extra data storage. + extra_data_storage_gb: 250 # Override number of GBs used by extra data storage. azurerm_mysql_flexible_server.my_flexible_server: additional_backup_storage_gb: 5000 # Additional backup storage in GB. If geo-redundancy is enabled, you should set this to twice the required storage capacity. @@ -1157,25 +1157,25 @@ resource_usage: additional_backup_storage_gb: 3000 # Additional consumption of backup storage in GB. azurerm_private_dns_a_record.my_a_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_aaaa_record.my_aaaa_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_cname_record.my_cname_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_mx_record.my_mx_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_ptr_record.my_ptr_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_srv_record.my_srv_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_dns_txt_record.my_txt_record: - monthly_queries: 1500000000 # Monthly number of DNS queries + monthly_queries: 1500000000 # Monthly number of DNS queries azurerm_private_endpoint.with_inbound: monthly_inbound_data_processed_gb: 100 # Monthly inbound data processed in GB. @@ -1185,28 +1185,28 @@ resource_usage: monthly_images_extracted: 1000000 # Monthly number of extracted images azurerm_storage_account.my_account: - data_at_rest_storage_gb: 10000 # Total size of Data at Rest in GB (File storage). - early_deletion_gb: 1000 # Total size of Early deletion data in GB. - snapshots_storage_gb: 10000 # Total size of Snapshots in GB (File storage). - metadata_at_rest_storage_gb: 10000 # Total size of Metadata in GB (File storage). - storage_gb: 1000000 # Total size of storage in GB. - monthly_iterative_write_operations: 170000 # Monthly number of Iterative write operations (GPv2). - monthly_write_operations: 1000000 # Monthly number of Write operations. + data_at_rest_storage_gb: 10000 # Total size of Data at Rest in GB (File storage). + early_deletion_gb: 1000 # Total size of Early deletion data in GB. + snapshots_storage_gb: 10000 # Total size of Snapshots in GB (File storage). + metadata_at_rest_storage_gb: 10000 # Total size of Metadata in GB (File storage). + storage_gb: 1000000 # Total size of storage in GB. + monthly_iterative_write_operations: 170000 # Monthly number of Iterative write operations (GPv2). + monthly_write_operations: 1000000 # Monthly number of Write operations. monthly_list_and_create_container_operations: 1000000 # Monthly number of List and Create Container operations. - monthly_iterative_read_operations: 150000 # Monthly number of Iterative read operations (GPv2). - monthly_read_operations: 100000 # Monthly number of Read operations. - monthly_other_operations: 1000000 # Monthly number of All other operations. - monthly_data_retrieval_gb: 1000 # Monthly number of data retrieval in GB. - monthly_data_write_gb: 1000 # Monthly number of data write in GB. - blob_index_tags: 100000 # Total number of Blob indexes. + monthly_iterative_read_operations: 150000 # Monthly number of Iterative read operations (GPv2). + monthly_read_operations: 100000 # Monthly number of Read operations. + monthly_other_operations: 1000000 # Monthly number of All other operations. + monthly_data_retrieval_gb: 1000 # Monthly number of data retrieval in GB. + monthly_data_write_gb: 1000 # Monthly number of data write in GB. + blob_index_tags: 100000 # Total number of Blob indexes. azurerm_sql_database.my_database: - monthly_vcore_hours: 600 # Monthly number of used vCore-hours for serverless compute. + monthly_vcore_hours: 600 # Monthly number of used vCore-hours for serverless compute. long_term_retention_storage_gb: 1000 # Number of GBs used by long-term retention backup storage. - extra_data_storage_gb: 250 # Override number of GBs used by extra data storage. - + extra_data_storage_gb: 250 # Override number of GBs used by extra data storage. + azurerm_sql_managed_instance.my_database: - backup_storage_gb: 100 # Backup storage size dedicated for Point In Time Restoration + backup_storage_gb: 100 # Backup storage size dedicated for Point In Time Restoration long_term_retention_storage_gb: 5 # Number of GBs used by long-term retention backup storage. azurerm_synapse_spark_pool.my_spark_pool: @@ -1312,7 +1312,7 @@ resource_usage: ibm_is_lb.lb: monthly_instance_hours: 730 # Monthly number of hours an instance runs - gigabyte_processed: 1000 # Monthly gigabytes of data processed by the load balancer + gigabyte_processed: 1000 # Monthly gigabytes of data processed by the load balancer ibm_is_instance.is_instance: monthly_instance_hours: 730 # Monthly number of hours an instance runs @@ -1339,7 +1339,7 @@ resource_usage: ibm_pi_volume.pi_volume: monthly_instance_hours: 730 # Monthly number of instance hours - ibm_resource_instance.resource_instance_kms: + ibm_resource_instance.resource_instance_kms: kms_key_versions: 6 # Number of key versions managed per month secretsmanager_active_secrets: 1 # Number of active secrets secretsmanager_instance: 1 # Number of instances of secrets manager @@ -1351,7 +1351,7 @@ resource_usage: appconnect_vcpu_hours: 10 # The number of VCPU hours used in a month logdna_gigabyte_months: 10 # The amount of logs in a month in GB activitytracker_gigabyte_months: 10 # The amount of logs in a month in GB - sysdig-monitor_NODE_HOURS: 700 # The amount of hours monitoring runs on a host in a month + sysdig-monitor_NODE_HOURS: 700 # The amount of hours monitoring runs on a host in a month sysdig-monitor_CONTAINER_HOURS: 700 # Additional containers on a host above the base 50 sysdig-monitor_API_CALL_HOURS: 1000 # Additional API calls above the base 1M/instance sysdig-monitor_TIME_SERIES_HOURS: 1000 # Additional time-series cost above the base 1000/host @@ -1385,7 +1385,7 @@ resource_usage: dns-svcs_qty_custom_resolver_locations: 1 # Number of resolver locations dns-svcs_qty_glb_instances: 1 # Number of GLBs dns-svcs_qty_pools: 1 # Number of pools - + ibm_resource_instance.event_streams: messagehub_CAPACITY_UNIT_HOURS: 1 messagehub_qty_capacity_units: 1 @@ -1419,7 +1419,7 @@ resource_usage: ibm_is_share.nfs: is-share_monthly_instance_hours: 730 # Monthly number of instance hours - is-share_monthly_transmitted_gb: 1 # Data transmitted between two file shares for replication + is-share_monthly_transmitted_gb: 1 # Data transmitted between two file shares for replication ibm_is_vpc_server: is.vpn-server_CONNECTION_HOURS: 730 From aa845e0876dc085d41f802d92dc7183dedf280de Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:41:04 -0500 Subject: [PATCH 04/55] Add event-notifications to Global Catalog & sort --- internal/providers/terraform/ibm/ibm.go | 57 +++++++++++++------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/internal/providers/terraform/ibm/ibm.go b/internal/providers/terraform/ibm/ibm.go index f546e3a16c5..8be81bfd820 100644 --- a/internal/providers/terraform/ibm/ibm.go +++ b/internal/providers/terraform/ibm/ibm.go @@ -51,45 +51,46 @@ type catalogMetadata struct { // Map between terraform type and global catalog id. For ibm_resource_instance, the service // field already matches the global catalog id, so they do not need to be mapped. eg: "kms" var globalCatalogServiceId = map[string]catalogMetadata{ - "ibm_is_vpc": {"is.vpc", []string{"ibm_is_flow_log", "ibm_is_share"}, nil, "https://cloud.ibm.com/vpc-ext/provision/vpc"}, + "aiopenscale": {"2ad019f3-0fd6-4c25-966d-f3952481a870", []string{}, nil, "https://cloud.ibm.com/catalog/services/watsonxgovernance"}, + "appconnect": {"96a0ebf2-2a02-4e32-815f-7c09a1268c78", []string{}, nil, "https://www.ibm.com/products/app-connect/pricing"}, + "appid": {"AdvancedMobileAccess-d6aece47-d840-45b0-8ab9-ad15354deeea", []string{}, nil, "https://cloud.ibm.com/catalog/services/appid"}, + "cloud-object-storage": {"dff97f5c-bc5e-4455-b470-411c3edbe49c", []string{}, nil, "https://cloud.ibm.com/objectstorage/create#pricing"}, + "compliance": {"compliance", []string{}, nil, "https://cloud.ibm.com/catalog/services/security-and-compliance-center"}, + "continuous-delivery": {"59b735ee-5938-4ebd-a6b2-541aef2d1f68", []string{}, nil, "https://cloud.ibm.com/catalog/services/continuous-delivery"}, + "conversation": {"7045626d-55e3-4418-be11-683a26dbc1e5", []string{}, nil, "https://cloud.ibm.com/catalog/services/watsonx-assistant"}, + "data-science-experience": {"39ba9d4c-b1c5-4cc3-a163-38b580121e01", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-studio"}, + "databases-for-elasticsearch": {"databases-for-elasticsearch", []string{}, nil, "https://cloud.ibm.com/databases/databases-for-elasticsearch/create"}, + "databases-for-postgresql": {"databases-for-postgresql", []string{}, nil, "https://cloud.ibm.com/databases/databases-for-postgresql/create"}, + "discovery": {"76b7bf22-b443-47db-b3db-066ba2988f47", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-discovery"}, + "dns-svcs": {"b4ed8a30-936f-11e9-b289-1d079699cbe5", []string{}, nil, "https://cloud.ibm.com/catalog/services/dns-services"}, + "event-notifications": {"ecdb4690-c2d8-11eb-bff1-4f7b9d2dfe41", []string{}, nil, "https://cloud.ibm.com/catalog/services/event-notifications"}, + "ibm_cloudant": {"Cloudant", []string{}, nil, "https://cloud.ibm.com/catalog/services/cloudant"}, "ibm_container_vpc_cluster": {"containers-kubernetes", []string{}, nil, "https://cloud.ibm.com/kubernetes/catalog/about#pricing"}, "ibm_container_vpc_worker_pool": {"containers-kubernetes", []string{}, nil, "https://cloud.ibm.com/kubernetes/catalog/about#pricing"}, + "ibm_cos_bucket": {"Object Storage Bucket", []string{}, nil, "https://cloud.ibm.com/objectstorage/create#pricing"}, + "ibm_is_floating_ip": {"is.floating-ip", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/vs"}, + "ibm_is_flow_log": {"is.flow-log-collector", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/flowLog"}, "ibm_is_instance": {"is.instance", []string{"ibm_is_ssh_key", "ibm_is_floating_ip"}, nil, "https://cloud.ibm.com/vpc-ext/provision/vs"}, + "ibm_is_lb": {"is.load-balancer", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/loadBalancer"}, + "ibm_is_share": {"is.share", []string{}, nil, "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-vpc-faqs&interface=ui#faq-fs-billing"}, "ibm_is_volume": {"is.volume", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/storage"}, + "ibm_is_vpc": {"is.vpc", []string{"ibm_is_flow_log", "ibm_is_share"}, nil, "https://cloud.ibm.com/vpc-ext/provision/vpc"}, "ibm_is_vpn_gateway": {"is.vpn", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/vpngateway"}, - "ibm_tg_gateway": {"f38a4da0-c353-11e9-83b6-a36a57a97a06", []string{}, nil, "https://cloud.ibm.com/interconnectivity/transit/provision"}, - "ibm_is_floating_ip": {"is.floating-ip", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/vs"}, - "ibm_is_flow_log": {"is.flow-log-collector", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/flowLog"}, - "ibm_cloudant": {"Cloudant", []string{}, nil, "https://cloud.ibm.com/catalog/services/cloudant"}, + "ibm_is_vpn_server": {"is.vpn-server", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/vpnserver"}, "ibm_pi_instance": {"Power Systems Virtual Server", []string{}, nil, "https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-pricing-virtual-server"}, "ibm_pi_volume": {"Power Systems Storage Volume", []string{}, nil, "https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-pricing-virtual-server#storage-type"}, - "ibm_cos_bucket": {"Object Storage Bucket", []string{}, nil, "https://cloud.ibm.com/objectstorage/create#pricing"}, - "ibm_is_lb": {"is.load-balancer", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/loadBalancer"}, + "ibm_tg_gateway": {"f38a4da0-c353-11e9-83b6-a36a57a97a06", []string{}, nil, "https://cloud.ibm.com/interconnectivity/transit/provision"}, "kms": {"ee41347f-b18e-4ca6-bf80-b5467c63f9a6", []string{}, nil, "https://cloud.ibm.com/catalog/services/key-protect"}, - "cloud-object-storage": {"dff97f5c-bc5e-4455-b470-411c3edbe49c", []string{}, nil, "https://cloud.ibm.com/objectstorage/create#pricing"}, - "roks": {"containers.kubernetes.cluster.roks", []string{}, nil, "https://cloud.ibm.com/kubernetes/catalog/about?platformType=openshift"}, - "pm-20": {"51c53b72-918f-4869-b834-2d99eb28422a", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-machine-learning"}, - "data-science-experience": {"39ba9d4c-b1c5-4cc3-a163-38b580121e01", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-studio"}, - "discovery": {"76b7bf22-b443-47db-b3db-066ba2988f47", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-discovery"}, - "wx": {"51c53b72-918f-4869-b834-2d99eb28422a", []string{}, nil, "https://cloud.ibm.com/watsonx/overview"}, - "conversation": {"7045626d-55e3-4418-be11-683a26dbc1e5", []string{}, nil, "https://cloud.ibm.com/catalog/services/watsonx-assistant"}, - "aiopenscale": {"2ad019f3-0fd6-4c25-966d-f3952481a870", []string{}, nil, "https://cloud.ibm.com/catalog/services/watsonxgovernance"}, - "sysdig-monitor": {"090c2c10-8c38-11e8-bec2-493df9c49eb8", []string{}, nil, "https://cloud.ibm.com/observe/catalog/ibm-cloud-monitoring"}, - "sysdig-secure": {"e831e900-82d6-11ec-95c5-c12c5a5d9687", []string{}, nil, "https://cloud.ibm.com/workload-protection/catalog/security-and-compliance-center-workload-protection"}, "logdna": {"e13e1860-959c-11e8-871e-ad157af61ad7", []string{}, nil, "https://cloud.ibm.com/catalog/services/logdna"}, - "databases-for-postgresql": {"databases-for-postgresql", []string{}, nil, "https://cloud.ibm.com/databases/databases-for-postgresql/create"}, - "databases-for-elasticsearch": {"databases-for-elasticsearch", []string{}, nil, "https://cloud.ibm.com/databases/databases-for-elasticsearch/create"}, - "secrets-manager": {"ebc0cdb0-af2a-11ea-98c7-29e5db822649", []string{}, nil, "https://cloud.ibm.com/catalog/services/secrets-manager"}, - "appid": {"AdvancedMobileAccess-d6aece47-d840-45b0-8ab9-ad15354deeea", []string{}, nil, "https://cloud.ibm.com/catalog/services/appid"}, - "appconnect": {"96a0ebf2-2a02-4e32-815f-7c09a1268c78", []string{}, nil, "https://www.ibm.com/products/app-connect/pricing"}, - "power-iaas": {"abd259f0-9990-11e8-acc8-b9f54a8f1661", []string{}, nil, "https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-pricing-virtual-server"}, "logdnaat": {"dcc46a60-e13b-11e8-a015-757410dab16b", []string{}, nil, "https://cloud.ibm.com/catalog/services/logdnaat"}, - "continuous-delivery": {"59b735ee-5938-4ebd-a6b2-541aef2d1f68", []string{}, nil, "https://cloud.ibm.com/catalog/services/continuous-delivery"}, - "compliance": {"compliance", []string{}, nil, "https://cloud.ibm.com/catalog/services/security-and-compliance-center"}, - "dns-svcs": {"b4ed8a30-936f-11e9-b289-1d079699cbe5", []string{}, nil, "https://cloud.ibm.com/catalog/services/dns-services"}, "messagehub": {"6a7f4e38-f218-48ef-9dd2-df408747568e", []string{}, nil, "https://cloud.ibm.com/eventstreams-provisioning/6a7f4e38-f218-48ef-9dd2-df408747568e/create"}, - "ibm_is_share": {"is.share", []string{}, nil, "https://cloud.ibm.com/docs/vpc?topic=vpc-file-storage-vpc-faqs&interface=ui#faq-fs-billing"}, - "ibm_is_vpn_server": {"is.vpn-server", []string{}, nil, "https://cloud.ibm.com/vpc-ext/provision/vpnserver"}, + "pm-20": {"51c53b72-918f-4869-b834-2d99eb28422a", []string{}, nil, "https://cloud.ibm.com/catalog/services/watson-machine-learning"}, + "power-iaas": {"abd259f0-9990-11e8-acc8-b9f54a8f1661", []string{}, nil, "https://cloud.ibm.com/docs/power-iaas?topic=power-iaas-pricing-virtual-server"}, + "roks": {"containers.kubernetes.cluster.roks", []string{}, nil, "https://cloud.ibm.com/kubernetes/catalog/about?platformType=openshift"}, + "secrets-manager": {"ebc0cdb0-af2a-11ea-98c7-29e5db822649", []string{}, nil, "https://cloud.ibm.com/catalog/services/secrets-manager"}, + "sysdig-monitor": {"090c2c10-8c38-11e8-bec2-493df9c49eb8", []string{}, nil, "https://cloud.ibm.com/observe/catalog/ibm-cloud-monitoring"}, + "sysdig-secure": {"e831e900-82d6-11ec-95c5-c12c5a5d9687", []string{}, nil, "https://cloud.ibm.com/workload-protection/catalog/security-and-compliance-center-workload-protection"}, + "wx": {"51c53b72-918f-4869-b834-2d99eb28422a", []string{}, nil, "https://cloud.ibm.com/watsonx/overview"}, } func SetCatalogMetadata(d *schema.ResourceData, resourceType string, config map[string]any) { From b755aaaad7b3477a3e17e9f95b1377882f0422af Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:41:43 -0500 Subject: [PATCH 05/55] Add event-notifications under resource_instance & sort lists, where applicable --- internal/resources/ibm/resource_instance.go | 48 +++++++++++++++------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 87676fdbb8f..a74fef5c9d3 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -108,6 +108,18 @@ type ResourceInstance struct { EventStreams_Instances *float64 `infracost_usage:"messagehub_qty_instances"` EventStreams_TerabyteHours *float64 `infracost_usage:"messagehub_TERABYTE_HOURS"` EventStreams_Terabytes *float64 `infracost_usage:"messagehub_qty_terabytes"` + // Event Notifications + EventNotifications_InboundIngestedEvents *int64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` + EventNotifications_OutboundCustomDomainEmailGBsTransmitted *int64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` + EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` + EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` + EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` + EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` + EventNotifications_PreProdPushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES"` + EventNotifications_PushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_DESTINATION_INSTANCES"` + EventNotifications_ResourceUnitsMonthly *int64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` + EventNotifications_ResourceUnitsSetup *int64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -177,27 +189,39 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "messagehub_qty_instances", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_TERABYTE_HOURS", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_qty_terabytes", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 1, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ - "kms": GetKMSCostComponents, - "secrets-manager": GetSecretsManagerCostComponents, - "appid": GetAppIDCostComponents, + "aiopenscale": GetWGOVCostComponents, "appconnect": GetAppConnectCostComponents, - "power-iaas": GetPowerCostComponents, - "logdna": GetLogDNACostComponents, - "logdnaat": GetActivityTrackerCostComponents, - "sysdig-monitor": GetSysdigCostComponenets, + "appid": GetAppIDCostComponents, + "compliance": GetSCCCostComponents, "continuous-delivery": GetContinuousDeliveryCostComponenets, - "pm-20": GetWMLCostComponents, "conversation": GetWACostComponents, - "discovery": GetWDCostComponents, - "compliance": GetSCCCostComponents, "data-science-experience": GetWSCostComponents, - "sysdig-secure": GetSCCWPCostComponents, - "aiopenscale": GetWGOVCostComponents, + "discovery": GetWDCostComponents, "dns-svcs": GetDNSServicesCostComponents, + "event-notifications": GetEventNotificationsCostComponents, + "kms": GetKMSCostComponents, + "logdna": GetLogDNACostComponents, + "logdnaat": GetActivityTrackerCostComponents, "messagehub": GetEventStreamsCostComponents, + "pm-20": GetWMLCostComponents, + "power-iaas": GetPowerCostComponents, + "secrets-manager": GetSecretsManagerCostComponents, + "sysdig-monitor": GetSysdigCostComponenets, + "sysdig-secure": GetSCCWPCostComponents, } func KMSKeyVersionsFreeCostComponent(r *ResourceInstance) *schema.CostComponent { From 2ea13623da8c6886604141e85b21d1604ce465c1 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:42:49 -0500 Subject: [PATCH 06/55] Add event-notifications unit test usage --- .../resource_instance_test.usage.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml index 0d207b793a2..93da04b33ec 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml @@ -143,4 +143,17 @@ resource_usage: messagehub_CAPACITY_UNIT_HOURS: 1 messagehub_qty_capacity_units: 1 messagehub_CAPACITY_UNIT_HOURS_ADDITIONAL: 1 - messagehub_qty_capacity_units_additional: 1 + messagehub_qty_capacity_units_additional: 1 + + ibm_resource_instance.event_notifications: + event-notifications_MILLION_INGESTED_EVENTS: 1 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1 + event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 1 + event-notifications_PUSH_DESTINATION_INSTANCES: 1 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 From 74ff730159448eec48885091337a3ffa57bdf5a0 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:43:21 -0500 Subject: [PATCH 07/55] Fix unit test usage yml formatting --- .../resource_instance_test/resource_instance_test.usage.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml index 93da04b33ec..b7f618b9631 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml @@ -114,7 +114,7 @@ resource_usage: messagehub_CAPACITY_UNIT_HOURS: 1 messagehub_qty_capacity_units: 1 messagehub_CAPACITY_UNIT_HOURS_ADDITIONAL: 1 - messagehub_qty_capacity_units_additional: 1 + messagehub_qty_capacity_units_additional: 1 messagehub_CAPACITY_UNIT_HOURS_MIRRORING: 1 messagehub_qty_capacity_units_mirroring: 1 messagehub_INSTANCE_HOURS: 1 @@ -127,12 +127,12 @@ resource_usage: messagehub_INSTANCE_HOURS: 100 messagehub_qty_instances: 1 messagehub_GIGABYTE_TRANSMITTED_OUTBOUNDS: 100 - + ibm_resource_instance.messagehub_enterprise: messagehub_CAPACITY_UNIT_HOURS: 1 messagehub_qty_capacity_units: 1 messagehub_CAPACITY_UNIT_HOURS_ADDITIONAL: 1 - messagehub_qty_capacity_units_additional: 1 + messagehub_qty_capacity_units_additional: 1 messagehub_CAPACITY_UNIT_HOURS_MIRRORING: 1 messagehub_qty_capacity_units_mirroring: 1 messagehub_TERABYTE_HOURS: 10 From fbee9c9927ce62c3417d4497e9ac9afd5b6fab12 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 16:45:16 -0500 Subject: [PATCH 08/55] Add Terraform unit tests for Event Notifications Plans: Lite, Standard --- .../resource_instance_test.tf | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf index cb4afc530a7..bc93fb8f41a 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf @@ -329,18 +329,16 @@ resource "ibm_resource_instance" "messagehub_satellite" { resource_group_id = "default" } -resource "ibm_resource_instance" "event_notifications_lite" { - name = "event-notifications-lite" - service = "event-notifications" - plan = "lite" - location = "us-south" - resource_group_id = "default" +locals { + event_notifications = { + plans : ["lite", "standard"] + } } - -resource "ibm_resource_instance" "event_notifications_standard" { - name = "event-notifications-standard" - service = "event-notifications" - plan = "standard" +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" location = "us-south" + plan = each.value resource_group_id = "default" + service = "event-notifications" } From cc394dd78f104370d99dccee9325b0f4775121af Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Fri, 22 Nov 2024 17:15:47 -0500 Subject: [PATCH 09/55] Change some usage from int to float --- internal/resources/ibm/resource_instance.go | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index a74fef5c9d3..0a3714a268b 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -109,17 +109,17 @@ type ResourceInstance struct { EventStreams_TerabyteHours *float64 `infracost_usage:"messagehub_TERABYTE_HOURS"` EventStreams_Terabytes *float64 `infracost_usage:"messagehub_qty_terabytes"` // Event Notifications - EventNotifications_InboundIngestedEvents *int64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` - EventNotifications_OutboundCustomDomainEmailGBsTransmitted *int64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` - EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` - EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` - EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` - EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` - EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` - EventNotifications_PreProdPushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES"` - EventNotifications_PushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_DESTINATION_INSTANCES"` - EventNotifications_ResourceUnitsMonthly *int64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` - EventNotifications_ResourceUnitsSetup *int64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` + EventNotifications_InboundIngestedEvents *float64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` + EventNotifications_OutboundCustomDomainEmailGBsTransmitted *float64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` + EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` + EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` + EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` + EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` + EventNotifications_PreProdPushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES"` + EventNotifications_PushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_DESTINATION_INSTANCES"` + EventNotifications_ResourceUnitsMonthly *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` + EventNotifications_ResourceUnitsSetup *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -191,13 +191,13 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "messagehub_qty_terabytes", DefaultValue: 1, ValueType: schema.Float64}, {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 1, ValueType: schema.Float64}, {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Int64}, + {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Int64}, {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 1, ValueType: schema.Float64}, {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 1, ValueType: schema.Float64}, } From 7d286df18cd04f1c3d03a1f0a314ef722b702e7a Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sat, 23 Nov 2024 15:25:39 -0500 Subject: [PATCH 10/55] Set DefaultValue property to 0 --- internal/resources/ibm/resource_instance.go | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 0a3714a268b..18816c07f53 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -189,17 +189,17 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "messagehub_qty_instances", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_TERABYTE_HOURS", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_qty_terabytes", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 1, ValueType: schema.Int64}, - {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 1, ValueType: schema.Float64}, - {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 1, ValueType: schema.Float64}, + {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ From 0e955970d53730723bb0a49a4b69a121825acfd4 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sat, 23 Nov 2024 16:29:18 -0500 Subject: [PATCH 11/55] Add no-usage Terraform unit test --- .../resource_instance_test/resource_instance_test.tf | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf index bc93fb8f41a..3c91f28f23d 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.tf @@ -342,3 +342,11 @@ resource "ibm_resource_instance" "event_notifications" { resource_group_id = "default" service = "event-notifications" } + +resource "ibm_resource_instance" "event_notifications_no_usage" { + name = "event-notifications-standard-no-usage" + location = "us-south" + plan = "standard" + resource_group_id = "default" + service = "event-notifications" +} From f05db535224f398878d7ecba607b57df2f79816d Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sat, 23 Nov 2024 16:29:42 -0500 Subject: [PATCH 12/55] Set test usage to the minimum to show in results --- .../resource_instance_test.usage.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml index b7f618b9631..63c180b168c 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml @@ -145,14 +145,14 @@ resource_usage: messagehub_CAPACITY_UNIT_HOURS_ADDITIONAL: 1 messagehub_qty_capacity_units_additional: 1 - ibm_resource_instance.event_notifications: + ibm_resource_instance.event_notifications[*]: event-notifications_MILLION_INGESTED_EVENTS: 1 event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 100000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 101 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 1 event-notifications_PUSH_DESTINATION_INSTANCES: 1 event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 From 5ee9a75949759a537bee064b9ce5b79d73f9eeb7 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sat, 23 Nov 2024 16:30:18 -0500 Subject: [PATCH 13/55] Updated golden file to include Event Notifications --- .../resource_instance_test.golden | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden index d92343b38f2..a08e44ef70f 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden @@ -18,6 +18,37 @@ └─ Additional Million DNS Queries (first 999 Million Queries) 999 Million Queries $645.16 └─ Additional Million DNS Queries (over 999 Million Queries) 1 Million Queries $0.32 + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 $0.00 + + ibm_resource_instance.event_notifications["standard"] + ├─ Ingested Events 1 Million Events $1.08 + ├─ Outbound Custom Domain E-mail GB Transmitted 1 GB $0.12 + ├─ Outbound Custom Domain E-mails 1,000 E-mails $0.15 + ├─ Outbound E-mails 100,000 E-mails $4.31 + ├─ Outbound HTTP Messages 1,000,000 Messages $1.08 + ├─ Outbound Push Messages (first 100 Messages) 100 Messages $0.00 + ├─ Outbound Push Messages (over 100 Messages) 1 Messages $0.00 + ├─ Outbound SMS Messages 1,000 Messages $16.15 + ├─ Pre-Prod Push Destination Instances 1 Instances $10.00 + ├─ Push Destination Instances 1 Instances $35.00 + ├─ SMS Number Monthly Resource Units 1 Resource Units $1.00 + └─ SMS Number Setup Resource Units 1 Resource Units $1.00 + + ibm_resource_instance.event_notifications_no_usage + ├─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + ├─ Outbound Custom Domain E-mail GB Transmitted Monthly cost depends on usage: $0.12 per GB + ├─ Outbound Custom Domain E-mails Monthly cost depends on usage: $0.00015 per E-mails + ├─ Outbound E-mails Monthly cost depends on usage: $0.0000431 per E-mails + ├─ Outbound HTTP Messages Monthly cost depends on usage: $0.00000108 per Messages + ├─ Outbound Push Messages (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + ├─ Outbound Push Messages (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + ├─ Outbound SMS Messages Monthly cost depends on usage: $0.01615 per Messages + ├─ Pre-Prod Push Destination Instances Monthly cost depends on usage: $10.00 per Instances + ├─ Push Destination Instances Monthly cost depends on usage: $35.00 per Instances + ├─ SMS Number Monthly Resource Units Monthly cost depends on usage: $1.00 per Resource Units + └─ SMS Number Setup Resource Units Monthly cost depends on usage: $1.00 per Resource Units + ibm_resource_instance.messagehub_enterprise ├─ Base Capacity Unit-Hour 1 Hours $7.37 ├─ Additional Capacity Unit-Hour 1 Hours $7.37 @@ -197,7 +228,7 @@ ├─ Class 2 Resource Units 50 RU $0.09 └─ Class 3 Resource Units 50 RU $0.25 - OVERALL TOTAL $19,305.11 + OVERALL TOTAL $19,375.00 ────────────────────────────────── -41 cloud resources were detected: -∙ 41 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file +44 cloud resources were detected: +∙ 44 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file From b673401fbdf0ba52e21b9255322bf4f698fdbdda Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sat, 23 Nov 2024 16:32:23 -0500 Subject: [PATCH 14/55] Add all Cost Components --- .../resource_instance_event-notifications.go | 370 ++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 internal/resources/ibm/resource_instance_event-notifications.go diff --git a/internal/resources/ibm/resource_instance_event-notifications.go b/internal/resources/ibm/resource_instance_event-notifications.go new file mode 100644 index 00000000000..a77ae439cf9 --- /dev/null +++ b/internal/resources/ibm/resource_instance_event-notifications.go @@ -0,0 +1,370 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +const EVENT_NOTIFICATIONS_LITE_PLAN_PROGRAMMATIC_NAME = "lite" +const EVENT_NOTIFICATIONS_STANDARD_PLAN_PROGRAMMATIC_NAME = "standard" + +func GetEventNotificationsCostComponents(r *ResourceInstance) []*schema.CostComponent { + if r.Plan == EVENT_NOTIFICATIONS_LITE_PLAN_PROGRAMMATIC_NAME { + costComponent := schema.CostComponent{ + Name: "Lite Plan", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + return []*schema.CostComponent{ + &costComponent, + } + } else if r.Plan == EVENT_NOTIFICATIONS_STANDARD_PLAN_PROGRAMMATIC_NAME { + return []*schema.CostComponent{ + EventNotificationsInboundIngestedEventsCostComponent(r), + EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r), + EventNotificationsOutboundCustomDomainEmailsCostComponent(r), + EventNotificationsOutboundEmailsCostComponent(r), + EventNotificationsOutboundHTTPMessagesCostComponent(r), + EventNotificationsOutboundPushMessagesCostComponent(r), + EventNotificationsOutboundSMSMessagesCostComponent(r), + EventNotificationsPreProdPushDestinationInstancesCostComponent(r), + EventNotificationsPushDestinationInstancesCostComponent(r), + EventNotificationsResourceUnitsMonthlyCostComponent(r), + EventNotificationsResourceUnitsSetupCostComponent(r), + } + } else { + costComponent := schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), // Final quantity for this cost component will be divided by this amount + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + return []*schema.CostComponent{ + &costComponent, + } + } +} + +func EventNotificationsInboundIngestedEventsCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_InboundIngestedEvents != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_InboundIngestedEvents)) + } + + costComponent := schema.CostComponent{ + Name: "Ingested Events", // Short descriptive name of the component. + Unit: "Million Events", // Unit of resource component's measurement. For example, it can be hours or 10M requests. + UnitMultiplier: decimal.NewFromInt(1), // Used to calculate the cost of component quantity correctly. For example, if a price is $0.02 per 1k requests, and assuming the amount is 10,000, its cost will be calculated as quantity/unitMultiplier * price. + MonthlyQuantity: quantity, // HourlyQuantity or MonthlyQuantity attributes specify the quantity of the resource. If the measurement unit is GB, it will be the number of gigabytes. If the unit is hours, it can be 1 as "1 hour" + ProductFilter: &schema.ProductFilter{ // Helps identify the exact price of the "product." Usually, it's only one, but if there are pricing tiers, its filters can pick the correct value. + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("MILLION_INGESTED_EVENTS"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound Custom Domain E-mail GB Transmitted", + Unit: "GB", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundCustomDomainEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundCustomDomainEmails != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundCustomDomainEmails)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound Custom Domain E-mails", + Unit: "E-mails", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundEmails != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundEmails)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound E-mails", + Unit: "E-mails", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_EMAILS"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundHTTPMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundHTTPMessages)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound HTTP Messages", + Unit: "Messages", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundPushMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundPushMessages)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound Push Messages", + Unit: "Messages", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + return &costComponent +} + +func EventNotificationsOutboundSMSMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_OutboundSMSMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundSMSMessages)) + } + + costComponent := schema.CostComponent{ + Name: "Outbound SMS Messages", + Unit: "Messages", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"), + }, + } + return &costComponent +} + +func EventNotificationsPreProdPushDestinationInstancesCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_PreProdPushDestinationInstances != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_PreProdPushDestinationInstances)) + } + + costComponent := schema.CostComponent{ + Name: "Pre-Prod Push Destination Instances", + Unit: "Instances", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("PUSH_PREPROD_DESTINATION_INSTANCES"), + }, + } + return &costComponent +} + +func EventNotificationsPushDestinationInstancesCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_PushDestinationInstances != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_PushDestinationInstances)) + } + + costComponent := schema.CostComponent{ + Name: "Push Destination Instances", + Unit: "Instances", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("PUSH_DESTINATION_INSTANCES"), + }, + } + return &costComponent +} + +/* + * D0HNPZX - IBM Cloud Event Notifications SMS number monthly fee unit Resource Unit Pay per Use + * This part covers the monthly usage fee for a phone number. It recurs monthly. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. + */ +func EventNotificationsResourceUnitsMonthlyCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_ResourceUnitsMonthly != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsMonthly)) + } + + costComponent := schema.CostComponent{ + Name: "SMS Number Monthly Resource Units", + Unit: "Resource Units", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("RESOURCE_UNITS_NUMBER_MONTHLY"), + }, + } + return &costComponent +} + +/* + * D0HNQZX - IBM Cloud Event Notifications SMS number setup fee unit Resource Unit Pay per Use. + * This part covers any setup fee a phone number might have. It will be a one-time fee. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. + */ +func EventNotificationsResourceUnitsSetupCostComponent(r *ResourceInstance) *schema.CostComponent { + + var quantity *decimal.Decimal + if r.EventNotifications_ResourceUnitsSetup != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsSetup)) + } + + costComponent := schema.CostComponent{ + Name: "SMS Number Setup Resource Units", + Unit: "Resource Units", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Location), + Service: &r.Service, + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), + }, + } + return &costComponent +} From 1199b6076c40f03e83128b607fdb3d09eb05a2ce Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 02:39:53 -0500 Subject: [PATCH 15/55] Remove destinations & subscriptions as free --- internal/providers/terraform/ibm/registry.go | 34 -------------------- 1 file changed, 34 deletions(-) diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 3ba3488c3b5..1ee0c50ae5b 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -93,45 +93,11 @@ var FreeResources = []string{ "ibm_container_addons", "ibm_cos_bucket_object_lock_configuration", "ibm_dns_custom_resolver", - "ibm_en_destination_android", - "ibm_en_destination_ce", - "ibm_en_destination_cf", - "ibm_en_destination_chrome", - "ibm_en_destination_cos", - "ibm_en_destination_custom_email", - "ibm_en_destination_custom_sms", - "ibm_en_destination_firefox", - "ibm_en_destination_huawei", - "ibm_en_destination_ios", - "ibm_en_destination_msteams", - "ibm_en_destination_pagerduty", - "ibm_en_destination_safari", - "ibm_en_destination_slack", - "ibm_en_destination_sn", - "ibm_en_destination_webhook", "ibm_en_email_template", "ibm_en_ibmsource", "ibm_en_integration_cos", "ibm_en_integration", "ibm_en_source", - "ibm_en_subscription_android", - "ibm_en_subscription_ce", - "ibm_en_subscription_cf", - "ibm_en_subscription_chrome", - "ibm_en_subscription_cos", - "ibm_en_subscription_custom_email", - "ibm_en_subscription_custom_sms", - "ibm_en_subscription_email", - "ibm_en_subscription_firefox", - "ibm_en_subscription_huawei", - "ibm_en_subscription_ios", - "ibm_en_subscription_msteams", - "ibm_en_subscription_pagerduty", - "ibm_en_subscription_safari", - "ibm_en_subscription_slack", - "ibm_en_subscription_sms", - "ibm_en_subscription_sn", - "ibm_en_subscription_webhook", "ibm_en_topic", "ibm_event_streams_schema", "ibm_event_streams_topic", From 6cdd95302e0e3aacd24cb488f284d384977feb12 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 03:57:07 -0500 Subject: [PATCH 16/55] Update EN golden file to only 1 cost component --- .../resource_instance_test.golden | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden index a08e44ef70f..414e93db808 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden @@ -22,32 +22,10 @@ └─ Lite Plan 1 $0.00 ibm_resource_instance.event_notifications["standard"] - ├─ Ingested Events 1 Million Events $1.08 - ├─ Outbound Custom Domain E-mail GB Transmitted 1 GB $0.12 - ├─ Outbound Custom Domain E-mails 1,000 E-mails $0.15 - ├─ Outbound E-mails 100,000 E-mails $4.31 - ├─ Outbound HTTP Messages 1,000,000 Messages $1.08 - ├─ Outbound Push Messages (first 100 Messages) 100 Messages $0.00 - ├─ Outbound Push Messages (over 100 Messages) 1 Messages $0.00 - ├─ Outbound SMS Messages 1,000 Messages $16.15 - ├─ Pre-Prod Push Destination Instances 1 Instances $10.00 - ├─ Push Destination Instances 1 Instances $35.00 - ├─ SMS Number Monthly Resource Units 1 Resource Units $1.00 - └─ SMS Number Setup Resource Units 1 Resource Units $1.00 + └─ Ingested Events 1 Million Events $1.08 ibm_resource_instance.event_notifications_no_usage - ├─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - ├─ Outbound Custom Domain E-mail GB Transmitted Monthly cost depends on usage: $0.12 per GB - ├─ Outbound Custom Domain E-mails Monthly cost depends on usage: $0.00015 per E-mails - ├─ Outbound E-mails Monthly cost depends on usage: $0.0000431 per E-mails - ├─ Outbound HTTP Messages Monthly cost depends on usage: $0.00000108 per Messages - ├─ Outbound Push Messages (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - ├─ Outbound Push Messages (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages - ├─ Outbound SMS Messages Monthly cost depends on usage: $0.01615 per Messages - ├─ Pre-Prod Push Destination Instances Monthly cost depends on usage: $10.00 per Instances - ├─ Push Destination Instances Monthly cost depends on usage: $35.00 per Instances - ├─ SMS Number Monthly Resource Units Monthly cost depends on usage: $1.00 per Resource Units - └─ SMS Number Setup Resource Units Monthly cost depends on usage: $1.00 per Resource Units + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events ibm_resource_instance.messagehub_enterprise ├─ Base Capacity Unit-Hour 1 Hours $7.37 @@ -228,7 +206,7 @@ ├─ Class 2 Resource Units 50 RU $0.09 └─ Class 3 Resource Units 50 RU $0.25 - OVERALL TOTAL $19,375.00 + OVERALL TOTAL $19,306.19 ────────────────────────────────── 44 cloud resources were detected: ∙ 44 were estimated, all of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file From 17b9b6938ab17f1adea866216c2ca0083f1671b7 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 03:58:34 -0500 Subject: [PATCH 17/55] Update EN golden file to only 1 cost component --- infracost-usage-example.yml | 19 +- .../resource_instance_test.usage.yml | 12 +- internal/resources/ibm/resource_instance.go | 39 +- .../resource_instance_event-notifications.go | 518 ++++++++---------- 4 files changed, 259 insertions(+), 329 deletions(-) diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index 8f6f590f621..241ce2a69e6 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -1401,16 +1401,15 @@ resource_usage: ibm_resource_instance.event_notifications: event-notifications_MILLION_INGESTED_EVENTS: 1 - event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 - event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 - event-notifications_PUSH_DESTINATION_INSTANCES: 1 - event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 - event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 + + # event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + # event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 + # event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + # event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 ibm_tg_gateway.tg_gateway: connection: 25 # Monthly number of connections to the gateway diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml index 63c180b168c..a68b43c8717 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.usage.yml @@ -146,14 +146,4 @@ resource_usage: messagehub_qty_capacity_units_additional: 1 ibm_resource_instance.event_notifications[*]: - event-notifications_MILLION_INGESTED_EVENTS: 1 - event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1000 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 100000 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 101 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 - event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 1 - event-notifications_PUSH_DESTINATION_INSTANCES: 1 - event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 - event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 + event-notifications_MILLION_INGESTED_EVENTS: 1 \ No newline at end of file diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index 18816c07f53..aad91e6e3f0 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -109,17 +109,15 @@ type ResourceInstance struct { EventStreams_TerabyteHours *float64 `infracost_usage:"messagehub_TERABYTE_HOURS"` EventStreams_Terabytes *float64 `infracost_usage:"messagehub_qty_terabytes"` // Event Notifications - EventNotifications_InboundIngestedEvents *float64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` - EventNotifications_OutboundCustomDomainEmailGBsTransmitted *float64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` - EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` - EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` - EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` - EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` - EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` - EventNotifications_PreProdPushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES"` - EventNotifications_PushDestinationInstances *int64 `infracost_usage:"event-notifications_PUSH_DESTINATION_INSTANCES"` - EventNotifications_ResourceUnitsMonthly *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` - EventNotifications_ResourceUnitsSetup *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` + EventNotifications_InboundIngestedEvents *float64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` + // EventNotifications_OutboundCustomDomainEmailGBsTransmitted *float64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` + // EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` + // EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` + // EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + // EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` + // EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` + // EventNotifications_ResourceUnitsMonthly *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` + // EventNotifications_ResourceUnitsSetup *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -190,16 +188,14 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "messagehub_TERABYTE_HOURS", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_qty_terabytes", DefaultValue: 1, ValueType: schema.Float64}, {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_PUSH_DESTINATION_INSTANCES", DefaultValue: 0, ValueType: schema.Int64}, - {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, + // {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Float64}, + // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, + // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 0, ValueType: schema.Int64}, + // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, + // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, + // {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, + // {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ @@ -698,6 +694,7 @@ func GetContinuousDeliveryCostComponenets(r *ResourceInstance) []*schema.CostCom q = decimalPtr(decimal.NewFromInt(*r.ContinuousDelivery_AuthorizedUsers)) } if r.Plan == "lite" { + costComponent := &schema.CostComponent{ Name: "Lite plan", UnitMultiplier: decimal.NewFromInt(1), diff --git a/internal/resources/ibm/resource_instance_event-notifications.go b/internal/resources/ibm/resource_instance_event-notifications.go index a77ae439cf9..5a8e5dd0695 100644 --- a/internal/resources/ibm/resource_instance_event-notifications.go +++ b/internal/resources/ibm/resource_instance_event-notifications.go @@ -32,16 +32,14 @@ func GetEventNotificationsCostComponents(r *ResourceInstance) []*schema.CostComp } else if r.Plan == EVENT_NOTIFICATIONS_STANDARD_PLAN_PROGRAMMATIC_NAME { return []*schema.CostComponent{ EventNotificationsInboundIngestedEventsCostComponent(r), - EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r), - EventNotificationsOutboundCustomDomainEmailsCostComponent(r), - EventNotificationsOutboundEmailsCostComponent(r), - EventNotificationsOutboundHTTPMessagesCostComponent(r), - EventNotificationsOutboundPushMessagesCostComponent(r), - EventNotificationsOutboundSMSMessagesCostComponent(r), - EventNotificationsPreProdPushDestinationInstancesCostComponent(r), - EventNotificationsPushDestinationInstancesCostComponent(r), - EventNotificationsResourceUnitsMonthlyCostComponent(r), - EventNotificationsResourceUnitsSetupCostComponent(r), + // EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r), + // EventNotificationsOutboundCustomDomainEmailsCostComponent(r), + // EventNotificationsOutboundEmailsCostComponent(r), + // EventNotificationsOutboundHTTPMessagesCostComponent(r), + // EventNotificationsOutboundPushMessagesCostComponent(r), + // EventNotificationsOutboundSMSMessagesCostComponent(r), + // EventNotificationsResourceUnitsMonthlyCostComponent(r), + // EventNotificationsResourceUnitsSetupCostComponent(r), } } else { costComponent := schema.CostComponent{ @@ -91,280 +89,226 @@ func EventNotificationsInboundIngestedEventsCostComponent(r *ResourceInstance) * return &costComponent } -func EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted != nil { - quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound Custom Domain E-mail GB Transmitted", - Unit: "GB", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"), - }, - } - return &costComponent -} - -func EventNotificationsOutboundCustomDomainEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundCustomDomainEmails != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundCustomDomainEmails)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound Custom Domain E-mails", - Unit: "E-mails", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"), - }, - } - return &costComponent -} - -func EventNotificationsOutboundEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundEmails != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundEmails)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound E-mails", - Unit: "E-mails", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_EMAILS"), - }, - } - return &costComponent -} - -func EventNotificationsOutboundHTTPMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundHTTPMessages)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound HTTP Messages", - Unit: "Messages", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), - }, - } - return &costComponent -} - -func EventNotificationsOutboundPushMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundPushMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundPushMessages)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound Push Messages", - Unit: "Messages", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), - }, - } - return &costComponent -} - -func EventNotificationsOutboundSMSMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_OutboundSMSMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundSMSMessages)) - } - - costComponent := schema.CostComponent{ - Name: "Outbound SMS Messages", - Unit: "Messages", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"), - }, - } - return &costComponent -} - -func EventNotificationsPreProdPushDestinationInstancesCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_PreProdPushDestinationInstances != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_PreProdPushDestinationInstances)) - } - - costComponent := schema.CostComponent{ - Name: "Pre-Prod Push Destination Instances", - Unit: "Instances", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("PUSH_PREPROD_DESTINATION_INSTANCES"), - }, - } - return &costComponent -} - -func EventNotificationsPushDestinationInstancesCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_PushDestinationInstances != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_PushDestinationInstances)) - } - - costComponent := schema.CostComponent{ - Name: "Push Destination Instances", - Unit: "Instances", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("PUSH_DESTINATION_INSTANCES"), - }, - } - return &costComponent -} - -/* - * D0HNPZX - IBM Cloud Event Notifications SMS number monthly fee unit Resource Unit Pay per Use - * This part covers the monthly usage fee for a phone number. It recurs monthly. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. - */ -func EventNotificationsResourceUnitsMonthlyCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_ResourceUnitsMonthly != nil { - quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsMonthly)) - } - - costComponent := schema.CostComponent{ - Name: "SMS Number Monthly Resource Units", - Unit: "Resource Units", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("RESOURCE_UNITS_NUMBER_MONTHLY"), - }, - } - return &costComponent -} - -/* - * D0HNQZX - IBM Cloud Event Notifications SMS number setup fee unit Resource Unit Pay per Use. - * This part covers any setup fee a phone number might have. It will be a one-time fee. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. - */ -func EventNotificationsResourceUnitsSetupCostComponent(r *ResourceInstance) *schema.CostComponent { - - var quantity *decimal.Decimal - if r.EventNotifications_ResourceUnitsSetup != nil { - quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsSetup)) - } - - costComponent := schema.CostComponent{ - Name: "SMS Number Setup Resource Units", - Unit: "Resource Units", - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: quantity, - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Location), - Service: &r.Service, - AttributeFilters: []*schema.AttributeFilter{ - {Key: "planName", Value: &r.Plan}, - }, - }, - PriceFilter: &schema.PriceFilter{ - Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), - }, - } - return &costComponent -} +// func EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted != nil { +// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound Custom Domain E-mail GB Transmitted", +// Unit: "GB", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"), +// }, +// } +// return &costComponent +// } + +// func EventNotificationsOutboundCustomDomainEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundCustomDomainEmails != nil { +// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundCustomDomainEmails)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound Custom Domain E-mails", +// Unit: "E-mails", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"), +// }, +// } +// return &costComponent +// } + +// func EventNotificationsOutboundEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundEmails != nil { +// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundEmails)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound E-mails", +// Unit: "E-mails", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_EMAILS"), +// }, +// } +// return &costComponent +// } + +// func EventNotificationsOutboundHTTPMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundHTTPMessages != nil { +// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundHTTPMessages)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound HTTP Messages", +// Unit: "Messages", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), +// }, +// } +// return &costComponent +// } + +// func EventNotificationsOutboundPushMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundPushMessages != nil { +// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundPushMessages)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound Push Messages", +// Unit: "Messages", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), +// }, +// } +// return &costComponent +// } + +// func EventNotificationsOutboundSMSMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_OutboundSMSMessages != nil { +// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundSMSMessages)) +// } + +// costComponent := schema.CostComponent{ +// Name: "Outbound SMS Messages", +// Unit: "Messages", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"), +// }, +// } +// return &costComponent +// } + +// /* +// * D0HNPZX - IBM Cloud Event Notifications SMS number monthly fee unit Resource Unit Pay per Use +// * This part covers the monthly usage fee for a phone number. It recurs monthly. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. +// */ +// func EventNotificationsResourceUnitsMonthlyCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_ResourceUnitsMonthly != nil { +// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsMonthly)) +// } + +// costComponent := schema.CostComponent{ +// Name: "SMS Number Monthly Resource Units", +// Unit: "Resource Units", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("RESOURCE_UNITS_NUMBER_MONTHLY"), +// }, +// } +// return &costComponent +// } + +// /* +// * D0HNQZX - IBM Cloud Event Notifications SMS number setup fee unit Resource Unit Pay per Use. +// * This part covers any setup fee a phone number might have. It will be a one-time fee. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. +// */ +// func EventNotificationsResourceUnitsSetupCostComponent(r *ResourceInstance) *schema.CostComponent { + +// var quantity *decimal.Decimal +// if r.EventNotifications_ResourceUnitsSetup != nil { +// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsSetup)) +// } + +// costComponent := schema.CostComponent{ +// Name: "SMS Number Setup Resource Units", +// Unit: "Resource Units", +// UnitMultiplier: decimal.NewFromInt(1), +// MonthlyQuantity: quantity, +// ProductFilter: &schema.ProductFilter{ +// VendorName: strPtr("ibm"), +// Region: strPtr(r.Location), +// Service: &r.Service, +// AttributeFilters: []*schema.AttributeFilter{ +// {Key: "planName", Value: &r.Plan}, +// }, +// }, +// PriceFilter: &schema.PriceFilter{ +// Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), +// }, +// } +// return &costComponent +// } From 03cbaa508491b1cc03d6fc0a6097b013fb1b7584 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:03:19 -0500 Subject: [PATCH 18/55] Better output for lite EN instances --- .../resource_instance_test/resource_instance_test.golden | 2 +- internal/resources/ibm/resource_instance_event-notifications.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden index 414e93db808..f6cc53cdc8d 100644 --- a/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden +++ b/internal/providers/terraform/ibm/testdata/resource_instance_test/resource_instance_test.golden @@ -19,7 +19,7 @@ └─ Additional Million DNS Queries (over 999 Million Queries) 1 Million Queries $0.32 ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 $0.00 + └─ Lite Plan 1 Instance $0.00 ibm_resource_instance.event_notifications["standard"] └─ Ingested Events 1 Million Events $1.08 diff --git a/internal/resources/ibm/resource_instance_event-notifications.go b/internal/resources/ibm/resource_instance_event-notifications.go index 5a8e5dd0695..75fae539d27 100644 --- a/internal/resources/ibm/resource_instance_event-notifications.go +++ b/internal/resources/ibm/resource_instance_event-notifications.go @@ -14,6 +14,7 @@ func GetEventNotificationsCostComponents(r *ResourceInstance) []*schema.CostComp if r.Plan == EVENT_NOTIFICATIONS_LITE_PLAN_PROGRAMMATIC_NAME { costComponent := schema.CostComponent{ Name: "Lite Plan", + Unit: "Instance", UnitMultiplier: decimal.NewFromInt(1), MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), ProductFilter: &schema.ProductFilter{ From cd5ef829b34bdf9b49bb8153e37b2019a2168d77 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:05:43 -0500 Subject: [PATCH 19/55] Add support for en_destination_android resource --- .../providers/terraform/ibm/en_destination.go | 46 +++++++ .../terraform/ibm/en_destination_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_test.golden | 25 ++++ .../en_destination_test.tf | 57 +++++++++ .../en_destination_test.usage.yml | 2 + internal/resources/ibm/en_destination.go | 112 ++++++++++++++++++ 7 files changed, 259 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination.go create mode 100644 internal/providers/terraform/ibm/en_destination_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.usage.yml create mode 100644 internal/resources/ibm/en_destination.go diff --git a/internal/providers/terraform/ibm/en_destination.go b/internal/providers/terraform/ibm/en_destination.go new file mode 100644 index 00000000000..c061d57c62d --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_android", + RFunc: newEnDestination, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestination(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + var plan string + + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_test.go b/internal/providers/terraform/ibm/en_destination_test.go new file mode 100644 index 00000000000..da9ba12e559 --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestination(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 1ee0c50ae5b..c06568a8c30 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -25,6 +25,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getDatabaseRegistryItem(), getIsShareRegistryItem(), getIsVpnServerRegistryItem(), + getEnDestinationRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.golden new file mode 100644 index 00000000000..ab8d149d548 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_android.destination_android_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_android.destination_android_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_android.destination_android_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_android.destination_android_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.tf new file mode 100644 index 00000000000..f852da9d0e9 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.tf @@ -0,0 +1,57 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_android" "destination_android_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Android Destination" + type = "push_android" + collect_failed_events = false + description = "Android push destination" + config { + params { + project_id = "projectid" + private_key = "privatekey" + client_email = "user@mail.com" + pre_prod = each.value + } + } +} + +resource "ibm_en_destination_android" "destination_android_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Android Destination" + type = "push_android" + collect_failed_events = false + description = "Android push destination" + config { + params { + project_id = "projectid" + private_key = "privatekey" + client_email = "user@mail.com" + pre_prod = tobool(each.value) + } + } +} diff --git a/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_test/en_destination_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination.go b/internal/resources/ibm/en_destination.go new file mode 100644 index 00000000000..669a19d7aca --- /dev/null +++ b/internal/resources/ibm/en_destination.go @@ -0,0 +1,112 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestination struct represents . +// +// +// +// Resource information: https://cloud.ibm.com// +// Pricing information: https://cloud.ibm.com// +type EnDestination struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationUsageSchema defines a list which represents the usage schema of EnDestination. +var EnDestinationUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestination. +// It uses the `infracost_usage` struct tags to populate data into the EnDestination. +func (r *EnDestination) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestination struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestination) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationPushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationPushDestinationInstancesCostComponent(r *EnDestination) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From bc4a424330b07923115363d8700246b70a5be0ae Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:47:34 -0500 Subject: [PATCH 20/55] Add support for android subscriptions --- infracost-usage-example.yml | 24 ++-- .../terraform/ibm/en_subscription.go | 42 +++++++ .../terraform/ibm/en_subscription_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 3 +- .../en_subscription_test.golden | 24 ++++ .../en_subscription_test.tf | 46 ++++++++ .../en_subscription_test.usage.yml | 6 + internal/resources/ibm/en_subscription.go | 109 ++++++++++++++++++ 8 files changed, 258 insertions(+), 12 deletions(-) create mode 100644 internal/providers/terraform/ibm/en_subscription.go create mode 100644 internal/providers/terraform/ibm/en_subscription_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription.go diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index 241ce2a69e6..a17551ab680 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -106,16 +106,16 @@ resource_type_default_usage: messagehub_qty_terabytes: 1 messagehub_GIGABYTE_TRANSMITTED_OUTBOUNDS: 1 event-notifications_MILLION_INGESTED_EVENTS: 1 - event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 - event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 - event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 - event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 - event-notifications_PUSH_DESTINATION_INSTANCES: 1 - event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 - event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 + # event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + # event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 + # event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 + # event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 + # event-notifications_PUSH_DESTINATION_INSTANCES: 1 + # event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + # event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 ibm_tg_gateway: connection: 3 @@ -1401,12 +1401,14 @@ resource_usage: ibm_resource_instance.event_notifications: event-notifications_MILLION_INGESTED_EVENTS: 1 - + + ibm_en_subscription_android.subscription_android: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + # event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 # event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 # event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 # event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 - # event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 # event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 # event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 # event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 diff --git a/internal/providers/terraform/ibm/en_subscription.go b/internal/providers/terraform/ibm/en_subscription.go new file mode 100644 index 00000000000..d44a1d79312 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription.go @@ -0,0 +1,42 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_android", + RFunc: newEnSubscription, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscription(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_test.go b/internal/providers/terraform/ibm/en_subscription_test.go new file mode 100644 index 00000000000..57bb9abc42e --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscription(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index c06568a8c30..76122795cf0 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -25,7 +25,8 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getDatabaseRegistryItem(), getIsShareRegistryItem(), getIsVpnServerRegistryItem(), - getEnDestinationRegistryItem(), + getEnDestinationRegistryItem(), // Android + getEnSubscriptionRegistryItem(), // Android } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden new file mode 100644 index 00000000000..ecbaf527f5a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_android.subscription_android_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_android.subscription_android_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_android.subscription_android_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.tf new file mode 100644 index 00000000000..ff5261a4b8a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_android" "subscription_android_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Android Subscription" + description = "Android Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_android" "subscription_android_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Android Subscription" + description = "Android Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_android" "subscription_android_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Android Subscription" + description = "Android Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.usage.yml new file mode 100644 index 00000000000..b88ea59c53f --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_android.subscription_android_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_android.subscription_android_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription.go b/internal/resources/ibm/en_subscription.go new file mode 100644 index 00000000000..e34bb42f005 --- /dev/null +++ b/internal/resources/ibm/en_subscription.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscription struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscription struct { + Address string + Name string + Plan string + Region string + EnSubscriptionAndroid_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionUsageSchema defines a list which represents the usage schema of EnSubscription. +var EnSubscriptionUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscription. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscription. +func (r *EnSubscription) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscription struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscription) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionOutboundPushMessagesCostComponent(r *EnSubscription) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Android Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionAndroid_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionAndroid_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 4e211e2265c1849738da92303d574a4a4114f8ca Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:47:52 -0500 Subject: [PATCH 21/55] Add destination android info in comments --- internal/resources/ibm/en_destination.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/resources/ibm/en_destination.go b/internal/resources/ibm/en_destination.go index 669a19d7aca..6d9706fae73 100644 --- a/internal/resources/ibm/en_destination.go +++ b/internal/resources/ibm/en_destination.go @@ -8,13 +8,10 @@ import ( "github.com/shopspring/decimal" ) -// EnDestination struct represents . +// EnDestination struct // -// -// -// Resource information: https://cloud.ibm.com// -// Pricing information: https://cloud.ibm.com// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications type EnDestination struct { Address string IsPreProd bool From 74e4bc5817ec90fd1d0ad49cf2a25c0fd3916f15 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:52:11 -0500 Subject: [PATCH 22/55] Update function name for clarity --- internal/resources/ibm/en_subscription.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/resources/ibm/en_subscription.go b/internal/resources/ibm/en_subscription.go index e34bb42f005..89fdaa7137d 100644 --- a/internal/resources/ibm/en_subscription.go +++ b/internal/resources/ibm/en_subscription.go @@ -36,7 +36,7 @@ func (r *EnSubscription) PopulateUsage(u *schema.UsageData) { // See providers folder for more information. func (r *EnSubscription) BuildResource() *schema.Resource { costComponents := []*schema.CostComponent{ - EnSubscriptionOutboundPushMessagesCostComponent(r), + EnSubscriptionAndroidOutboundPushMessagesCostComponent(r), } return &schema.Resource{ @@ -46,7 +46,7 @@ func (r *EnSubscription) BuildResource() *schema.Resource { } } -func EnSubscriptionOutboundPushMessagesCostComponent(r *EnSubscription) *schema.CostComponent { +func EnSubscriptionAndroidOutboundPushMessagesCostComponent(r *EnSubscription) *schema.CostComponent { var costComponent schema.CostComponent component_name := "Outbound Android Push Messages" component_unit := "Messages" From 270dd9b12adf6c889838786cb6b6f227428e0300 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 04:56:31 -0500 Subject: [PATCH 23/55] Add support for push notifications in Chrome --- .../terraform/ibm/en_subscription_chrome.go | 42 +++++++ .../ibm/en_subscription_chrome_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_chrome_test.golden | 24 ++++ .../en_subscription_chrome_test.tf | 46 ++++++++ .../en_subscription_chrome_test.usage.yml | 6 + .../resources/ibm/en_subscription_chrome.go | 109 ++++++++++++++++++ 7 files changed, 244 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_chrome.go create mode 100644 internal/providers/terraform/ibm/en_subscription_chrome_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_chrome.go diff --git a/internal/providers/terraform/ibm/en_subscription_chrome.go b/internal/providers/terraform/ibm/en_subscription_chrome.go new file mode 100644 index 00000000000..feed9c8c167 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_chrome.go @@ -0,0 +1,42 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionChromeRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_chrome", + RFunc: newEnSubscriptionChrome, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionChrome(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_chrome_test.go b/internal/providers/terraform/ibm/en_subscription_chrome_test.go new file mode 100644 index 00000000000..622b5487571 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_chrome_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionChrome(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_chrome_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 76122795cf0..a4c8532bfb2 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -27,6 +27,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getIsVpnServerRegistryItem(), getEnDestinationRegistryItem(), // Android getEnSubscriptionRegistryItem(), // Android + getEnSubscriptionChromeRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.golden new file mode 100644 index 00000000000..745d06aa422 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_chrome.subscription_chrome_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_chrome.subscription_chrome_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_chrome.subscription_chrome_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.tf new file mode 100644 index 00000000000..796db6608aa --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_chrome" "subscription_chrome_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Chrome Subscription" + description = "Chrome Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_chrome" "subscription_chrome_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Chrome Subscription" + description = "Chrome Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_chrome" "subscription_chrome_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Chrome Subscription" + description = "Chrome Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.usage.yml new file mode 100644 index 00000000000..29a233cdfaa --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_chrome_test/en_subscription_chrome_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_chrome.subscription_chrome_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_chrome.subscription_chrome_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription_chrome.go b/internal/resources/ibm/en_subscription_chrome.go new file mode 100644 index 00000000000..229de835efe --- /dev/null +++ b/internal/resources/ibm/en_subscription_chrome.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionChrome struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionChrome struct { + Address string + Region string + Name string + Plan string + EnSubscriptionChrome_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionChromeUsageSchema defines a list which represents the usage schema of EnSubscriptionChrome. +var EnSubscriptionChromeUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionChrome. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionChrome. +func (r *EnSubscriptionChrome) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionChrome struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionChrome) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionChromeOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionChromeUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionChromeOutboundPushMessagesCostComponent(r *EnSubscriptionChrome) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Chrome Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionChrome_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionChrome_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 55fe97884b7a41f195baa70db6a3fbab40b85017 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:06:35 -0500 Subject: [PATCH 24/55] Add support for destinations in Chrome --- .../terraform/ibm/en_destination_chrome.go | 46 ++++++++ .../ibm/en_destination_chrome_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_chrome_test.golden | 25 ++++ .../en_destination_chrome_test.tf | 56 +++++++++ .../en_destination_chrome_test.usage.yml | 2 + .../resources/ibm/en_destination_chrome.go | 109 ++++++++++++++++++ 7 files changed, 255 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination_chrome.go create mode 100644 internal/providers/terraform/ibm/en_destination_chrome_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.usage.yml create mode 100644 internal/resources/ibm/en_destination_chrome.go diff --git a/internal/providers/terraform/ibm/en_destination_chrome.go b/internal/providers/terraform/ibm/en_destination_chrome.go new file mode 100644 index 00000000000..659fcce9e4b --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_chrome.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationChromeRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_chrome", + RFunc: newEnDestinationChrome, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestinationChrome(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_chrome_test.go b/internal/providers/terraform/ibm/en_destination_chrome_test.go new file mode 100644 index 00000000000..5bc1406bceb --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_chrome_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestinationChrome(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_chrome_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index a4c8532bfb2..f992c8e8995 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -28,6 +28,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationRegistryItem(), // Android getEnSubscriptionRegistryItem(), // Android getEnSubscriptionChromeRegistryItem(), + getEnDestinationChromeRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.golden new file mode 100644 index 00000000000..66ef4d28661 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_chrome.destination_chrome_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_chrome.destination_chrome_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_chrome.destination_chrome_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_chrome.destination_chrome_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.tf new file mode 100644 index 00000000000..242cafb3073 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.tf @@ -0,0 +1,56 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_chrome" "destination_chrome_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Chrome Destination" + type = "push_chrome" + collect_failed_events = false + description = "Chrome push destination" + config { + params { + api_key = "apikey" + website_url = "https://testevents.com" + pre_prod = tobool(each.value) + } + } +} + +resource "ibm_en_destination_chrome" "destination_chrome_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Chrome Destination" + type = "push_chrome" + collect_failed_events = false + description = "Chrome push destination" + config { + params { + api_key = "apikey" + website_url = "https://testevents.com" + pre_prod = tobool(each.value) + } + } +} + diff --git a/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_chrome_test/en_destination_chrome_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination_chrome.go b/internal/resources/ibm/en_destination_chrome.go new file mode 100644 index 00000000000..24a883d5a4b --- /dev/null +++ b/internal/resources/ibm/en_destination_chrome.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestinationChrome struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnDestinationChrome struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationChromeUsageSchema defines a list which represents the usage schema of EnDestinationChrome. +var EnDestinationChromeUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestinationChrome. +// It uses the `infracost_usage` struct tags to populate data into the EnDestinationChrome. +func (r *EnDestinationChrome) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestinationChrome struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestinationChrome) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationChromePushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationChromeUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationChromePushDestinationInstancesCostComponent(r *EnDestinationChrome) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From cc6cedad0f6d70352963951dcedcc29b619019c8 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:06:51 -0500 Subject: [PATCH 25/55] Update function name for clarity --- internal/resources/ibm/en_destination.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/resources/ibm/en_destination.go b/internal/resources/ibm/en_destination.go index 6d9706fae73..04c410b0c15 100644 --- a/internal/resources/ibm/en_destination.go +++ b/internal/resources/ibm/en_destination.go @@ -34,7 +34,7 @@ func (r *EnDestination) PopulateUsage(u *schema.UsageData) { // See providers folder for more information. func (r *EnDestination) BuildResource() *schema.Resource { costComponents := []*schema.CostComponent{ - EnDestinationPushDestinationInstancesCostComponent(r), + EnDestinationAndroidPushDestinationInstancesCostComponent(r), } return &schema.Resource{ @@ -44,7 +44,7 @@ func (r *EnDestination) BuildResource() *schema.Resource { } } -func EnDestinationPushDestinationInstancesCostComponent(r *EnDestination) *schema.CostComponent { +func EnDestinationAndroidPushDestinationInstancesCostComponent(r *EnDestination) *schema.CostComponent { var costComponent schema.CostComponent component_name := "Push Destination Instances" From 8c25ddd50911080d75635ee3accb7f6e8036f443 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:12:01 -0500 Subject: [PATCH 26/55] Add support for destinations in Firefox --- .../terraform/ibm/en_destination_firefox.go | 46 ++++++++ .../ibm/en_destination_firefox_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_firefox_test.golden | 25 ++++ .../en_destination_firefox_test.tf | 54 +++++++++ .../en_destination_firefox_test.usage.yml | 2 + .../resources/ibm/en_destination_firefox.go | 109 ++++++++++++++++++ 7 files changed, 253 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination_firefox.go create mode 100644 internal/providers/terraform/ibm/en_destination_firefox_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.usage.yml create mode 100644 internal/resources/ibm/en_destination_firefox.go diff --git a/internal/providers/terraform/ibm/en_destination_firefox.go b/internal/providers/terraform/ibm/en_destination_firefox.go new file mode 100644 index 00000000000..b3c33152505 --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_firefox.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationFirefoxRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_firefox", + RFunc: newEnDestinationFirefox, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestinationFirefox(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_firefox_test.go b/internal/providers/terraform/ibm/en_destination_firefox_test.go new file mode 100644 index 00000000000..f06edd8eacc --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_firefox_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestinationFirefox(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_firefox_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index f992c8e8995..7eae300ce8a 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -29,6 +29,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionRegistryItem(), // Android getEnSubscriptionChromeRegistryItem(), getEnDestinationChromeRegistryItem(), + getEnDestinationFirefoxRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.golden new file mode 100644 index 00000000000..dec1748ef58 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_firefox.destination_firefox_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_firefox.destination_firefox_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_firefox.destination_firefox_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_firefox.destination_firefox_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.tf new file mode 100644 index 00000000000..952b41fc118 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.tf @@ -0,0 +1,54 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_firefox" "destination_firefox_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Firefox Destination" + type = "push_firefox" + collect_failed_events = false + description = "Firefox push destination" + config { + params { + website_url = "https://testevents.com" + pre_prod = tobool(each.value) + } + } +} + +resource "ibm_en_destination_firefox" "destination_firefox_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Firefox Destination" + type = "push_firefox" + collect_failed_events = false + description = "Firefox push destination" + config { + params { + website_url = "https://testevents.com" + pre_prod = tobool(each.value) + } + } +} + diff --git a/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_firefox_test/en_destination_firefox_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination_firefox.go b/internal/resources/ibm/en_destination_firefox.go new file mode 100644 index 00000000000..f3bdf208285 --- /dev/null +++ b/internal/resources/ibm/en_destination_firefox.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestinationFirefox struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnDestinationFirefox struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationFirefoxUsageSchema defines a list which represents the usage schema of EnDestinationFirefox. +var EnDestinationFirefoxUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestinationFirefox. +// It uses the `infracost_usage` struct tags to populate data into the EnDestinationFirefox. +func (r *EnDestinationFirefox) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestinationFirefox struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestinationFirefox) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationFirefoxPushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationFirefoxUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationFirefoxPushDestinationInstancesCostComponent(r *EnDestinationFirefox) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From a9a22309b182bb528babada8f7f4dbc2f8df44f0 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:16:11 -0500 Subject: [PATCH 27/55] Add support for destinations in Huawei --- .../terraform/ibm/en_destination_huawei.go | 46 ++++++++ .../ibm/en_destination_huawei_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_huawei_test.golden | 25 ++++ .../en_destination_huawei_test.tf | 57 +++++++++ .../en_destination_huawei_test.usage.yml | 2 + .../resources/ibm/en_destination_huawei.go | 109 ++++++++++++++++++ 7 files changed, 256 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination_huawei.go create mode 100644 internal/providers/terraform/ibm/en_destination_huawei_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.usage.yml create mode 100644 internal/resources/ibm/en_destination_huawei.go diff --git a/internal/providers/terraform/ibm/en_destination_huawei.go b/internal/providers/terraform/ibm/en_destination_huawei.go new file mode 100644 index 00000000000..a47295d5a43 --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_huawei.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationHuaweiRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_huawei", + RFunc: newEnDestinationHuawei, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestinationHuawei(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_huawei_test.go b/internal/providers/terraform/ibm/en_destination_huawei_test.go new file mode 100644 index 00000000000..2326846408d --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_huawei_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestinationHuawei(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_huawei_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 7eae300ce8a..1f049744bf1 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -30,6 +30,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionChromeRegistryItem(), getEnDestinationChromeRegistryItem(), getEnDestinationFirefoxRegistryItem(), + getEnDestinationHuaweiRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.golden new file mode 100644 index 00000000000..cf9ed510a4c --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_huawei.destination_huawei_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_huawei.destination_huawei_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_huawei.destination_huawei_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_huawei.destination_huawei_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.tf new file mode 100644 index 00000000000..d216287be15 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.tf @@ -0,0 +1,57 @@ + +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_huawei" "destination_huawei_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Huawei Destination" + type = "push_huawei" + collect_failed_events = false + description = "Huawei push destination" + config { + params { + client_id = "clientid" + client_secret = "clientsecret" + pre_prod = tobool(each.value) + } + } +} + +resource "ibm_en_destination_huawei" "destination_huawei_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Huawei Destination" + type = "push_huawei" + collect_failed_events = false + description = "Huawei push destination" + config { + params { + client_id = "clientid" + client_secret = "clientsecret" // pragma: allowlist secret + pre_prod = tobool(each.value) + } + } +} + diff --git a/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_huawei_test/en_destination_huawei_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination_huawei.go b/internal/resources/ibm/en_destination_huawei.go new file mode 100644 index 00000000000..7bef7b8c5d0 --- /dev/null +++ b/internal/resources/ibm/en_destination_huawei.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestinationHuawei struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnDestinationHuawei struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationHuaweiUsageSchema defines a list which represents the usage schema of EnDestinationHuawei. +var EnDestinationHuaweiUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestinationHuawei. +// It uses the `infracost_usage` struct tags to populate data into the EnDestinationHuawei. +func (r *EnDestinationHuawei) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestinationHuawei struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestinationHuawei) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationHuaweiPushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationHuaweiUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationHuaweiPushDestinationInstancesCostComponent(r *EnDestinationHuawei) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From 493fb99442d09bee07db6f5cf4225d468a8116b1 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:26:43 -0500 Subject: [PATCH 28/55] Add support for destinations in iOS --- .../terraform/ibm/en_destination_iphoneos.go | 46 ++++++++ .../ibm/en_destination_iphoneos_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_iphoneos_test.golden | 25 ++++ .../en_destination_iphoneos_test.tf | 59 ++++++++++ .../en_destination_iphoneos_test.usage.yml | 2 + .../resources/ibm/en_destination_iphoneos.go | 109 ++++++++++++++++++ 7 files changed, 258 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination_iphoneos.go create mode 100644 internal/providers/terraform/ibm/en_destination_iphoneos_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.usage.yml create mode 100644 internal/resources/ibm/en_destination_iphoneos.go diff --git a/internal/providers/terraform/ibm/en_destination_iphoneos.go b/internal/providers/terraform/ibm/en_destination_iphoneos.go new file mode 100644 index 00000000000..0bddc79e902 --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_iphoneos.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationIphoneosRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_ios", + RFunc: newEnDestinationIphoneos, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestinationIphoneos(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_iphoneos_test.go b/internal/providers/terraform/ibm/en_destination_iphoneos_test.go new file mode 100644 index 00000000000..07b167b0819 --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_iphoneos_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestinationIphoneos(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_iphoneos_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 1f049744bf1..ad3746e1a21 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -31,6 +31,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationChromeRegistryItem(), getEnDestinationFirefoxRegistryItem(), getEnDestinationHuaweiRegistryItem(), + getEnDestinationIphoneosRegistryItem(), // iOS } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.golden new file mode 100644 index 00000000000..1c69fb700f1 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_ios.destination_ios_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_ios.destination_ios_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_ios.destination_ios_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_ios.destination_ios_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.tf new file mode 100644 index 00000000000..a32bcb10ba6 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.tf @@ -0,0 +1,59 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_ios" "destination_ios_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "iOS Destination Auth" + type = "push_ios" + collect_failed_events = false + certificate_content_type = "p8" + certificate = "${path.module}/Certificates/Auth.p8" + description = "iOS destination with P8" + config { + params { + cert_type = "p8" + is_sandbox = true + pre_prod = tobool(each.value) + } + } +} + +resource "ibm_en_destination_ios" "destination_ios_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "iOS Destination Auth" + type = "push_ios" + collect_failed_events = false + certificate_content_type = "p8" + certificate = "${path.module}/Certificates/Auth.p8" + description = "iOS destination with P8" + config { + params { + cert_type = "p8" + is_sandbox = true + pre_prod = tobool(each.value) + } + } +} diff --git a/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_iphoneos_test/en_destination_iphoneos_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination_iphoneos.go b/internal/resources/ibm/en_destination_iphoneos.go new file mode 100644 index 00000000000..4df39965a3a --- /dev/null +++ b/internal/resources/ibm/en_destination_iphoneos.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestinationIphoneos struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnDestinationIphoneos struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationIphoneosUsageSchema defines a list which represents the usage schema of EnDestinationIphoneos. +var EnDestinationIphoneosUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestinationIphoneos. +// It uses the `infracost_usage` struct tags to populate data into the EnDestinationIphoneos. +func (r *EnDestinationIphoneos) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestinationIphoneos struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestinationIphoneos) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationiOSPushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationIphoneosUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationiOSPushDestinationInstancesCostComponent(r *EnDestinationIphoneos) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From 5b4504f6178baf3e7484fa4cc3e9a83f6c24bfd2 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:33:27 -0500 Subject: [PATCH 29/55] Add support for destinations in Safari --- .../terraform/ibm/en_destination_safari.go | 46 ++++++++ .../ibm/en_destination_safari_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_destination_safari_test.golden | 25 ++++ .../en_destination_safari_test.tf | 66 +++++++++++ .../en_destination_safari_test.usage.yml | 2 + .../resources/ibm/en_destination_safari.go | 109 ++++++++++++++++++ 7 files changed, 265 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_destination_safari.go create mode 100644 internal/providers/terraform/ibm/en_destination_safari_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.usage.yml create mode 100644 internal/resources/ibm/en_destination_safari.go diff --git a/internal/providers/terraform/ibm/en_destination_safari.go b/internal/providers/terraform/ibm/en_destination_safari.go new file mode 100644 index 00000000000..a9b5764d21f --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_safari.go @@ -0,0 +1,46 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnDestinationSafariRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_destination_safari", + RFunc: newEnDestinationSafari, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnDestinationSafari(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + is_pre_prod := d.Get("config.0.params.0.pre_prod").Bool() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnDestination{ + Address: d.Address, + IsPreProd: is_pre_prod, + Name: name, + Plan: plan, + Region: region, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["pre-prod"] = is_pre_prod + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_destination_safari_test.go b/internal/providers/terraform/ibm/en_destination_safari_test.go new file mode 100644 index 00000000000..a19e4d3ed8e --- /dev/null +++ b/internal/providers/terraform/ibm/en_destination_safari_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnDestinationSafari(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_destination_safari_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index ad3746e1a21..3e55dbc0737 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -32,6 +32,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationFirefoxRegistryItem(), getEnDestinationHuaweiRegistryItem(), getEnDestinationIphoneosRegistryItem(), // iOS + getEnDestinationSafariRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.golden b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.golden new file mode 100644 index 00000000000..0b2b1199b9d --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_destination_safari.destination_safari_lite["false"] + └─ Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_safari.destination_safari_lite["true"] + └─ Pre-Prod Push Destination Instances (Lite plan) 1 Instance $0.00 + + ibm_en_destination_safari.destination_safari_standard["false"] + └─ Push Destination Instances (Standard plan) 1 Instance $35.00 + + ibm_en_destination_safari.destination_safari_standard["true"] + └─ Pre-Prod Push Destination Instances (Standard plan) 1 Instance $10.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $45.00 +────────────────────────────────── +6 cloud resources were detected: +∙ 6 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.tf b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.tf new file mode 100644 index 00000000000..9bc479914d8 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.tf @@ -0,0 +1,66 @@ + +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + destination_pre_prod = ["true", "false"] + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_destination_safari" "destination_safari_lite" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Safari Destination" + certificate = "${path.module}/Certificates/safaricert.p12" + collect_failed_events = false + description = "Safari push destination" + type = "push_safari" + config { + params { + cert_type = "p12" + password = "apnscertpassword" + url_format_string = "https://test.petstorez.com" + website_name = "petstore" + website_push_id = "petzz" + website_url = "https://test.petstorez.com" + pre_prod = tobool(each.value) + } + } +} + +resource "ibm_en_destination_safari" "destination_safari_standard" { + for_each = toset(local.event_notifications.destination_pre_prod) + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Safari Destination" + certificate = "${path.module}/Certificates/safaricert.p12" + collect_failed_events = false + description = "Safari push destination" + type = "push_safari" + config { + params { + cert_type = "p12" + password = "apnscertpassword" + url_format_string = "https://test.petstorez.com" + website_name = "petstore" + website_push_id = "petzz" + website_url = "https://test.petstorez.com" + pre_prod = tobool(each.value) + } + } +} \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.usage.yml new file mode 100644 index 00000000000..6b38d343c6a --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_destination_safari_test/en_destination_safari_test.usage.yml @@ -0,0 +1,2 @@ +version: 0.1 +resource_usage: \ No newline at end of file diff --git a/internal/resources/ibm/en_destination_safari.go b/internal/resources/ibm/en_destination_safari.go new file mode 100644 index 00000000000..4df9050e557 --- /dev/null +++ b/internal/resources/ibm/en_destination_safari.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnDestinationSafari struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnDestinationSafari struct { + Address string + IsPreProd bool + Name string + Plan string + Region string +} + +// EnDestinationSafariUsageSchema defines a list which represents the usage schema of EnDestinationSafari. +var EnDestinationSafariUsageSchema = []*schema.UsageItem{} + +// PopulateUsage parses the u schema.UsageData into the EnDestinationSafari. +// It uses the `infracost_usage` struct tags to populate data into the EnDestinationSafari. +func (r *EnDestinationSafari) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnDestinationSafari struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnDestinationSafari) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnDestinationSafariPushDestinationInstancesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnDestinationSafariUsageSchema, + CostComponents: costComponents, + } +} + +func EnDestinationSafariPushDestinationInstancesCostComponent(r *EnDestinationSafari) *schema.CostComponent { + + var costComponent schema.CostComponent + component_name := "Push Destination Instances" + unit := "PUSH_DESTINATION_INSTANCES" + + if r.IsPreProd { + component_name = "Pre-Prod Push Destination Instances" + unit = "PUSH_PREPROD_DESTINATION_INSTANCES" + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: "Instance", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ // Only standard plan exists + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr(unit), + }, + } + + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} From d611bfe1e3a11f6c9ff1629953fc0d710cd7babe Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:39:26 -0500 Subject: [PATCH 30/55] Add support for subscriptions in Firefox --- .../terraform/ibm/en_subscription_firefox.go | 43 +++++++ .../ibm/en_subscription_firefox_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_firefox_test.golden | 24 ++++ .../en_subscription_firefox_test.tf | 47 ++++++++ .../en_subscription_firefox_test.usage.yml | 6 + .../resources/ibm/en_subscription_firefox.go | 109 ++++++++++++++++++ 7 files changed, 246 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_firefox.go create mode 100644 internal/providers/terraform/ibm/en_subscription_firefox_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_firefox.go diff --git a/internal/providers/terraform/ibm/en_subscription_firefox.go b/internal/providers/terraform/ibm/en_subscription_firefox.go new file mode 100644 index 00000000000..b29ccbd92fe --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_firefox.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionFirefoxRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_firefox", + RFunc: newEnSubscriptionFirefox, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionFirefox(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_firefox_test.go b/internal/providers/terraform/ibm/en_subscription_firefox_test.go new file mode 100644 index 00000000000..bff757d0cc9 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_firefox_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionFirefox(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_firefox_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 3e55dbc0737..8dc1764cafb 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -33,6 +33,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationHuaweiRegistryItem(), getEnDestinationIphoneosRegistryItem(), // iOS getEnDestinationSafariRegistryItem(), + getEnSubscriptionFirefoxRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden new file mode 100644 index 00000000000..39ceb775703 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_firefox.subscription_firefox_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_firefox.subscription_firefox_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_firefox.subscription_firefox_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.tf new file mode 100644 index 00000000000..499ed37a374 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.tf @@ -0,0 +1,47 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_firefox" "subscription_firefox_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Firefox Subscription" + description = "Firefox Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_firefox" "subscription_firefox_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Firefox Subscription" + description = "Firefox Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_firefox" "subscription_firefox_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Firefox Subscription" + description = "Firefox Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.usage.yml new file mode 100644 index 00000000000..ca19b0c1001 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_firefox.subscription_firefox_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_firefox.subscription_firefox_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription_firefox.go b/internal/resources/ibm/en_subscription_firefox.go new file mode 100644 index 00000000000..71beb166294 --- /dev/null +++ b/internal/resources/ibm/en_subscription_firefox.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionFirefox struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionFirefox struct { + Address string + Region string + Name string + Plan string + EnSubscriptionFirefox_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionFirefoxUsageSchema defines a list which represents the usage schema of EnSubscriptionFirefox. +var EnSubscriptionFirefoxUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionFirefox. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionFirefox. +func (r *EnSubscriptionFirefox) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionFirefox struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionFirefox) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionFirefoxOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionFirefoxUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionFirefoxOutboundPushMessagesCostComponent(r *EnSubscriptionFirefox) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Chrome Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionFirefox_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionFirefox_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From f25d78e3349b61305c142f022ff8ee74bc48e8e0 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:46:23 -0500 Subject: [PATCH 31/55] Add support for subscriptions in Huawei --- .../terraform/ibm/en_subscription_huawei.go | 43 +++++++ .../ibm/en_subscription_huawei_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_huawei_test.golden | 24 ++++ .../en_subscription_huawei_test.tf | 46 ++++++++ .../en_subscription_huawei_test.usage.yml | 6 + .../resources/ibm/en_subscription_huawei.go | 109 ++++++++++++++++++ 7 files changed, 245 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_huawei.go create mode 100644 internal/providers/terraform/ibm/en_subscription_huawei_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_huawei.go diff --git a/internal/providers/terraform/ibm/en_subscription_huawei.go b/internal/providers/terraform/ibm/en_subscription_huawei.go new file mode 100644 index 00000000000..8dd29e3104e --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_huawei.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionHuaweiRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_huawei", + RFunc: newEnSubscriptionHuawei, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionHuawei(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_huawei_test.go b/internal/providers/terraform/ibm/en_subscription_huawei_test.go new file mode 100644 index 00000000000..c8f740b096b --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_huawei_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionHuawei(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_huawei_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 8dc1764cafb..487a6f39764 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -34,6 +34,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationIphoneosRegistryItem(), // iOS getEnDestinationSafariRegistryItem(), getEnSubscriptionFirefoxRegistryItem(), + getEnSubscriptionHuaweiRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden new file mode 100644 index 00000000000..5afa756949f --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_huawei.subscription_huawei_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_huawei.subscription_huawei_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_huawei.subscription_huawei_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.tf new file mode 100644 index 00000000000..05f54e2bcb0 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_huawei" "subscription_huawei_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Huawei Subscription" + description = "Huawei Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_huawei" "subscription_huawei_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Huawei Subscription" + description = "Huawei Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_huawei" "subscription_huawei_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Huawei Subscription" + description = "Huawei Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.usage.yml new file mode 100644 index 00000000000..92338194bc9 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_huawei.subscription_huawei_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_huawei.subscription_huawei_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription_huawei.go b/internal/resources/ibm/en_subscription_huawei.go new file mode 100644 index 00000000000..f62df8b6464 --- /dev/null +++ b/internal/resources/ibm/en_subscription_huawei.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionHuawei struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionHuawei struct { + Address string + Region string + Name string + Plan string + EnSubscriptionHuawei_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionHuaweiUsageSchema defines a list which represents the usage schema of EnSubscriptionHuawei. +var EnSubscriptionHuaweiUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionHuawei. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionHuawei. +func (r *EnSubscriptionHuawei) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionHuawei struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionHuawei) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionHuaweiOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionHuaweiUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionHuaweiOutboundPushMessagesCostComponent(r *EnSubscriptionHuawei) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Huawei Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionHuawei_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionHuawei_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 2a30f3b74e23b207e631613bc30624414b22e8e8 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:46:37 -0500 Subject: [PATCH 32/55] Fix output text --- internal/resources/ibm/en_subscription_firefox.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/resources/ibm/en_subscription_firefox.go b/internal/resources/ibm/en_subscription_firefox.go index 71beb166294..8f02a4f5b5f 100644 --- a/internal/resources/ibm/en_subscription_firefox.go +++ b/internal/resources/ibm/en_subscription_firefox.go @@ -48,7 +48,7 @@ func (r *EnSubscriptionFirefox) BuildResource() *schema.Resource { func EnSubscriptionFirefoxOutboundPushMessagesCostComponent(r *EnSubscriptionFirefox) *schema.CostComponent { var costComponent schema.CostComponent - component_name := "Outbound Chrome Push Messages" + component_name := "Outbound Firefox Push Messages" component_unit := "Messages" if r.Plan == "lite" { From 14e0c65d6ee99b9bd505980e6d746f46de8486af Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:52:28 -0500 Subject: [PATCH 33/55] Add support for subscriptions in iOS --- .../terraform/ibm/en_subscription_iphoneos.go | 43 +++++++ .../ibm/en_subscription_iphoneos_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_iphoneos_test.golden | 24 ++++ .../en_subscription_iphoneos_test.tf | 46 ++++++++ .../en_subscription_iphoneos_test.usage.yml | 6 + .../resources/ibm/en_subscription_iphoneos.go | 109 ++++++++++++++++++ 7 files changed, 245 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_iphoneos.go create mode 100644 internal/providers/terraform/ibm/en_subscription_iphoneos_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_iphoneos.go diff --git a/internal/providers/terraform/ibm/en_subscription_iphoneos.go b/internal/providers/terraform/ibm/en_subscription_iphoneos.go new file mode 100644 index 00000000000..b421b7c1f1f --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_iphoneos.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionIphoneosRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_ios", + RFunc: newEnSubscriptionIphoneos, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionIphoneos(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_iphoneos_test.go b/internal/providers/terraform/ibm/en_subscription_iphoneos_test.go new file mode 100644 index 00000000000..54ef714cb58 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_iphoneos_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionIphoneos(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_iphoneos_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 487a6f39764..6b247416f68 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -35,6 +35,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationSafariRegistryItem(), getEnSubscriptionFirefoxRegistryItem(), getEnSubscriptionHuaweiRegistryItem(), + getEnSubscriptionIphoneosRegistryItem(), // iOS } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden new file mode 100644 index 00000000000..2d3a8bc5043 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_ios.subscription_ios_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_ios.subscription_ios_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_ios.subscription_ios_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.tf new file mode 100644 index 00000000000..8e952204d37 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_ios" "subscription_ios_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "iOS Subscription" + description = "iOS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_ios" "subscription_ios_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "iOS Subscription" + description = "iOS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_ios" "subscription_ios_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "iOS Subscription" + description = "iOS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.usage.yml new file mode 100644 index 00000000000..c3aa245c6b3 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_ios.subscription_ios_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_ios.subscription_ios_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription_iphoneos.go b/internal/resources/ibm/en_subscription_iphoneos.go new file mode 100644 index 00000000000..73269689ea4 --- /dev/null +++ b/internal/resources/ibm/en_subscription_iphoneos.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionIphoneos struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionIphoneos struct { + Address string + Region string + Name string + Plan string + EnSubscriptioniOS_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionIphoneosUsageSchema defines a list which represents the usage schema of EnSubscriptionIphoneos. +var EnSubscriptionIphoneosUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionIphoneos. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionIphoneos. +func (r *EnSubscriptionIphoneos) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionIphoneos struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionIphoneos) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptioniOSOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionIphoneosUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptioniOSOutboundPushMessagesCostComponent(r *EnSubscriptionIphoneos) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound iOS Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptioniOS_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptioniOS_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 29606deaa5b336ee8669a9b34c2dda2eb8fc020d Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 05:56:53 -0500 Subject: [PATCH 34/55] Add support for subscriptions in Safaro --- .../terraform/ibm/en_subscription_safari.go | 43 +++++++ .../ibm/en_subscription_safari_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 7 +- .../en_subscription_safari_test.golden | 24 ++++ .../en_subscription_safari_test.tf | 46 +++++++ .../en_subscription_safari_test.usage.yml | 6 + .../resources/ibm/en_subscription_safari.go | 112 ++++++++++++++++++ 7 files changed, 251 insertions(+), 3 deletions(-) create mode 100644 internal/providers/terraform/ibm/en_subscription_safari.go create mode 100644 internal/providers/terraform/ibm/en_subscription_safari_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_safari.go diff --git a/internal/providers/terraform/ibm/en_subscription_safari.go b/internal/providers/terraform/ibm/en_subscription_safari.go new file mode 100644 index 00000000000..7cc861c812d --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_safari.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionSafariRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_safari", + RFunc: newEnSubscriptionSafari, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionSafari(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscription{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_safari_test.go b/internal/providers/terraform/ibm/en_subscription_safari_test.go new file mode 100644 index 00000000000..c55e667688c --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_safari_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionSafari(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_safari_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 6b247416f68..fb5ac6d7827 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -25,17 +25,18 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getDatabaseRegistryItem(), getIsShareRegistryItem(), getIsVpnServerRegistryItem(), - getEnDestinationRegistryItem(), // Android - getEnSubscriptionRegistryItem(), // Android - getEnSubscriptionChromeRegistryItem(), getEnDestinationChromeRegistryItem(), getEnDestinationFirefoxRegistryItem(), getEnDestinationHuaweiRegistryItem(), getEnDestinationIphoneosRegistryItem(), // iOS + getEnDestinationRegistryItem(), // Android getEnDestinationSafariRegistryItem(), + getEnSubscriptionChromeRegistryItem(), getEnSubscriptionFirefoxRegistryItem(), getEnSubscriptionHuaweiRegistryItem(), getEnSubscriptionIphoneosRegistryItem(), // iOS + getEnSubscriptionRegistryItem(), // Android + getEnSubscriptionSafariRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden new file mode 100644 index 00000000000..c8181284ee9 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden @@ -0,0 +1,24 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_safari.subscription_safari_lite + └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_safari.subscription_safari_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_safari.subscription_safari_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.tf new file mode 100644 index 00000000000..6f33ac18faa --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_safari" "subscription_safari_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Safari Subscription" + description = "Safari Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_safari" "subscription_safari_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Safari Subscription" + description = "Safari Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_safari" "subscription_safari_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Safari Subscription" + description = "Safari Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.usage.yml new file mode 100644 index 00000000000..fc8af5d4f2f --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_safari.subscription_safari_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 1 + ibm_en_subscription_safari.subscription_safari_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 10100 diff --git a/internal/resources/ibm/en_subscription_safari.go b/internal/resources/ibm/en_subscription_safari.go new file mode 100644 index 00000000000..388ecfda47b --- /dev/null +++ b/internal/resources/ibm/en_subscription_safari.go @@ -0,0 +1,112 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionSafari struct represents . +// +// +// +// Resource information: https://cloud.ibm.com// +// Pricing information: https://cloud.ibm.com// +type EnSubscriptionSafari struct { + Address string + Region string + Name string + Plan string + EnSubscriptionSafari_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` +} + +// EnSubscriptionSafariUsageSchema defines a list which represents the usage schema of EnSubscriptionSafari. +var EnSubscriptionSafariUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionSafari. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionSafari. +func (r *EnSubscriptionSafari) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionSafari struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionSafari) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionSafariOutboundPushMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionSafariUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionSafariOutboundPushMessagesCostComponent(r *EnSubscriptionSafari) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Safari Push Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSafari_OutboundPushMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSafari_OutboundPushMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 49791ecca9bc3475f1acea24db72801f626bdd76 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 06:43:51 -0500 Subject: [PATCH 35/55] Add support for subscriptions in Slack --- .../terraform/ibm/en_subscription_slack.go | 43 +++++++ .../ibm/en_subscription_slack_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_slack_test.golden | 22 ++++ .../en_subscription_slack_test.tf | 46 ++++++++ .../en_subscription_slack_test.usage.yml | 6 + .../resources/ibm/en_subscription_slack.go | 109 ++++++++++++++++++ 7 files changed, 243 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_slack.go create mode 100644 internal/providers/terraform/ibm/en_subscription_slack_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_slack.go diff --git a/internal/providers/terraform/ibm/en_subscription_slack.go b/internal/providers/terraform/ibm/en_subscription_slack.go new file mode 100644 index 00000000000..20d502d16e4 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_slack.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionSlackRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_slack", + RFunc: newEnSubscriptionSlack, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionSlack(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionSlack{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_slack_test.go b/internal/providers/terraform/ibm/en_subscription_slack_test.go new file mode 100644 index 00000000000..46ffee0c426 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_slack_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionSlack(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_slack_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index fb5ac6d7827..f79b9f3cf55 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -37,6 +37,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionIphoneosRegistryItem(), // iOS getEnSubscriptionRegistryItem(), // Android getEnSubscriptionSafariRegistryItem(), + getEnSubscriptionSlackRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden new file mode 100644 index 00000000000..61e9d0b9884 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_slack.subscription_slack_lite + └─ Outbound Slack HTTP Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_slack.subscription_slack_standard + └─ Outbound Slack HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_slack.subscription_slack_standard_no_usage + └─ Outbound Slack HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.tf new file mode 100644 index 00000000000..ffc009169f1 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_slack" "subscription_slack_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Slack Subscription" + description = "Slack Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_slack" "subscription_slack_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Slack Subscription" + description = "Slack Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_slack" "subscription_slack_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Slack Subscription" + description = "Slack Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml new file mode 100644 index 00000000000..e8d1cc0df58 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_slack.subscription_slack_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_slack.subscription_slack_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_slack.go b/internal/resources/ibm/en_subscription_slack.go new file mode 100644 index 00000000000..16c4cdee1b1 --- /dev/null +++ b/internal/resources/ibm/en_subscription_slack.go @@ -0,0 +1,109 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionSlack struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionSlack struct { + Address string + Region string + Name string + Plan string + EnSubscriptionSlack_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionSlackUsageSchema defines a list which represents the usage schema of EnSubscriptionSlack. +var EnSubscriptionSlackUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionSlack. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionSlack. +func (r *EnSubscriptionSlack) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionSlack struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionSlack) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionSlackOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionSlackUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionSlackOutboundHTTPMessagesCostComponent(r *EnSubscriptionSlack) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Slack HTTP Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSlack_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSlack_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From daa8b8c6f49a8761b49c5e3468fbba241db77aae Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 06:44:47 -0500 Subject: [PATCH 36/55] Fix bug in referencing struct --- internal/providers/terraform/ibm/en_destination_chrome.go | 2 +- internal/providers/terraform/ibm/en_destination_firefox.go | 2 +- internal/providers/terraform/ibm/en_destination_huawei.go | 2 +- internal/providers/terraform/ibm/en_destination_iphoneos.go | 2 +- internal/providers/terraform/ibm/en_destination_safari.go | 2 +- internal/providers/terraform/ibm/en_subscription_chrome.go | 2 +- internal/providers/terraform/ibm/en_subscription_firefox.go | 2 +- internal/providers/terraform/ibm/en_subscription_huawei.go | 2 +- internal/providers/terraform/ibm/en_subscription_iphoneos.go | 2 +- internal/providers/terraform/ibm/en_subscription_safari.go | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/providers/terraform/ibm/en_destination_chrome.go b/internal/providers/terraform/ibm/en_destination_chrome.go index 659fcce9e4b..7b0d0ab9e55 100644 --- a/internal/providers/terraform/ibm/en_destination_chrome.go +++ b/internal/providers/terraform/ibm/en_destination_chrome.go @@ -25,7 +25,7 @@ func newEnDestinationChrome(d *schema.ResourceData, u *schema.UsageData) *schema plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnDestination{ + r := &ibm.EnDestinationChrome{ Address: d.Address, IsPreProd: is_pre_prod, Name: name, diff --git a/internal/providers/terraform/ibm/en_destination_firefox.go b/internal/providers/terraform/ibm/en_destination_firefox.go index b3c33152505..ed780149548 100644 --- a/internal/providers/terraform/ibm/en_destination_firefox.go +++ b/internal/providers/terraform/ibm/en_destination_firefox.go @@ -25,7 +25,7 @@ func newEnDestinationFirefox(d *schema.ResourceData, u *schema.UsageData) *schem plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnDestination{ + r := &ibm.EnDestinationFirefox{ Address: d.Address, IsPreProd: is_pre_prod, Name: name, diff --git a/internal/providers/terraform/ibm/en_destination_huawei.go b/internal/providers/terraform/ibm/en_destination_huawei.go index a47295d5a43..4e1f0612d98 100644 --- a/internal/providers/terraform/ibm/en_destination_huawei.go +++ b/internal/providers/terraform/ibm/en_destination_huawei.go @@ -25,7 +25,7 @@ func newEnDestinationHuawei(d *schema.ResourceData, u *schema.UsageData) *schema plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnDestination{ + r := &ibm.EnDestinationHuawei{ Address: d.Address, IsPreProd: is_pre_prod, Name: name, diff --git a/internal/providers/terraform/ibm/en_destination_iphoneos.go b/internal/providers/terraform/ibm/en_destination_iphoneos.go index 0bddc79e902..baa5b6cae7e 100644 --- a/internal/providers/terraform/ibm/en_destination_iphoneos.go +++ b/internal/providers/terraform/ibm/en_destination_iphoneos.go @@ -25,7 +25,7 @@ func newEnDestinationIphoneos(d *schema.ResourceData, u *schema.UsageData) *sche plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnDestination{ + r := &ibm.EnDestinationIphoneos{ Address: d.Address, IsPreProd: is_pre_prod, Name: name, diff --git a/internal/providers/terraform/ibm/en_destination_safari.go b/internal/providers/terraform/ibm/en_destination_safari.go index a9b5764d21f..d03d7700c52 100644 --- a/internal/providers/terraform/ibm/en_destination_safari.go +++ b/internal/providers/terraform/ibm/en_destination_safari.go @@ -25,7 +25,7 @@ func newEnDestinationSafari(d *schema.ResourceData, u *schema.UsageData) *schema plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnDestination{ + r := &ibm.EnDestinationSafari{ Address: d.Address, IsPreProd: is_pre_prod, Name: name, diff --git a/internal/providers/terraform/ibm/en_subscription_chrome.go b/internal/providers/terraform/ibm/en_subscription_chrome.go index feed9c8c167..c21f1c0dad2 100644 --- a/internal/providers/terraform/ibm/en_subscription_chrome.go +++ b/internal/providers/terraform/ibm/en_subscription_chrome.go @@ -23,7 +23,7 @@ func newEnSubscriptionChrome(d *schema.ResourceData, u *schema.UsageData) *schem plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnSubscription{ + r := &ibm.EnSubscriptionChrome{ Address: d.Address, Region: region, Name: name, diff --git a/internal/providers/terraform/ibm/en_subscription_firefox.go b/internal/providers/terraform/ibm/en_subscription_firefox.go index b29ccbd92fe..76108fb2032 100644 --- a/internal/providers/terraform/ibm/en_subscription_firefox.go +++ b/internal/providers/terraform/ibm/en_subscription_firefox.go @@ -24,7 +24,7 @@ func newEnSubscriptionFirefox(d *schema.ResourceData, u *schema.UsageData) *sche plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnSubscription{ + r := &ibm.EnSubscriptionFirefox{ Address: d.Address, Region: region, Name: name, diff --git a/internal/providers/terraform/ibm/en_subscription_huawei.go b/internal/providers/terraform/ibm/en_subscription_huawei.go index 8dd29e3104e..73f7caf97f5 100644 --- a/internal/providers/terraform/ibm/en_subscription_huawei.go +++ b/internal/providers/terraform/ibm/en_subscription_huawei.go @@ -24,7 +24,7 @@ func newEnSubscriptionHuawei(d *schema.ResourceData, u *schema.UsageData) *schem plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnSubscription{ + r := &ibm.EnSubscriptionHuawei{ Address: d.Address, Region: region, Name: name, diff --git a/internal/providers/terraform/ibm/en_subscription_iphoneos.go b/internal/providers/terraform/ibm/en_subscription_iphoneos.go index b421b7c1f1f..70292b2ef48 100644 --- a/internal/providers/terraform/ibm/en_subscription_iphoneos.go +++ b/internal/providers/terraform/ibm/en_subscription_iphoneos.go @@ -24,7 +24,7 @@ func newEnSubscriptionIphoneos(d *schema.ResourceData, u *schema.UsageData) *sch plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnSubscription{ + r := &ibm.EnSubscriptionIphoneos{ Address: d.Address, Region: region, Name: name, diff --git a/internal/providers/terraform/ibm/en_subscription_safari.go b/internal/providers/terraform/ibm/en_subscription_safari.go index 7cc861c812d..aa5900f7d07 100644 --- a/internal/providers/terraform/ibm/en_subscription_safari.go +++ b/internal/providers/terraform/ibm/en_subscription_safari.go @@ -24,7 +24,7 @@ func newEnSubscriptionSafari(d *schema.ResourceData, u *schema.UsageData) *schem plan = enReferenceAttributes[0].Get("plan").String() } - r := &ibm.EnSubscription{ + r := &ibm.EnSubscriptionSafari{ Address: d.Address, Region: region, Name: name, From e4770ba625dca697dc0f18efb1c179c909469ef7 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 06:55:18 -0500 Subject: [PATCH 37/55] Add support for subscriptions in MS Teams --- .../terraform/ibm/en_subscription_msteams.go | 43 +++++++ .../ibm/en_subscription_msteams_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_msteams_test.golden | 22 ++++ .../en_subscription_msteams_test.tf | 47 ++++++++ .../en_subscription_msteams_test.usage.yml | 6 + .../resources/ibm/en_subscription_msteams.go | 112 ++++++++++++++++++ 7 files changed, 247 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_msteams.go create mode 100644 internal/providers/terraform/ibm/en_subscription_msteams_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_msteams.go diff --git a/internal/providers/terraform/ibm/en_subscription_msteams.go b/internal/providers/terraform/ibm/en_subscription_msteams.go new file mode 100644 index 00000000000..54cfe040b51 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_msteams.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionMsteamsRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_msteams", + RFunc: newEnSubscriptionMsteams, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionMsteams(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionMsteams{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_msteams_test.go b/internal/providers/terraform/ibm/en_subscription_msteams_test.go new file mode 100644 index 00000000000..2eb37626b8e --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_msteams_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionMsteams(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_msteams_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index f79b9f3cf55..23e5287b964 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -38,6 +38,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionRegistryItem(), // Android getEnSubscriptionSafariRegistryItem(), getEnSubscriptionSlackRegistryItem(), + getEnSubscriptionMsteamsRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden new file mode 100644 index 00000000000..a2048fd9ba3 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_msteams.subscription_msteams_lite + └─ Outbound Microsoft Teams HTTP Messages (Lite plan) 1 Messages $0.00 + + ibm_en_subscription_msteams.subscription_msteams_standard + └─ Outbound Microsoft Teams HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_msteams.subscription_msteams_standard_no_usage + └─ Outbound Microsoft Teams HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.tf new file mode 100644 index 00000000000..8421fa788bd --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.tf @@ -0,0 +1,47 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_msteams" "subscription_msteams_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Microsoft Teams Subscription" + description = "Microsoft Teams Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_msteams" "subscription_msteams_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Microsoft Teams Subscription" + description = "Microsoft Teams Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_msteams" "subscription_msteams_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Microsoft Teams Subscription" + description = "Microsoft Teams Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml new file mode 100644 index 00000000000..a2e6238f04b --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_msteams.subscription_msteams_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_msteams.subscription_msteams_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_msteams.go b/internal/resources/ibm/en_subscription_msteams.go new file mode 100644 index 00000000000..8ee2f2ff763 --- /dev/null +++ b/internal/resources/ibm/en_subscription_msteams.go @@ -0,0 +1,112 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionMsteams struct represents . +// +// +// +// Resource information: https://cloud.ibm.com// +// Pricing information: https://cloud.ibm.com// +type EnSubscriptionMsteams struct { + Address string + Region string + Name string + Plan string + EnSubscriptionMsteams_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionMsteamsUsageSchema defines a list which represents the usage schema of EnSubscriptionMsteams. +var EnSubscriptionMsteamsUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionMsteams. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionMsteams. +func (r *EnSubscriptionMsteams) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionMsteams struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionMsteams) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionMsteamsOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionMsteamsUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionMsteamsOutboundHTTPMessagesCostComponent(r *EnSubscriptionMsteams) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Microsoft Teams HTTP Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionMsteams_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionMsteams_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 947fc376bc0e8712b33ead20f323d412faeb5b0d Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:04:17 -0500 Subject: [PATCH 38/55] Add support for subscriptions in PagerDuty --- .../ibm/en_subscription_pagerduty.go | 43 +++++++++ .../ibm/en_subscription_pagerduty_test.go | 16 ++++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_pagerduty_test.golden | 22 +++++ .../en_subscription_pagerduty_test.tf | 47 +++++++++ .../en_subscription_pagerduty_test.usage.yml | 6 ++ .../ibm/en_subscription_pagerduty.go | 96 +++++++++++++++++++ 7 files changed, 231 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_pagerduty.go create mode 100644 internal/providers/terraform/ibm/en_subscription_pagerduty_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_pagerduty.go diff --git a/internal/providers/terraform/ibm/en_subscription_pagerduty.go b/internal/providers/terraform/ibm/en_subscription_pagerduty.go new file mode 100644 index 00000000000..0ea45da90dd --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_pagerduty.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionPagerdutyRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_pagerduty", + RFunc: newEnSubscriptionPagerduty, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionPagerduty(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionPagerduty{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_pagerduty_test.go b/internal/providers/terraform/ibm/en_subscription_pagerduty_test.go new file mode 100644 index 00000000000..b8114987da3 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_pagerduty_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionPagerduty(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_pagerduty_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 23e5287b964..86949f021ce 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -39,6 +39,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionSafariRegistryItem(), getEnSubscriptionSlackRegistryItem(), getEnSubscriptionMsteamsRegistryItem(), + getEnSubscriptionPagerdutyRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden new file mode 100644 index 00000000000..07623ac9b3b --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_pagerduty.subscription_pagerduty_lite + └─ Plan lite not found 1 $0.00 + + ibm_en_subscription_pagerduty.subscription_pagerduty_standard + └─ Outbound PagerDuty HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_pagerduty.subscription_pagerduty_standard_no_usage + └─ Outbound PagerDuty HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.tf new file mode 100644 index 00000000000..a5bd9d138b9 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.tf @@ -0,0 +1,47 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_pagerduty" "subscription_pagerduty_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "PagerDuty Subscription" + description = "PagerDuty Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_pagerduty" "subscription_pagerduty_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "PagerDuty Subscription" + description = "PagerDuty Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_pagerduty" "subscription_pagerduty_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "PagerDuty Subscription" + description = "PagerDuty Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml new file mode 100644 index 00000000000..9b89719ecb3 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_pagerduty.subscription_pagerduty_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_pagerduty.subscription_pagerduty_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_pagerduty.go b/internal/resources/ibm/en_subscription_pagerduty.go new file mode 100644 index 00000000000..57821f51832 --- /dev/null +++ b/internal/resources/ibm/en_subscription_pagerduty.go @@ -0,0 +1,96 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionPagerduty struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionPagerduty struct { + Address string + Region string + Name string + Plan string + EnSubscriptionPagerDuty_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionPagerdutyUsageSchema defines a list which represents the usage schema of EnSubscriptionPagerduty. +var EnSubscriptionPagerdutyUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionPagerduty. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionPagerduty. +func (r *EnSubscriptionPagerduty) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionPagerduty struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionPagerduty) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionPagerDutyOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionPagerdutyUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionPagerDutyOutboundHTTPMessagesCostComponent(r *EnSubscriptionPagerduty) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound PagerDuty HTTP Messages" + component_unit := "Messages" + + if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionPagerDuty_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionPagerDuty_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 13f5a45d14ae67d9ff680e7b5b1c67dad719f7f4 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:04:41 -0500 Subject: [PATCH 39/55] Remove 'lite' as option; not listed in description --- internal/resources/ibm/en_subscription_msteams.go | 15 +-------------- internal/resources/ibm/en_subscription_slack.go | 15 +-------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/internal/resources/ibm/en_subscription_msteams.go b/internal/resources/ibm/en_subscription_msteams.go index 8ee2f2ff763..36dc21b9c4e 100644 --- a/internal/resources/ibm/en_subscription_msteams.go +++ b/internal/resources/ibm/en_subscription_msteams.go @@ -54,20 +54,7 @@ func EnSubscriptionMsteamsOutboundHTTPMessagesCostComponent(r *EnSubscriptionMst component_name := "Outbound Microsoft Teams HTTP Messages" component_unit := "Messages" - if r.Plan == "lite" { - costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), - Unit: component_unit, - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Region), - Service: strPtr("event-notifications"), - }, - } - costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) - } else if r.Plan == "standard" { + if r.Plan == "standard" { var quantity *decimal.Decimal if r.EnSubscriptionMsteams_OutboundHTTPMessages != nil { diff --git a/internal/resources/ibm/en_subscription_slack.go b/internal/resources/ibm/en_subscription_slack.go index 16c4cdee1b1..933e1bef097 100644 --- a/internal/resources/ibm/en_subscription_slack.go +++ b/internal/resources/ibm/en_subscription_slack.go @@ -51,20 +51,7 @@ func EnSubscriptionSlackOutboundHTTPMessagesCostComponent(r *EnSubscriptionSlack component_name := "Outbound Slack HTTP Messages" component_unit := "Messages" - if r.Plan == "lite" { - costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), - Unit: component_unit, - UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), - ProductFilter: &schema.ProductFilter{ - VendorName: strPtr("ibm"), - Region: strPtr(r.Region), - Service: strPtr("event-notifications"), - }, - } - costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) - } else if r.Plan == "standard" { + if r.Plan == "standard" { var quantity *decimal.Decimal if r.EnSubscriptionSlack_OutboundHTTPMessages != nil { From 2fcc45b5e5633fcc24e772ce1dde20f5a1aabe84 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:15:11 -0500 Subject: [PATCH 40/55] Account for free 1000 notifications in lite --- .../en_subscription_firefox_test.golden | 40 +++++++++---------- .../en_subscription_huawei_test.golden | 40 +++++++++---------- .../en_subscription_iphoneos_test.golden | 10 ++--- .../en_subscription_msteams_test.golden | 2 +- .../en_subscription_safari_test.golden | 40 +++++++++---------- .../en_subscription_slack_test.golden | 2 +- .../en_subscription_test.golden | 40 +++++++++---------- internal/resources/ibm/en_subscription.go | 8 +++- .../resources/ibm/en_subscription_chrome.go | 9 ++++- .../resources/ibm/en_subscription_firefox.go | 8 +++- .../resources/ibm/en_subscription_huawei.go | 8 +++- .../resources/ibm/en_subscription_iphoneos.go | 9 ++++- .../resources/ibm/en_subscription_safari.go | 17 ++++---- 13 files changed, 128 insertions(+), 105 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden index 39ceb775703..04b24a0be8e 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_firefox_test/en_subscription_firefox_test.golden @@ -1,24 +1,24 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_en_subscription_firefox.subscription_firefox_lite - └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 - - ibm_en_subscription_firefox.subscription_firefox_standard - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 - - ibm_en_subscription_firefox.subscription_firefox_standard_no_usage - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages - - ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 Instance $0.00 - - ibm_resource_instance.event_notifications["standard"] - └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - - OVERALL TOTAL $0.01 + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_firefox.subscription_firefox_lite + └─ Outbound Firefox Push Messages (Lite plan: Max. 1000 per destination) 1 Messages $0.00 + + ibm_en_subscription_firefox.subscription_firefox_standard + └─ Outbound Firefox Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Firefox Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_firefox.subscription_firefox_standard_no_usage + └─ Outbound Firefox Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Firefox Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden index 5afa756949f..e45b8fd7df0 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_huawei_test/en_subscription_huawei_test.golden @@ -1,24 +1,24 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_en_subscription_huawei.subscription_huawei_lite - └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 - - ibm_en_subscription_huawei.subscription_huawei_standard - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 - - ibm_en_subscription_huawei.subscription_huawei_standard_no_usage - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages - - ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 Instance $0.00 - - ibm_resource_instance.event_notifications["standard"] - └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - - OVERALL TOTAL $0.01 + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_huawei.subscription_huawei_lite + └─ Outbound Huawei Push Messages (Lite plan) (Max. 1,000 per destination) 1 Messages $0.00 + + ibm_en_subscription_huawei.subscription_huawei_standard + └─ Outbound Huawei Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Huawei Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_huawei.subscription_huawei_standard_no_usage + └─ Outbound Huawei Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Huawei Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden index 2d3a8bc5043..ab1ed668ce4 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_iphoneos_test/en_subscription_iphoneos_test.golden @@ -2,15 +2,15 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_ios.subscription_ios_lite - └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 + └─ Outbound iOS Push Messages (Lite plan) (Max. 1,000 per destination) 1 Messages $0.00 ibm_en_subscription_ios.subscription_ios_standard - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + └─ Outbound iOS Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound iOS Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 ibm_en_subscription_ios.subscription_ios_standard_no_usage - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + └─ Outbound iOS Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound iOS Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages ibm_resource_instance.event_notifications["lite"] └─ Lite Plan 1 Instance $0.00 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden index a2048fd9ba3..7e0b8399aa8 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_msteams.subscription_msteams_lite - └─ Outbound Microsoft Teams HTTP Messages (Lite plan) 1 Messages $0.00 + └─ Plan lite not found 1 $0.00 ibm_en_subscription_msteams.subscription_msteams_standard └─ Outbound Microsoft Teams HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden index c8181284ee9..172e9bcdc18 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_safari_test/en_subscription_safari_test.golden @@ -1,24 +1,24 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_en_subscription_safari.subscription_safari_lite - └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 - - ibm_en_subscription_safari.subscription_safari_standard - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 - - ibm_en_subscription_safari.subscription_safari_standard_no_usage - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages - - ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 Instance $0.00 - - ibm_resource_instance.event_notifications["standard"] - └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - - OVERALL TOTAL $0.01 + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_safari.subscription_safari_lite + └─ Outbound Safari Push Messages (Lite plan) (Max. 1,000 per destination) 1 Messages $0.00 + + ibm_en_subscription_safari.subscription_safari_standard + └─ Outbound Safari Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Safari Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_safari.subscription_safari_standard_no_usage + └─ Outbound Safari Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Safari Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden index 61e9d0b9884..b7fbbfd7a45 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_slack.subscription_slack_lite - └─ Outbound Slack HTTP Messages (Lite plan) 1 Messages $0.00 + └─ Plan lite not found 1 $0.00 ibm_en_subscription_slack.subscription_slack_standard └─ Outbound Slack HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden index ecbaf527f5a..42f4ee5a8a4 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_test/en_subscription_test.golden @@ -1,24 +1,24 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_en_subscription_android.subscription_android_lite - └─ Outbound Android Push Messages (Lite plan) 1 Messages $0.00 - - ibm_en_subscription_android.subscription_android_standard - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 - - ibm_en_subscription_android.subscription_android_standard_no_usage - └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages - └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages - - ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 Instance $0.00 - - ibm_resource_instance.event_notifications["standard"] - └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - - OVERALL TOTAL $0.01 + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_android.subscription_android_lite + └─ Outbound Android Push Messages (Lite plan) (Max. 1,000 per destination) 1 Messages $0.00 + + ibm_en_subscription_android.subscription_android_standard + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) 100 Messages $0.00 + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) 10,000 Messages $0.01 + + ibm_en_subscription_android.subscription_android_standard_no_usage + └─ Outbound Android Push Messages (Standard plan) (first 100 Messages) Monthly cost depends on usage: $0.000001 per Messages + └─ Outbound Android Push Messages (Standard plan) (over 100 Messages) Monthly cost depends on usage: $0.0000005 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.01 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/resources/ibm/en_subscription.go b/internal/resources/ibm/en_subscription.go index 89fdaa7137d..ebe360181d2 100644 --- a/internal/resources/ibm/en_subscription.go +++ b/internal/resources/ibm/en_subscription.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -52,11 +53,14 @@ func EnSubscriptionAndroidOutboundPushMessagesCostComponent(r *EnSubscription) * component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionAndroid_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), diff --git a/internal/resources/ibm/en_subscription_chrome.go b/internal/resources/ibm/en_subscription_chrome.go index 229de835efe..aea6b165071 100644 --- a/internal/resources/ibm/en_subscription_chrome.go +++ b/internal/resources/ibm/en_subscription_chrome.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -52,11 +53,14 @@ func EnSubscriptionChromeOutboundPushMessagesCostComponent(r *EnSubscriptionChro component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionChrome_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), @@ -64,6 +68,7 @@ func EnSubscriptionChromeOutboundPushMessagesCostComponent(r *EnSubscriptionChro }, } costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } else if r.Plan == "standard" { var quantity *decimal.Decimal diff --git a/internal/resources/ibm/en_subscription_firefox.go b/internal/resources/ibm/en_subscription_firefox.go index 8f02a4f5b5f..459d8470093 100644 --- a/internal/resources/ibm/en_subscription_firefox.go +++ b/internal/resources/ibm/en_subscription_firefox.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -52,11 +53,14 @@ func EnSubscriptionFirefoxOutboundPushMessagesCostComponent(r *EnSubscriptionFir component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionFirefox_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), diff --git a/internal/resources/ibm/en_subscription_huawei.go b/internal/resources/ibm/en_subscription_huawei.go index f62df8b6464..de16689a5cd 100644 --- a/internal/resources/ibm/en_subscription_huawei.go +++ b/internal/resources/ibm/en_subscription_huawei.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -52,11 +53,14 @@ func EnSubscriptionHuaweiOutboundPushMessagesCostComponent(r *EnSubscriptionHuaw component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionHuawei_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), diff --git a/internal/resources/ibm/en_subscription_iphoneos.go b/internal/resources/ibm/en_subscription_iphoneos.go index 73269689ea4..c99eab79a39 100644 --- a/internal/resources/ibm/en_subscription_iphoneos.go +++ b/internal/resources/ibm/en_subscription_iphoneos.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -52,11 +53,15 @@ func EnSubscriptioniOSOutboundPushMessagesCostComponent(r *EnSubscriptionIphoneo component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptioniOS_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), + Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), diff --git a/internal/resources/ibm/en_subscription_safari.go b/internal/resources/ibm/en_subscription_safari.go index 388ecfda47b..a563ae90845 100644 --- a/internal/resources/ibm/en_subscription_safari.go +++ b/internal/resources/ibm/en_subscription_safari.go @@ -2,19 +2,17 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" "github.com/shopspring/decimal" ) -// EnSubscriptionSafari struct represents . +// EnSubscriptionSafari struct // -// -// -// Resource information: https://cloud.ibm.com// -// Pricing information: https://cloud.ibm.com// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications type EnSubscriptionSafari struct { Address string Region string @@ -55,11 +53,14 @@ func EnSubscriptionSafariOutboundPushMessagesCostComponent(r *EnSubscriptionSafa component_unit := "Messages" if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionSafari_OutboundPushMessages), float64(1000)) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 1,000 per destination)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), - MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), ProductFilter: &schema.ProductFilter{ VendorName: strPtr("ibm"), Region: strPtr(r.Region), From 2363f57a803df9f83d2ad908da3738b2b33d77c0 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:21:55 -0500 Subject: [PATCH 41/55] Add support for subscriptions in webhooks --- .../terraform/ibm/en_subscription_webhook.go | 43 +++++++ .../ibm/en_subscription_webhook_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_webhook_test.golden | 22 ++++ .../en_subscription_webhook_test.tf | 46 +++++++ .../en_subscription_webhook_test.usage.yml | 6 + .../resources/ibm/en_subscription_webhook.go | 114 ++++++++++++++++++ 7 files changed, 248 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_webhook.go create mode 100644 internal/providers/terraform/ibm/en_subscription_webhook_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_webhook.go diff --git a/internal/providers/terraform/ibm/en_subscription_webhook.go b/internal/providers/terraform/ibm/en_subscription_webhook.go new file mode 100644 index 00000000000..ff91aef7ad8 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_webhook.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionWebhookRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_webhook", + RFunc: newEnSubscriptionWebhook, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionWebhook(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionWebhook{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_webhook_test.go b/internal/providers/terraform/ibm/en_subscription_webhook_test.go new file mode 100644 index 00000000000..e8666e9d7f1 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_webhook_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionWebhook(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_webhook_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 86949f021ce..81bddfaea80 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -40,6 +40,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionSlackRegistryItem(), getEnSubscriptionMsteamsRegistryItem(), getEnSubscriptionPagerdutyRegistryItem(), + getEnSubscriptionWebhookRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.golden new file mode 100644 index 00000000000..054dab4ae29 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_webhook.subscription_webhook_lite + └─ Outbound Webhook HTTP Messages (Lite plan) (Max. 20) 20 Messages $0.00 + + ibm_en_subscription_webhook.subscription_webhook_standard + └─ Outbound Webhook HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_webhook.subscription_webhook_standard_no_usage + └─ Outbound Webhook HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.tf new file mode 100644 index 00000000000..714caacb26b --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_webhook" "subscription_webhook_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Webhook Subscription" + description = "Webhook Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_webhook" "subscription_webhook_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Webhook Subscription" + description = "Webhook Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_webhook" "subscription_webhook_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Webhook Subscription" + description = "Webhook Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml new file mode 100644 index 00000000000..d4fb467f7f4 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_webhook.subscription_webhook_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_webhook.subscription_webhook_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_webhook.go b/internal/resources/ibm/en_subscription_webhook.go new file mode 100644 index 00000000000..7948b522cda --- /dev/null +++ b/internal/resources/ibm/en_subscription_webhook.go @@ -0,0 +1,114 @@ +package ibm + +import ( + "fmt" + "math" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionWebhook struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionWebhook struct { + Address string + Region string + Name string + Plan string + EnSubscriptionWebhook_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionWebhookUsageSchema defines a list which represents the usage schema of EnSubscriptionWebhook. +var EnSubscriptionWebhookUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionWebhook. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionWebhook. +func (r *EnSubscriptionWebhook) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionWebhook struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionWebhook) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionWebhookOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionWebhookUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionWebhookOutboundHTTPMessagesCostComponent(r *EnSubscriptionWebhook) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Webhook HTTP Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionWebhook_OutboundHTTPMessages), float64(20)) + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan) (Max. 20)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionWebhook_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionWebhook_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From ace1533279c9156eeb6cd8c80069c642b52edb11 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:27:10 -0500 Subject: [PATCH 42/55] Add support for subscriptions in ServiceNow --- .../terraform/ibm/en_subscription_sn.go | 42 ++++++++ .../terraform/ibm/en_subscription_sn_test.go | 16 ++++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_sn_test.golden | 22 +++++ .../en_subscription_sn_test.tf | 46 +++++++++ .../en_subscription_sn_test.usage.yml | 6 ++ internal/resources/ibm/en_subscription_sn.go | 96 +++++++++++++++++++ 7 files changed, 229 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_sn.go create mode 100644 internal/providers/terraform/ibm/en_subscription_sn_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_sn.go diff --git a/internal/providers/terraform/ibm/en_subscription_sn.go b/internal/providers/terraform/ibm/en_subscription_sn.go new file mode 100644 index 00000000000..6ca17aeac94 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_sn.go @@ -0,0 +1,42 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionSnRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_sn", + RFunc: newEnSubscriptionSn, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionSn(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionSn{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_sn_test.go b/internal/providers/terraform/ibm/en_subscription_sn_test.go new file mode 100644 index 00000000000..1c38d3549c7 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_sn_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionSn(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_sn_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 81bddfaea80..d784b5e4d7c 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -41,6 +41,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionMsteamsRegistryItem(), getEnSubscriptionPagerdutyRegistryItem(), getEnSubscriptionWebhookRegistryItem(), + getEnSubscriptionSnRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden new file mode 100644 index 00000000000..9c872e82ebc --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_sn.subscription_sn_lite + └─ Plan lite not found 1 $0.00 + + ibm_en_subscription_sn.subscription_sn_standard + └─ Outbound ServiceNow HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_sn.subscription_sn_standard_no_usage + └─ Outbound ServiceNow HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.tf new file mode 100644 index 00000000000..6dc7064d5bf --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_sn" "subscription_sn_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "ServiceNow Subscription" + description = "ServiceNow Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_sn" "subscription_sn_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "ServiceNow Subscription" + description = "ServiceNow Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_sn" "subscription_sn_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "ServiceNow Subscription" + description = "ServiceNow Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml new file mode 100644 index 00000000000..459f3d6c986 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_sn.subscription_sn_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_sn.subscription_sn_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_sn.go b/internal/resources/ibm/en_subscription_sn.go new file mode 100644 index 00000000000..7a0127ba679 --- /dev/null +++ b/internal/resources/ibm/en_subscription_sn.go @@ -0,0 +1,96 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionSn struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionSn struct { + Address string + Region string + Name string + Plan string + EnSubscriptionServiceNow_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionSnUsageSchema defines a list which represents the usage schema of EnSubscriptionSn. +var EnSubscriptionSnUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionSn. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionSn. +func (r *EnSubscriptionSn) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionSn struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionSn) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionServiceNowOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionSnUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionServiceNowOutboundHTTPMessagesCostComponent(r *EnSubscriptionSn) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound ServiceNow HTTP Messages" + component_unit := "Messages" + + if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionServiceNow_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionServiceNow_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 3c95b3ed683b4e4fe78c03e7d969857be980f4de Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:30:47 -0500 Subject: [PATCH 43/55] Add support for subscriptions in Code Engine --- .../terraform/ibm/en_subscription_ce.go | 42 ++++++++ .../terraform/ibm/en_subscription_ce_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_ce_test.golden | 22 +++++ .../en_subscription_ce_test.tf | 46 +++++++++ .../en_subscription_ce_test.usage.yml | 6 ++ internal/resources/ibm/en_subscription_ce.go | 99 +++++++++++++++++++ 7 files changed, 232 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_ce.go create mode 100644 internal/providers/terraform/ibm/en_subscription_ce_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_ce.go diff --git a/internal/providers/terraform/ibm/en_subscription_ce.go b/internal/providers/terraform/ibm/en_subscription_ce.go new file mode 100644 index 00000000000..acb709acd49 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_ce.go @@ -0,0 +1,42 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionCeRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_ce", + RFunc: newEnSubscriptionCe, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionCe(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionCe{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_ce_test.go b/internal/providers/terraform/ibm/en_subscription_ce_test.go new file mode 100644 index 00000000000..98d393186e5 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_ce_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionCe(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_ce_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index d784b5e4d7c..88175a087ae 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -42,6 +42,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionPagerdutyRegistryItem(), getEnSubscriptionWebhookRegistryItem(), getEnSubscriptionSnRegistryItem(), + getEnSubscriptionCeRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden new file mode 100644 index 00000000000..ebad90170ad --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_ce.subscription_ce_lite + └─ Plan lite not found 1 $0.00 + + ibm_en_subscription_ce.subscription_ce_standard + └─ Outbound Code Engine HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_ce.subscription_ce_standard_no_usage + └─ Outbound Code Engine HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.tf new file mode 100644 index 00000000000..adbdb626664 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_ce" "subscription_ce_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Code Engine Subscription" + description = "Code Engine Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_ce" "subscription_ce_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Code Engine Subscription" + description = "Code Engine Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_ce" "subscription_ce_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Code Engine Subscription" + description = "Code Engine Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml new file mode 100644 index 00000000000..b2e416be36c --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_ce.subscription_ce_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_ce.subscription_ce_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_ce.go b/internal/resources/ibm/en_subscription_ce.go new file mode 100644 index 00000000000..ef0eb0c8560 --- /dev/null +++ b/internal/resources/ibm/en_subscription_ce.go @@ -0,0 +1,99 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionCe struct represents . +// +// +// +// Resource information: https://cloud.ibm.com// +// Pricing information: https://cloud.ibm.com// +type EnSubscriptionCe struct { + Address string + Region string + Name string + Plan string + EnSubscriptionCodeEngine_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionCeUsageSchema defines a list which represents the usage schema of EnSubscriptionCe. +var EnSubscriptionCeUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionCe. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionCe. +func (r *EnSubscriptionCe) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionCe struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionCe) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionCodeEngineOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionCeUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionCodeEngineOutboundHTTPMessagesCostComponent(r *EnSubscriptionCe) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Code Engine HTTP Messages" + component_unit := "Messages" + + if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionCodeEngine_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCodeEngine_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 15e77851aab6757526c4ec50c7d47540006a4024 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:34:28 -0500 Subject: [PATCH 44/55] Add support for subscriptions in COS --- .../terraform/ibm/en_subscription_cos.go | 43 +++++++++ .../terraform/ibm/en_subscription_cos_test.go | 16 ++++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_cos_test.golden | 22 +++++ .../en_subscription_cos_test.tf | 46 +++++++++ .../en_subscription_cos_test.usage.yml | 6 ++ internal/resources/ibm/en_subscription_cos.go | 96 +++++++++++++++++++ 7 files changed, 230 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_cos.go create mode 100644 internal/providers/terraform/ibm/en_subscription_cos_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_cos.go diff --git a/internal/providers/terraform/ibm/en_subscription_cos.go b/internal/providers/terraform/ibm/en_subscription_cos.go new file mode 100644 index 00000000000..89dd6c1a225 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_cos.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionCosRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_cos", + RFunc: newEnSubscriptionCos, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionCos(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionCos{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_cos_test.go b/internal/providers/terraform/ibm/en_subscription_cos_test.go new file mode 100644 index 00000000000..c271ee6d95f --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_cos_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionCos(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_cos_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 88175a087ae..f1c21e654a8 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -43,6 +43,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionWebhookRegistryItem(), getEnSubscriptionSnRegistryItem(), getEnSubscriptionCeRegistryItem(), + getEnSubscriptionCosRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden new file mode 100644 index 00000000000..224b9606822 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_cos.subscription_cos_lite + └─ Plan lite not found 1 $0.00 + + ibm_en_subscription_cos.subscription_cos_standard + └─ Outbound Cloud Object Storage HTTP Messages (Standard plan) 1,000,000 Messages $1.08 + + ibm_en_subscription_cos.subscription_cos_standard_no_usage + └─ Outbound Cloud Object Storage HTTP Messages (Standard plan) Monthly cost depends on usage: $0.00000108 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $1.08 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.tf new file mode 100644 index 00000000000..20b229991d8 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_cos" "subscription_cos_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Cloud Object Storage Subscription" + description = "Cloud Object Storage Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_cos" "subscription_cos_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Cloud Object Storage Subscription" + description = "Cloud Object Storage Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_cos" "subscription_cos_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Cloud Object Storage Subscription" + description = "Cloud Object Storage Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml new file mode 100644 index 00000000000..2b6051f2f2f --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_cos.subscription_cos_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + ibm_en_subscription_cos.subscription_cos_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_cos.go b/internal/resources/ibm/en_subscription_cos.go new file mode 100644 index 00000000000..b44d3c16b1c --- /dev/null +++ b/internal/resources/ibm/en_subscription_cos.go @@ -0,0 +1,96 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionCos struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionCos struct { + Address string + Region string + Name string + Plan string + EnSubscriptionCOS_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` +} + +// EnSubscriptionCosUsageSchema defines a list which represents the usage schema of EnSubscriptionCos. +var EnSubscriptionCosUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionCos. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionCos. +func (r *EnSubscriptionCos) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionCos struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionCos) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionCOSOutboundHTTPMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionCosUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionCOSOutboundHTTPMessagesCostComponent(r *EnSubscriptionCos) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound Cloud Object Storage HTTP Messages" + component_unit := "Messages" + + if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionCOS_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCOS_OutboundHTTPMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From ef8b9832b05813f0a100faf441b275669411348f Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 07:43:18 -0500 Subject: [PATCH 45/55] Add support for SMS subscriptions --- .../terraform/ibm/en_subscription_sms.go | 43 +++++++ .../terraform/ibm/en_subscription_sms_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_sms_test.golden | 22 ++++ .../en_subscription_sms_test.tf | 46 +++++++ .../en_subscription_sms_test.usage.yml | 6 + internal/resources/ibm/en_subscription_sms.go | 114 ++++++++++++++++++ 7 files changed, 248 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_sms.go create mode 100644 internal/providers/terraform/ibm/en_subscription_sms_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_sms.go diff --git a/internal/providers/terraform/ibm/en_subscription_sms.go b/internal/providers/terraform/ibm/en_subscription_sms.go new file mode 100644 index 00000000000..2cb4823e24c --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_sms.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionSmsRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_sms", + RFunc: newEnSubscriptionSms, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionSms(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionSms{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_sms_test.go b/internal/providers/terraform/ibm/en_subscription_sms_test.go new file mode 100644 index 00000000000..ca9d071c9e8 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_sms_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionSms(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_sms_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index f1c21e654a8..faeea3e3169 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -44,6 +44,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionSnRegistryItem(), getEnSubscriptionCeRegistryItem(), getEnSubscriptionCosRegistryItem(), + getEnSubscriptionSmsRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden new file mode 100644 index 00000000000..d729398f211 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_sms.subscription_sms_lite + └─ Outbound IBM Cloud SMS Message Units (Lite plan) (Max. 20) 20 Message Units $0.00 + + ibm_en_subscription_sms.subscription_sms_standard + └─ Outbound IBM Cloud SMS Message Units (Standard plan) 1,000 Message Units $16.15 + + ibm_en_subscription_sms.subscription_sms_standard_no_usage + └─ Outbound IBM Cloud SMS Message Units (Standard plan) Monthly cost depends on usage: $0.01615 per Message Units + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $16.15 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.tf new file mode 100644 index 00000000000..79f15b6c9d6 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_sms" "subscription_sms_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "SMS Subscription" + description = "SMS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_sms" "subscription_sms_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "SMS Subscription" + description = "SMS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_sms" "subscription_sms_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "SMS Subscription" + description = "SMS Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml new file mode 100644 index 00000000000..5b415500401 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_sms.subscription_sms_lite: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 + ibm_en_subscription_sms.subscription_sms_standard: + event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 diff --git a/internal/resources/ibm/en_subscription_sms.go b/internal/resources/ibm/en_subscription_sms.go new file mode 100644 index 00000000000..0d5d67aa7a9 --- /dev/null +++ b/internal/resources/ibm/en_subscription_sms.go @@ -0,0 +1,114 @@ +package ibm + +import ( + "fmt" + "math" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionSms struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionSms struct { + Address string + Region string + Name string + Plan string + EnSubscriptionSMS_OutboundSMSMessageUnits *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` +} + +// EnSubscriptionSmsUsageSchema defines a list which represents the usage schema of EnSubscriptionSms. +var EnSubscriptionSmsUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionSms. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionSms. +func (r *EnSubscriptionSms) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionSms struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionSms) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionSmsUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r *EnSubscriptionSms) *schema.CostComponent { + var costComponent schema.CostComponent + component_name := "Outbound IBM Cloud SMS Message Units" + component_unit := "Message Units" + + if r.Plan == "lite" { + + quantity := math.Min(float64(*r.EnSubscriptionSMS_OutboundSMSMessageUnits), float64(20)) + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan) (Max. 20)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromFloat(quantity)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSMS_OutboundSMSMessageUnits != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSMS_OutboundSMSMessageUnits)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From dd4d57446c7a2f7ae610d907b4e07c9ccaada128 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:08:11 -0500 Subject: [PATCH 46/55] Add more usage for SMS subcription --- .../en_subscription_sms_test.golden | 11 +- .../en_subscription_sms_test.usage.yml | 2 + internal/resources/ibm/en_subscription_sms.go | 151 ++++++++++++++++-- 3 files changed, 151 insertions(+), 13 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden index d729398f211..4ebd4f515d8 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden @@ -2,13 +2,16 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_sms.subscription_sms_lite - └─ Outbound IBM Cloud SMS Message Units (Lite plan) (Max. 20) 20 Message Units $0.00 + ├─ Outbound IBM Cloud SMS Message Units (Lite plan) (Max. 20) 20 Message Units $0.00 + └─ SMS Number Setup Resource Units (Lite plan) 1 Resource Units $0.00 ibm_en_subscription_sms.subscription_sms_standard - └─ Outbound IBM Cloud SMS Message Units (Standard plan) 1,000 Message Units $16.15 + ├─ Outbound IBM Cloud SMS Message Units (Standard plan) 1,000 Message Units $16.15 + └─ SMS Number Setup Resource Units 1 Resource Units $1.00 ibm_en_subscription_sms.subscription_sms_standard_no_usage - └─ Outbound IBM Cloud SMS Message Units (Standard plan) Monthly cost depends on usage: $0.01615 per Message Units + ├─ Outbound IBM Cloud SMS Message Units (Standard plan) Monthly cost depends on usage: $0.01615 per Message Units + └─ SMS Number Setup Resource Units 1 Resource Units $1.00 ibm_resource_instance.event_notifications["lite"] └─ Lite Plan 1 Instance $0.00 @@ -16,7 +19,7 @@ ibm_resource_instance.event_notifications["standard"] └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - OVERALL TOTAL $16.15 + OVERALL TOTAL $18.15 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml index 5b415500401..0927382a2c2 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml @@ -2,5 +2,7 @@ version: 0.1 resource_usage: ibm_en_subscription_sms.subscription_sms_lite: event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 + event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 ibm_en_subscription_sms.subscription_sms_standard: event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 + event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 \ No newline at end of file diff --git a/internal/resources/ibm/en_subscription_sms.go b/internal/resources/ibm/en_subscription_sms.go index 0d5d67aa7a9..be221734653 100644 --- a/internal/resources/ibm/en_subscription_sms.go +++ b/internal/resources/ibm/en_subscription_sms.go @@ -14,16 +14,20 @@ import ( // Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about // Pricing information: https://cloud.ibm.com/catalog/services/event-notifications type EnSubscriptionSms struct { - Address string - Region string - Name string - Plan string - EnSubscriptionSMS_OutboundSMSMessageUnits *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` + Address string + Region string + Name string + Plan string + EnSubscriptionSMS_NumberResourceUnits *float64 `infracost_usage:"event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` + EnSubscriptionSMS_NumberSetupResourceUnits *float64 `infracost_usage:"event-notifications_notifications_RESOURCE_UNITS_NUMBER_SETUP"` + EnSubscriptionSMS_OutboundMessageUnits *float64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` } // EnSubscriptionSmsUsageSchema defines a list which represents the usage schema of EnSubscriptionSms. var EnSubscriptionSmsUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionSms. @@ -38,6 +42,7 @@ func (r *EnSubscriptionSms) PopulateUsage(u *schema.UsageData) { func (r *EnSubscriptionSms) BuildResource() *schema.Resource { costComponents := []*schema.CostComponent{ EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r), + EnSubscriptionSMSNumberSetupResourceUnitsCostComponent(r), } return &schema.Resource{ @@ -47,6 +52,134 @@ func (r *EnSubscriptionSms) BuildResource() *schema.Resource { } } +func EnSubscriptionSMSNumberSetupResourceUnitsCostComponent(r *EnSubscriptionSms) *schema.CostComponent { + + component_unit := "Resource Units" + component_name := "SMS Number Setup Resource Units" + + var costComponent schema.CostComponent + + if r.Plan == "lite" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSMS_NumberSetupResourceUnits != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EnSubscriptionSMS_NumberSetupResourceUnits)) + } else { + quantity = decimalPtr(decimal.NewFromInt(1)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: strPtr("standard")}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSMS_NumberSetupResourceUnits != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EnSubscriptionSMS_NumberSetupResourceUnits)) + } else { + quantity = decimalPtr(decimal.NewFromInt(1)) + } + + costComponent = schema.CostComponent{ + Name: component_name, + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent +} + +func EnSubscriptionSMSNumberResourceUnitsCostComponent(r *EnSubscriptionSms) *schema.CostComponent { + + var costComponent schema.CostComponent + + if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionSMS_NumberSetupResourceUnits != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EnSubscriptionSMS_NumberSetupResourceUnits)) + } + + costComponent = schema.CostComponent{ + Name: "SMS Number Use Resource Units", + Unit: "Resource Units", + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("RESOURCE_UNITS_NUMBER_MONTHLY"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + return &costComponent + +} + func EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r *EnSubscriptionSms) *schema.CostComponent { var costComponent schema.CostComponent component_name := "Outbound IBM Cloud SMS Message Units" @@ -54,7 +187,7 @@ func EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r *EnSubscriptionSms) if r.Plan == "lite" { - quantity := math.Min(float64(*r.EnSubscriptionSMS_OutboundSMSMessageUnits), float64(20)) + quantity := math.Min(float64(*r.EnSubscriptionSMS_OutboundMessageUnits), float64(20)) costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Lite plan) (Max. 20)", component_name), @@ -72,8 +205,8 @@ func EnSubscriptionSMSOutboundSMSMessageUnitsCostComponent(r *EnSubscriptionSms) } else if r.Plan == "standard" { var quantity *decimal.Decimal - if r.EnSubscriptionSMS_OutboundSMSMessageUnits != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSMS_OutboundSMSMessageUnits)) + if r.EnSubscriptionSMS_OutboundMessageUnits != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EnSubscriptionSMS_OutboundMessageUnits)) } costComponent = schema.CostComponent{ From 059cb40d3e23e579edf342b53e9bf109fe99b2a5 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:10:05 -0500 Subject: [PATCH 47/55] Fix typo in variable name --- .../en_subscription_ce_test.usage.yml | 4 ++-- .../en_subscription_cos_test.usage.yml | 4 ++-- .../en_subscription_msteams_test.usage.yml | 4 ++-- .../en_subscription_pagerduty_test.usage.yml | 4 ++-- .../en_subscription_slack_test.usage.yml | 4 ++-- .../en_subscription_sms_test.usage.yml | 8 ++++---- .../en_subscription_sn_test.usage.yml | 4 ++-- .../en_subscription_webhook_test.usage.yml | 4 ++-- internal/resources/ibm/en_subscription_ce.go | 4 ++-- internal/resources/ibm/en_subscription_cos.go | 4 ++-- internal/resources/ibm/en_subscription_msteams.go | 4 ++-- internal/resources/ibm/en_subscription_pagerduty.go | 4 ++-- internal/resources/ibm/en_subscription_slack.go | 4 ++-- internal/resources/ibm/en_subscription_sms.go | 12 ++++++------ internal/resources/ibm/en_subscription_sn.go | 4 ++-- internal/resources/ibm/en_subscription_webhook.go | 4 ++-- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml index b2e416be36c..85a4b3b58fc 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_ce.subscription_ce_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_ce.subscription_ce_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml index 2b6051f2f2f..4da30965882 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_cos.subscription_cos_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_cos.subscription_cos_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml index a2e6238f04b..dc9fcfa2b0c 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_msteams.subscription_msteams_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_msteams.subscription_msteams_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml index 9b89719ecb3..e85ffc127ab 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_pagerduty.subscription_pagerduty_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_pagerduty.subscription_pagerduty_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml index e8d1cc0df58..d852e08296c 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_slack.subscription_slack_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_slack.subscription_slack_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml index 0927382a2c2..16ac13dea71 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.usage.yml @@ -1,8 +1,8 @@ version: 0.1 resource_usage: ibm_en_subscription_sms.subscription_sms_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 - event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 ibm_en_subscription_sms.subscription_sms_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 - event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 \ No newline at end of file + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 1000 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1000 \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml index 459f3d6c986..a8a3dbc5cb8 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_sn.subscription_sn_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_sn.subscription_sn_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml index d4fb467f7f4..2541d2023bb 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml +++ b/internal/providers/terraform/ibm/testdata/en_subscription_webhook_test/en_subscription_webhook_test.usage.yml @@ -1,6 +1,6 @@ version: 0.1 resource_usage: ibm_en_subscription_webhook.subscription_webhook_lite: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 ibm_en_subscription_webhook.subscription_webhook_standard: - event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 1000000 diff --git a/internal/resources/ibm/en_subscription_ce.go b/internal/resources/ibm/en_subscription_ce.go index ef0eb0c8560..e40369451b5 100644 --- a/internal/resources/ibm/en_subscription_ce.go +++ b/internal/resources/ibm/en_subscription_ce.go @@ -20,12 +20,12 @@ type EnSubscriptionCe struct { Region string Name string Plan string - EnSubscriptionCodeEngine_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionCodeEngine_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionCeUsageSchema defines a list which represents the usage schema of EnSubscriptionCe. var EnSubscriptionCeUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionCe. diff --git a/internal/resources/ibm/en_subscription_cos.go b/internal/resources/ibm/en_subscription_cos.go index b44d3c16b1c..c51daeef7ac 100644 --- a/internal/resources/ibm/en_subscription_cos.go +++ b/internal/resources/ibm/en_subscription_cos.go @@ -17,12 +17,12 @@ type EnSubscriptionCos struct { Region string Name string Plan string - EnSubscriptionCOS_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionCOS_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionCosUsageSchema defines a list which represents the usage schema of EnSubscriptionCos. var EnSubscriptionCosUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionCos. diff --git a/internal/resources/ibm/en_subscription_msteams.go b/internal/resources/ibm/en_subscription_msteams.go index 36dc21b9c4e..219835fc541 100644 --- a/internal/resources/ibm/en_subscription_msteams.go +++ b/internal/resources/ibm/en_subscription_msteams.go @@ -20,12 +20,12 @@ type EnSubscriptionMsteams struct { Region string Name string Plan string - EnSubscriptionMsteams_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionMsteams_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionMsteamsUsageSchema defines a list which represents the usage schema of EnSubscriptionMsteams. var EnSubscriptionMsteamsUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionMsteams. diff --git a/internal/resources/ibm/en_subscription_pagerduty.go b/internal/resources/ibm/en_subscription_pagerduty.go index 57821f51832..5ff2b1f70c6 100644 --- a/internal/resources/ibm/en_subscription_pagerduty.go +++ b/internal/resources/ibm/en_subscription_pagerduty.go @@ -17,12 +17,12 @@ type EnSubscriptionPagerduty struct { Region string Name string Plan string - EnSubscriptionPagerDuty_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionPagerDuty_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionPagerdutyUsageSchema defines a list which represents the usage schema of EnSubscriptionPagerduty. var EnSubscriptionPagerdutyUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionPagerduty. diff --git a/internal/resources/ibm/en_subscription_slack.go b/internal/resources/ibm/en_subscription_slack.go index 933e1bef097..6b638bfc283 100644 --- a/internal/resources/ibm/en_subscription_slack.go +++ b/internal/resources/ibm/en_subscription_slack.go @@ -17,12 +17,12 @@ type EnSubscriptionSlack struct { Region string Name string Plan string - EnSubscriptionSlack_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionSlack_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionSlackUsageSchema defines a list which represents the usage schema of EnSubscriptionSlack. var EnSubscriptionSlackUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionSlack. diff --git a/internal/resources/ibm/en_subscription_sms.go b/internal/resources/ibm/en_subscription_sms.go index be221734653..bafe13452f4 100644 --- a/internal/resources/ibm/en_subscription_sms.go +++ b/internal/resources/ibm/en_subscription_sms.go @@ -18,16 +18,16 @@ type EnSubscriptionSms struct { Region string Name string Plan string - EnSubscriptionSMS_NumberResourceUnits *float64 `infracost_usage:"event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` - EnSubscriptionSMS_NumberSetupResourceUnits *float64 `infracost_usage:"event-notifications_notifications_RESOURCE_UNITS_NUMBER_SETUP"` - EnSubscriptionSMS_OutboundMessageUnits *float64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` + EnSubscriptionSMS_NumberResourceUnits *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` + EnSubscriptionSMS_NumberSetupResourceUnits *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` + EnSubscriptionSMS_OutboundMessageUnits *float64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` } // EnSubscriptionSmsUsageSchema defines a list which represents the usage schema of EnSubscriptionSms. var EnSubscriptionSmsUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "event-notifications_notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, - {Key: "event-notifications_notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, + {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionSms. diff --git a/internal/resources/ibm/en_subscription_sn.go b/internal/resources/ibm/en_subscription_sn.go index 7a0127ba679..f0b7bd1a7ac 100644 --- a/internal/resources/ibm/en_subscription_sn.go +++ b/internal/resources/ibm/en_subscription_sn.go @@ -17,12 +17,12 @@ type EnSubscriptionSn struct { Region string Name string Plan string - EnSubscriptionServiceNow_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionServiceNow_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionSnUsageSchema defines a list which represents the usage schema of EnSubscriptionSn. var EnSubscriptionSnUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionSn. diff --git a/internal/resources/ibm/en_subscription_webhook.go b/internal/resources/ibm/en_subscription_webhook.go index 7948b522cda..821d7c9184c 100644 --- a/internal/resources/ibm/en_subscription_webhook.go +++ b/internal/resources/ibm/en_subscription_webhook.go @@ -18,12 +18,12 @@ type EnSubscriptionWebhook struct { Region string Name string Plan string - EnSubscriptionWebhook_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` + EnSubscriptionWebhook_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` } // EnSubscriptionWebhookUsageSchema defines a list which represents the usage schema of EnSubscriptionWebhook. var EnSubscriptionWebhookUsageSchema = []*schema.UsageItem{ - {Key: "event-notifications_notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, } // PopulateUsage parses the u schema.UsageData into the EnSubscriptionWebhook. From 7b69347a4c7698fff5aa22b9b9fec6b46586f8f4 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:20:31 -0500 Subject: [PATCH 48/55] Add explicit mention of lite plans --- .../en_subscription_ce_test.golden | 2 +- .../en_subscription_cos_test.golden | 2 +- .../en_subscription_msteams_test.golden | 2 +- .../en_subscription_pagerduty_test.golden | 2 +- .../en_subscription_slack_test.golden | 2 +- .../en_subscription_sn_test.golden | 2 +- internal/resources/ibm/en_subscription_ce.go | 34 +++++++++++++------ internal/resources/ibm/en_subscription_cos.go | 24 ++++++++++--- .../resources/ibm/en_subscription_msteams.go | 34 +++++++++++++------ .../ibm/en_subscription_pagerduty.go | 25 +++++++++++--- .../resources/ibm/en_subscription_slack.go | 25 +++++++++++--- internal/resources/ibm/en_subscription_sn.go | 25 +++++++++++--- 12 files changed, 137 insertions(+), 42 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden index ebad90170ad..79314806482 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_ce_test/en_subscription_ce_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_ce.subscription_ce_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound Code Engine HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_ce.subscription_ce_standard └─ Outbound Code Engine HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden index 224b9606822..a7129d014f5 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_cos_test/en_subscription_cos_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_cos.subscription_cos_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound Cloud Object Storage HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_cos.subscription_cos_standard └─ Outbound Cloud Object Storage HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden index 7e0b8399aa8..147f283339b 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_msteams_test/en_subscription_msteams_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_msteams.subscription_msteams_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound Microsoft Teams HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_msteams.subscription_msteams_standard └─ Outbound Microsoft Teams HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden index 07623ac9b3b..5c6278ae862 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_pagerduty_test/en_subscription_pagerduty_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_pagerduty.subscription_pagerduty_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound PagerDuty HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_pagerduty.subscription_pagerduty_standard └─ Outbound PagerDuty HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden index b7fbbfd7a45..c4cdea3a294 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_slack_test/en_subscription_slack_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_slack.subscription_slack_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound Slack HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_slack.subscription_slack_standard └─ Outbound Slack HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden index 9c872e82ebc..de0819dce44 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sn_test/en_subscription_sn_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_sn.subscription_sn_lite - └─ Plan lite not found 1 $0.00 + └─ Outbound ServiceNow HTTP Messages (Lite plan) 1,000,000 Messages $0.00 ibm_en_subscription_sn.subscription_sn_standard └─ Outbound ServiceNow HTTP Messages (Standard plan) 1,000,000 Messages $1.08 diff --git a/internal/resources/ibm/en_subscription_ce.go b/internal/resources/ibm/en_subscription_ce.go index e40369451b5..0b5c483b461 100644 --- a/internal/resources/ibm/en_subscription_ce.go +++ b/internal/resources/ibm/en_subscription_ce.go @@ -8,13 +8,10 @@ import ( "github.com/shopspring/decimal" ) -// EnSubscriptionCe struct represents . +// EnSubscriptionCe struct // -// -// -// Resource information: https://cloud.ibm.com// -// Pricing information: https://cloud.ibm.com// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications type EnSubscriptionCe struct { Address string Region string @@ -50,16 +47,33 @@ func (r *EnSubscriptionCe) BuildResource() *schema.Resource { } func EnSubscriptionCodeEngineOutboundHTTPMessagesCostComponent(r *EnSubscriptionCe) *schema.CostComponent { + var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound Code Engine HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionCodeEngine_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCodeEngine_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionCodeEngine_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCodeEngine_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), diff --git a/internal/resources/ibm/en_subscription_cos.go b/internal/resources/ibm/en_subscription_cos.go index c51daeef7ac..4c2087f3d3e 100644 --- a/internal/resources/ibm/en_subscription_cos.go +++ b/internal/resources/ibm/en_subscription_cos.go @@ -48,15 +48,31 @@ func (r *EnSubscriptionCos) BuildResource() *schema.Resource { func EnSubscriptionCOSOutboundHTTPMessagesCostComponent(r *EnSubscriptionCos) *schema.CostComponent { var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound Cloud Object Storage HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionCOS_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCOS_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionCOS_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionCOS_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), diff --git a/internal/resources/ibm/en_subscription_msteams.go b/internal/resources/ibm/en_subscription_msteams.go index 219835fc541..0b33e936aba 100644 --- a/internal/resources/ibm/en_subscription_msteams.go +++ b/internal/resources/ibm/en_subscription_msteams.go @@ -8,13 +8,10 @@ import ( "github.com/shopspring/decimal" ) -// EnSubscriptionMsteams struct represents . +// EnSubscriptionMsteams struct // -// -// -// Resource information: https://cloud.ibm.com// -// Pricing information: https://cloud.ibm.com// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications type EnSubscriptionMsteams struct { Address string Region string @@ -50,16 +47,33 @@ func (r *EnSubscriptionMsteams) BuildResource() *schema.Resource { } func EnSubscriptionMsteamsOutboundHTTPMessagesCostComponent(r *EnSubscriptionMsteams) *schema.CostComponent { + var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound Microsoft Teams HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionMsteams_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionMsteams_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionMsteams_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionMsteams_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), diff --git a/internal/resources/ibm/en_subscription_pagerduty.go b/internal/resources/ibm/en_subscription_pagerduty.go index 5ff2b1f70c6..f8131172a82 100644 --- a/internal/resources/ibm/en_subscription_pagerduty.go +++ b/internal/resources/ibm/en_subscription_pagerduty.go @@ -47,16 +47,33 @@ func (r *EnSubscriptionPagerduty) BuildResource() *schema.Resource { } func EnSubscriptionPagerDutyOutboundHTTPMessagesCostComponent(r *EnSubscriptionPagerduty) *schema.CostComponent { + var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound PagerDuty HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionPagerDuty_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionPagerDuty_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionPagerDuty_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionPagerDuty_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), diff --git a/internal/resources/ibm/en_subscription_slack.go b/internal/resources/ibm/en_subscription_slack.go index 6b638bfc283..9566e952093 100644 --- a/internal/resources/ibm/en_subscription_slack.go +++ b/internal/resources/ibm/en_subscription_slack.go @@ -47,16 +47,33 @@ func (r *EnSubscriptionSlack) BuildResource() *schema.Resource { } func EnSubscriptionSlackOutboundHTTPMessagesCostComponent(r *EnSubscriptionSlack) *schema.CostComponent { + var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound Slack HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionSlack_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSlack_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionSlack_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionSlack_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), diff --git a/internal/resources/ibm/en_subscription_sn.go b/internal/resources/ibm/en_subscription_sn.go index f0b7bd1a7ac..34e677e15ac 100644 --- a/internal/resources/ibm/en_subscription_sn.go +++ b/internal/resources/ibm/en_subscription_sn.go @@ -47,16 +47,33 @@ func (r *EnSubscriptionSn) BuildResource() *schema.Resource { } func EnSubscriptionServiceNowOutboundHTTPMessagesCostComponent(r *EnSubscriptionSn) *schema.CostComponent { + var costComponent schema.CostComponent + var quantity *decimal.Decimal + component_name := "Outbound ServiceNow HTTP Messages" component_unit := "Messages" - if r.Plan == "standard" { + if r.EnSubscriptionServiceNow_OutboundHTTPMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionServiceNow_OutboundHTTPMessages)) + } + + if r.Plan == "lite" { - var quantity *decimal.Decimal - if r.EnSubscriptionServiceNow_OutboundHTTPMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionServiceNow_OutboundHTTPMessages)) + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), From 0041b8bc539269b79675adf1d475e10b57f66295 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:39:52 -0500 Subject: [PATCH 49/55] Add support for IBM e-mail subscriptions --- .../terraform/ibm/en_subscription_email.go | 43 +++++++ .../ibm/en_subscription_email_test.go | 16 +++ internal/providers/terraform/ibm/registry.go | 1 + .../en_subscription_email_test.golden | 22 ++++ .../en_subscription_email_test.tf | 46 +++++++ .../en_subscription_email_test.usage.yml | 6 + .../resources/ibm/en_subscription_email.go | 116 ++++++++++++++++++ 7 files changed, 250 insertions(+) create mode 100644 internal/providers/terraform/ibm/en_subscription_email.go create mode 100644 internal/providers/terraform/ibm/en_subscription_email_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_email.go diff --git a/internal/providers/terraform/ibm/en_subscription_email.go b/internal/providers/terraform/ibm/en_subscription_email.go new file mode 100644 index 00000000000..f2b14101e0e --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_email.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionEmailRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_email", + RFunc: newEnSubscriptionEmail, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionEmail(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionEmail{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_email_test.go b/internal/providers/terraform/ibm/en_subscription_email_test.go new file mode 100644 index 00000000000..73503c907dc --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_email_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionEmail(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_email_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index faeea3e3169..e39eb46d072 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -45,6 +45,7 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnSubscriptionCeRegistryItem(), getEnSubscriptionCosRegistryItem(), getEnSubscriptionSmsRegistryItem(), + getEnSubscriptionEmailRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.golden new file mode 100644 index 00000000000..1590dbe12d6 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.golden @@ -0,0 +1,22 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_email.subscription_email_lite + └─ Outbound E-mail Messages (Lite plan) (Max. 20) 20 Messages $0.00 + + ibm_en_subscription_email.subscription_email_standard + └─ Outbound E-mail Messages (Standard plan) 100,000 Messages $4.31 + + ibm_en_subscription_email.subscription_email_standard_no_usage + └─ Outbound E-mail Messages (Standard plan) Monthly cost depends on usage: $0.0000431 per Messages + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $4.31 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.tf new file mode 100644 index 00000000000..524d6151be9 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_email" "subscription_email_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "E-mail Subscription" + description = "E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_email" "subscription_email_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "E-mail Subscription" + description = "E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_email" "subscription_email_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "E-mail Subscription" + description = "E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.usage.yml new file mode 100644 index 00000000000..44acf4d0a51 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_email_test/en_subscription_email_test.usage.yml @@ -0,0 +1,6 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_email.subscription_email_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 100000 + ibm_en_subscription_email.subscription_email_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 100000 diff --git a/internal/resources/ibm/en_subscription_email.go b/internal/resources/ibm/en_subscription_email.go new file mode 100644 index 00000000000..84c2153892d --- /dev/null +++ b/internal/resources/ibm/en_subscription_email.go @@ -0,0 +1,116 @@ +package ibm + +import ( + "fmt" + "math" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionEmail struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionEmail struct { + Address string + Region string + Name string + Plan string + EnSubscriptionEmail_OutboundEmailMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` +} + +// EnSubscriptionEmailUsageSchema defines a list which represents the usage schema of EnSubscriptionEmail. +var EnSubscriptionEmailUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionEmail. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionEmail. +func (r *EnSubscriptionEmail) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionEmail struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionEmail) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionEmailOutboundMessagesCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionEmailUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionEmailOutboundMessagesCostComponent(r *EnSubscriptionEmail) *schema.CostComponent { + + var costComponent schema.CostComponent + + component_name := "Outbound E-mail Messages" + component_unit := "Messages" + + if r.Plan == "lite" { + + quantity := decimalPtr(decimal.NewFromFloat(math.Min(float64(*r.EnSubscriptionEmail_OutboundEmailMessages), float64(20)))) + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan) (Max. 20)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + var quantity *decimal.Decimal + if r.EnSubscriptionEmail_OutboundEmailMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionEmail_OutboundEmailMessages)) + } + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_EMAILS"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 986d4ed1a5b0098b20f067bb3e9bcb1a38f29322 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:40:24 -0500 Subject: [PATCH 50/55] Remove unused comments --- internal/resources/ibm/resource_instance.go | 16 -- .../resource_instance_event-notifications.go | 232 ------------------ 2 files changed, 248 deletions(-) diff --git a/internal/resources/ibm/resource_instance.go b/internal/resources/ibm/resource_instance.go index aad91e6e3f0..ffa36d732eb 100644 --- a/internal/resources/ibm/resource_instance.go +++ b/internal/resources/ibm/resource_instance.go @@ -110,14 +110,6 @@ type ResourceInstance struct { EventStreams_Terabytes *float64 `infracost_usage:"messagehub_qty_terabytes"` // Event Notifications EventNotifications_InboundIngestedEvents *float64 `infracost_usage:"event-notifications_MILLION_INGESTED_EVENTS"` - // EventNotifications_OutboundCustomDomainEmailGBsTransmitted *float64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` - // EventNotifications_OutboundCustomDomainEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` - // EventNotifications_OutboundEmails *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS"` - // EventNotifications_OutboundHTTPMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP"` - // EventNotifications_OutboundPushMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH"` - // EventNotifications_OutboundSMSMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"` - // EventNotifications_ResourceUnitsMonthly *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY"` - // EventNotifications_ResourceUnitsSetup *float64 `infracost_usage:"event-notifications_RESOURCE_UNITS_NUMBER_SETUP"` } type ResourceCostComponentsFunc func(*ResourceInstance) []*schema.CostComponent @@ -188,14 +180,6 @@ var ResourceInstanceUsageSchema = []*schema.UsageItem{ {Key: "messagehub_TERABYTE_HOURS", DefaultValue: 1, ValueType: schema.Float64}, {Key: "messagehub_qty_terabytes", DefaultValue: 1, ValueType: schema.Float64}, {Key: "event-notifications_MILLION_INGESTED_EVENTS", DefaultValue: 0, ValueType: schema.Float64}, - // {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Float64}, - // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, - // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS", DefaultValue: 0, ValueType: schema.Int64}, - // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP", DefaultValue: 0, ValueType: schema.Int64}, - // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH", DefaultValue: 0, ValueType: schema.Int64}, - // {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS", DefaultValue: 0, ValueType: schema.Int64}, - // {Key: "event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY", DefaultValue: 0, ValueType: schema.Float64}, - // {Key: "event-notifications_RESOURCE_UNITS_NUMBER_SETUP", DefaultValue: 0, ValueType: schema.Float64}, } var ResourceInstanceCostMap map[string]ResourceCostComponentsFunc = map[string]ResourceCostComponentsFunc{ diff --git a/internal/resources/ibm/resource_instance_event-notifications.go b/internal/resources/ibm/resource_instance_event-notifications.go index 75fae539d27..960e3b29209 100644 --- a/internal/resources/ibm/resource_instance_event-notifications.go +++ b/internal/resources/ibm/resource_instance_event-notifications.go @@ -33,14 +33,6 @@ func GetEventNotificationsCostComponents(r *ResourceInstance) []*schema.CostComp } else if r.Plan == EVENT_NOTIFICATIONS_STANDARD_PLAN_PROGRAMMATIC_NAME { return []*schema.CostComponent{ EventNotificationsInboundIngestedEventsCostComponent(r), - // EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r), - // EventNotificationsOutboundCustomDomainEmailsCostComponent(r), - // EventNotificationsOutboundEmailsCostComponent(r), - // EventNotificationsOutboundHTTPMessagesCostComponent(r), - // EventNotificationsOutboundPushMessagesCostComponent(r), - // EventNotificationsOutboundSMSMessagesCostComponent(r), - // EventNotificationsResourceUnitsMonthlyCostComponent(r), - // EventNotificationsResourceUnitsSetupCostComponent(r), } } else { costComponent := schema.CostComponent{ @@ -89,227 +81,3 @@ func EventNotificationsInboundIngestedEventsCostComponent(r *ResourceInstance) * } return &costComponent } - -// func EventNotificationsOutboundCustomDomainEmailGBsTransmittedCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted != nil { -// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_OutboundCustomDomainEmailGBsTransmitted)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound Custom Domain E-mail GB Transmitted", -// Unit: "GB", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"), -// }, -// } -// return &costComponent -// } - -// func EventNotificationsOutboundCustomDomainEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundCustomDomainEmails != nil { -// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundCustomDomainEmails)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound Custom Domain E-mails", -// Unit: "E-mails", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"), -// }, -// } -// return &costComponent -// } - -// func EventNotificationsOutboundEmailsCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundEmails != nil { -// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundEmails)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound E-mails", -// Unit: "E-mails", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_EMAILS"), -// }, -// } -// return &costComponent -// } - -// func EventNotificationsOutboundHTTPMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundHTTPMessages != nil { -// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundHTTPMessages)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound HTTP Messages", -// Unit: "Messages", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_HTTP"), -// }, -// } -// return &costComponent -// } - -// func EventNotificationsOutboundPushMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundPushMessages != nil { -// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundPushMessages)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound Push Messages", -// Unit: "Messages", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_PUSH"), -// }, -// } -// return &costComponent -// } - -// func EventNotificationsOutboundSMSMessagesCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_OutboundSMSMessages != nil { -// quantity = decimalPtr(decimal.NewFromInt(*r.EventNotifications_OutboundSMSMessages)) -// } - -// costComponent := schema.CostComponent{ -// Name: "Outbound SMS Messages", -// Unit: "Messages", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS"), -// }, -// } -// return &costComponent -// } - -// /* -// * D0HNPZX - IBM Cloud Event Notifications SMS number monthly fee unit Resource Unit Pay per Use -// * This part covers the monthly usage fee for a phone number. It recurs monthly. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. -// */ -// func EventNotificationsResourceUnitsMonthlyCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_ResourceUnitsMonthly != nil { -// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsMonthly)) -// } - -// costComponent := schema.CostComponent{ -// Name: "SMS Number Monthly Resource Units", -// Unit: "Resource Units", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("RESOURCE_UNITS_NUMBER_MONTHLY"), -// }, -// } -// return &costComponent -// } - -// /* -// * D0HNQZX - IBM Cloud Event Notifications SMS number setup fee unit Resource Unit Pay per Use. -// * This part covers any setup fee a phone number might have. It will be a one-time fee. The charge metric is 'resource unit'. Since every country and number type is a different price, the Event Notifications team will send over the proper number of units for the given use case. One unit = $1. -// */ -// func EventNotificationsResourceUnitsSetupCostComponent(r *ResourceInstance) *schema.CostComponent { - -// var quantity *decimal.Decimal -// if r.EventNotifications_ResourceUnitsSetup != nil { -// quantity = decimalPtr(decimal.NewFromFloat(*r.EventNotifications_ResourceUnitsSetup)) -// } - -// costComponent := schema.CostComponent{ -// Name: "SMS Number Setup Resource Units", -// Unit: "Resource Units", -// UnitMultiplier: decimal.NewFromInt(1), -// MonthlyQuantity: quantity, -// ProductFilter: &schema.ProductFilter{ -// VendorName: strPtr("ibm"), -// Region: strPtr(r.Location), -// Service: &r.Service, -// AttributeFilters: []*schema.AttributeFilter{ -// {Key: "planName", Value: &r.Plan}, -// }, -// }, -// PriceFilter: &schema.PriceFilter{ -// Unit: strPtr("RESOURCE_UNITS_NUMBER_SETUP"), -// }, -// } -// return &costComponent -// } From 58d6f4c68cda604fb2bcda828e786649023bfab4 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:52:20 -0500 Subject: [PATCH 51/55] Add support for custom domain email subscriptions --- .../ibm/en_subscription_custom_email.go | 43 +++++ .../ibm/en_subscription_custom_email_test.go | 16 ++ internal/providers/terraform/ibm/registry.go | 17 +- .../en_subscription_custom_email_test.golden | 25 +++ .../en_subscription_custom_email_test.tf | 46 +++++ ...n_subscription_custom_email_test.usage.yml | 8 + .../ibm/en_subscription_custom_email.go | 182 ++++++++++++++++++ 7 files changed, 329 insertions(+), 8 deletions(-) create mode 100644 internal/providers/terraform/ibm/en_subscription_custom_email.go create mode 100644 internal/providers/terraform/ibm/en_subscription_custom_email_test.go create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.tf create mode 100644 internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.usage.yml create mode 100644 internal/resources/ibm/en_subscription_custom_email.go diff --git a/internal/providers/terraform/ibm/en_subscription_custom_email.go b/internal/providers/terraform/ibm/en_subscription_custom_email.go new file mode 100644 index 00000000000..8a6c382e46d --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_custom_email.go @@ -0,0 +1,43 @@ +package ibm + +import ( + "github.com/infracost/infracost/internal/resources/ibm" + "github.com/infracost/infracost/internal/schema" +) + +func getEnSubscriptionCustomEmailRegistryItem() *schema.RegistryItem { + return &schema.RegistryItem{ + Name: "ibm_en_subscription_custom_email", + RFunc: newEnSubscriptionCustomEmail, + ReferenceAttributes: []string{"instance_guid"}, + } +} + +func newEnSubscriptionCustomEmail(d *schema.ResourceData, u *schema.UsageData) *schema.Resource { + + region := d.Get("region").String() + name := d.Get("name").String() + + var plan string + enReferenceAttributes := d.References("instance_guid") + if len(enReferenceAttributes) > 0 { + plan = enReferenceAttributes[0].Get("plan").String() + } + + r := &ibm.EnSubscriptionCustomEmail{ + Address: d.Address, + Region: region, + Name: name, + Plan: plan, + } + r.PopulateUsage(u) + + configuration := make(map[string]any) + configuration["name"] = name + configuration["plan"] = plan + configuration["region"] = region + + SetCatalogMetadata(d, d.Type, configuration) + + return r.BuildResource() +} diff --git a/internal/providers/terraform/ibm/en_subscription_custom_email_test.go b/internal/providers/terraform/ibm/en_subscription_custom_email_test.go new file mode 100644 index 00000000000..695b8aefc02 --- /dev/null +++ b/internal/providers/terraform/ibm/en_subscription_custom_email_test.go @@ -0,0 +1,16 @@ +package ibm_test + +import ( + "testing" + + "github.com/infracost/infracost/internal/providers/terraform/tftest" +) + +func TestEnSubscriptionCustomEmail(t *testing.T) { + t.Parallel() + if testing.Short() { + t.Skip("skipping test in short mode") + } + + tftest.GoldenFileResourceTests(t, "en_subscription_custom_email_test") +} diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index e39eb46d072..7bb1e02218d 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -31,21 +31,22 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ getEnDestinationIphoneosRegistryItem(), // iOS getEnDestinationRegistryItem(), // Android getEnDestinationSafariRegistryItem(), + getEnSubscriptionCeRegistryItem(), getEnSubscriptionChromeRegistryItem(), + getEnSubscriptionCosRegistryItem(), + getEnSubscriptionCustomEmailRegistryItem(), + getEnSubscriptionEmailRegistryItem(), getEnSubscriptionFirefoxRegistryItem(), getEnSubscriptionHuaweiRegistryItem(), getEnSubscriptionIphoneosRegistryItem(), // iOS - getEnSubscriptionRegistryItem(), // Android - getEnSubscriptionSafariRegistryItem(), - getEnSubscriptionSlackRegistryItem(), getEnSubscriptionMsteamsRegistryItem(), getEnSubscriptionPagerdutyRegistryItem(), - getEnSubscriptionWebhookRegistryItem(), - getEnSubscriptionSnRegistryItem(), - getEnSubscriptionCeRegistryItem(), - getEnSubscriptionCosRegistryItem(), + getEnSubscriptionRegistryItem(), // Android + getEnSubscriptionSafariRegistryItem(), + getEnSubscriptionSlackRegistryItem(), getEnSubscriptionSmsRegistryItem(), - getEnSubscriptionEmailRegistryItem(), + getEnSubscriptionSnRegistryItem(), + getEnSubscriptionWebhookRegistryItem(), } // FreeResources grouped alphabetically diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden new file mode 100644 index 00000000000..7b4a0c9986f --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden @@ -0,0 +1,25 @@ + + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_custom_email.subscription_custom_email_lite + ├─ Outbound Custom Domain E-mail Messages (Lite plan) 1,000 Messages $0.00 + └─ Outbound Transmitted E-mail Messages (Lite plan) 1 GB $0.00 + + ibm_en_subscription_custom_email.subscription_custom_email_standard + ├─ Outbound Custom Domain E-mail Messages (Standard plan) 1,000 Messages $0.15 + └─ Outbound Transmitted E-mail Messages (Standard plan) 1 GB $0.12 + + ibm_en_subscription_custom_email.subscription_custom_email_standard_no_usage + ├─ Outbound Custom Domain E-mail Messages (Standard plan) Monthly cost depends on usage: $0.00015 per Messages + └─ Outbound Transmitted E-mail Messages (Standard plan) Monthly cost depends on usage: $0.12 per GB + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $0.27 +────────────────────────────────── +5 cloud resources were detected: +∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.tf b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.tf new file mode 100644 index 00000000000..77874a43d4d --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.tf @@ -0,0 +1,46 @@ +terraform { + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + } + } +} + +locals { + event_notifications = { + plans = ["lite", "standard"], + } +} + +resource "ibm_resource_instance" "event_notifications" { + for_each = toset(local.event_notifications.plans) + name = "event-notifications-${each.value}" + location = "us-south" + plan = each.value + resource_group_id = "default" + service = "event-notifications" +} + +resource "ibm_en_subscription_custom_email" "subscription_custom_email_lite" { + instance_guid = ibm_resource_instance.event_notifications["lite"].guid + name = "Custom Domain E-mail Subscription" + description = "Custom Domain E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_custom_email" "subscription_custom_email_standard" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Custom Domain E-mail Subscription" + description = "Custom Domain E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} + +resource "ibm_en_subscription_custom_email" "subscription_custom_email_standard_no_usage" { + instance_guid = ibm_resource_instance.event_notifications["standard"].guid + name = "Custom Domain E-mail Subscription" + description = "Custom Domain E-mail Subscription for Event Notifications" + destination_id = "somedestinationid" + topic_id = "sometopicid" +} diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.usage.yml b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.usage.yml new file mode 100644 index 00000000000..40b7b6ced92 --- /dev/null +++ b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.usage.yml @@ -0,0 +1,8 @@ +version: 0.1 +resource_usage: + ibm_en_subscription_custom_email.subscription_custom_email_lite: + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1000 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 + ibm_en_subscription_custom_email.subscription_custom_email_standard: + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 1000 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 diff --git a/internal/resources/ibm/en_subscription_custom_email.go b/internal/resources/ibm/en_subscription_custom_email.go new file mode 100644 index 00000000000..8eaf0353a3b --- /dev/null +++ b/internal/resources/ibm/en_subscription_custom_email.go @@ -0,0 +1,182 @@ +package ibm + +import ( + "fmt" + + "github.com/infracost/infracost/internal/resources" + "github.com/infracost/infracost/internal/schema" + "github.com/shopspring/decimal" +) + +// EnSubscriptionCustomEmail struct +// +// Resource information: https://cloud.ibm.com/catalog/services/event-notifications#about +// Pricing information: https://cloud.ibm.com/catalog/services/event-notifications +type EnSubscriptionCustomEmail struct { + Address string + Region string + Name string + Plan string + EnSubscriptionEmail_OutboundCustomDomainEmailMessages *int64 `infracost_usage:"event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"` + EnSubscriptionEmail_OutboundTransmittedGB *float64 `infracost_usage:"event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"` +} + +// EnSubscriptionCustomEmailUsageSchema defines a list which represents the usage schema of EnSubscriptionCustomEmail. +var EnSubscriptionCustomEmailUsageSchema = []*schema.UsageItem{ + {Key: "event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, + {Key: "event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL", DefaultValue: 0, ValueType: schema.Int64}, +} + +// PopulateUsage parses the u schema.UsageData into the EnSubscriptionCustomEmail. +// It uses the `infracost_usage` struct tags to populate data into the EnSubscriptionCustomEmail. +func (r *EnSubscriptionCustomEmail) PopulateUsage(u *schema.UsageData) { + resources.PopulateArgsWithUsage(r, u) +} + +// BuildResource builds a schema.Resource from a valid EnSubscriptionCustomEmail struct. +// This method is called after the resource is initialised by an IaC provider. +// See providers folder for more information. +func (r *EnSubscriptionCustomEmail) BuildResource() *schema.Resource { + costComponents := []*schema.CostComponent{ + EnSubscriptionEmailOutboundCustomDomainEmailMessagesCostComponent(r), + EnSubscriptionEmail_OutboundTransmittedGBCostComponent(r), + } + + return &schema.Resource{ + Name: r.Address, + UsageSchema: EnSubscriptionCustomEmailUsageSchema, + CostComponents: costComponents, + } +} + +func EnSubscriptionEmailOutboundCustomDomainEmailMessagesCostComponent(r *EnSubscriptionCustomEmail) *schema.CostComponent { + + var costComponent schema.CostComponent + var quantity *decimal.Decimal + + component_name := "Outbound Custom Domain E-mail Messages" + component_unit := "Messages" + + if r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages)) + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} + +func EnSubscriptionEmail_OutboundTransmittedGBCostComponent(r *EnSubscriptionCustomEmail) *schema.CostComponent { + + var costComponent schema.CostComponent + var quantity *decimal.Decimal + + component_name := "Outbound Transmitted E-mail Messages" + component_unit := "GB" + + if r.EnSubscriptionEmail_OutboundTransmittedGB != nil { + quantity = decimalPtr(decimal.NewFromFloat(*r.EnSubscriptionEmail_OutboundTransmittedGB)) + } + + if r.Plan == "lite" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Lite plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + + } else if r.Plan == "standard" { + + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("%s (Standard plan)", component_name), + Unit: component_unit, + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: quantity, + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + PriceFilter: &schema.PriceFilter{ + Unit: strPtr("GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL"), + }, + } + } else { + costComponent = schema.CostComponent{ + Name: fmt.Sprintf("Plan %s not found", r.Plan), + UnitMultiplier: decimal.NewFromInt(1), + MonthlyQuantity: decimalPtr(decimal.NewFromInt(1)), + ProductFilter: &schema.ProductFilter{ + VendorName: strPtr("ibm"), + Region: strPtr(r.Region), + Service: strPtr("event-notifications"), + AttributeFilters: []*schema.AttributeFilter{ + {Key: "planName", Value: &r.Plan}, + }, + }, + } + costComponent.SetCustomPrice(decimalPtr(decimal.NewFromInt(0))) + } + + return &costComponent +} From 9766179995ceab2ee2783c21a021726c2cdce0eb Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:55:04 -0500 Subject: [PATCH 52/55] Account for free 20 emails in lite --- .../en_subscription_custom_email_test.golden | 2 +- .../resources/ibm/en_subscription_custom_email.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden index 7b4a0c9986f..0b00f0c66c9 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_custom_email_test/en_subscription_custom_email_test.golden @@ -2,7 +2,7 @@ Name Monthly Qty Unit Monthly Cost ibm_en_subscription_custom_email.subscription_custom_email_lite - ├─ Outbound Custom Domain E-mail Messages (Lite plan) 1,000 Messages $0.00 + ├─ Outbound Custom Domain E-mail Messages (Lite plan) (Max. 20) 20 Messages $0.00 └─ Outbound Transmitted E-mail Messages (Lite plan) 1 GB $0.00 ibm_en_subscription_custom_email.subscription_custom_email_standard diff --git a/internal/resources/ibm/en_subscription_custom_email.go b/internal/resources/ibm/en_subscription_custom_email.go index 8eaf0353a3b..c70e2589635 100644 --- a/internal/resources/ibm/en_subscription_custom_email.go +++ b/internal/resources/ibm/en_subscription_custom_email.go @@ -2,6 +2,7 @@ package ibm import ( "fmt" + "math" "github.com/infracost/infracost/internal/resources" "github.com/infracost/infracost/internal/schema" @@ -57,14 +58,12 @@ func EnSubscriptionEmailOutboundCustomDomainEmailMessagesCostComponent(r *EnSubs component_name := "Outbound Custom Domain E-mail Messages" component_unit := "Messages" - if r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages != nil { - quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages)) - } - if r.Plan == "lite" { + quantity = decimalPtr(decimal.NewFromFloat(math.Min(float64(*r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages), float64(20)))) + costComponent = schema.CostComponent{ - Name: fmt.Sprintf("%s (Lite plan)", component_name), + Name: fmt.Sprintf("%s (Lite plan) (Max. 20)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), MonthlyQuantity: quantity, @@ -78,6 +77,10 @@ func EnSubscriptionEmailOutboundCustomDomainEmailMessagesCostComponent(r *EnSubs } else if r.Plan == "standard" { + if r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages != nil { + quantity = decimalPtr(decimal.NewFromInt(*r.EnSubscriptionEmail_OutboundCustomDomainEmailMessages)) + } + costComponent = schema.CostComponent{ Name: fmt.Sprintf("%s (Standard plan)", component_name), Unit: component_unit, From 7c4ad86d1a31e535f549bdd3b480c039df835dc8 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 08:55:47 -0500 Subject: [PATCH 53/55] Sort --- infracost-usage-example.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/infracost-usage-example.yml b/infracost-usage-example.yml index a17551ab680..5d1018b81d7 100644 --- a/infracost-usage-example.yml +++ b/infracost-usage-example.yml @@ -105,17 +105,17 @@ resource_type_default_usage: messagehub_TERABYTE_HOURS: 1 messagehub_qty_terabytes: 1 messagehub_GIGABYTE_TRANSMITTED_OUTBOUNDS: 1 + event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 event-notifications_MILLION_INGESTED_EVENTS: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 event-notifications_OUTBOUND_DIGITAL_MESSAGES_PUSH: 0 - # event-notifications_GIGABYTE_TRANSMITTED_OUTBOUND_CUSTOM_DOMAIN_EMAIL: 1 - # event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 - # event-notifications_OUTBOUND_DIGITAL_MESSAGES_EMAILS: 0 - # event-notifications_OUTBOUND_DIGITAL_MESSAGES_HTTP: 0 - # event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 - # event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 - # event-notifications_PUSH_DESTINATION_INSTANCES: 1 - # event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 - # event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 + event-notifications_OUTBOUND_DIGITAL_MESSAGES_SMS_UNITS: 0 + event-notifications_OUTBOUND_DIGITAL_MESSAGE_CUSTOM_DOMAIN_EMAIL: 0 + event-notifications_PUSH_DESTINATION_INSTANCES: 1 + event-notifications_PUSH_PREPROD_DESTINATION_INSTANCES: 0 + event-notifications_RESOURCE_UNITS_NUMBER_MONTHLY: 1 + event-notifications_RESOURCE_UNITS_NUMBER_SETUP: 1 ibm_tg_gateway: connection: 3 From 4b3a9ccd67d1a171e1433b816540d04afa279525 Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Sun, 24 Nov 2024 09:01:24 -0500 Subject: [PATCH 54/55] Add more EN free resources --- internal/providers/terraform/ibm/registry.go | 58 ++++++++++++-------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/internal/providers/terraform/ibm/registry.go b/internal/providers/terraform/ibm/registry.go index 7bb1e02218d..0fe13fa6c16 100644 --- a/internal/providers/terraform/ibm/registry.go +++ b/internal/providers/terraform/ibm/registry.go @@ -53,9 +53,9 @@ var ResourceRegistry []*schema.RegistryItem = []*schema.RegistryItem{ var FreeResources = []string{ "ibm_appid_action_url", "ibm_appid_apm", + "ibm_appid_application", "ibm_appid_application_roles", "ibm_appid_application_scopes", - "ibm_appid_application", "ibm_appid_audit_status", "ibm_appid_cloud_directory_template", "ibm_appid_cloud_directory_user", @@ -65,8 +65,8 @@ var FreeResources = []string{ "ibm_appid_idp_google", "ibm_appid_idp_saml", "ibm_appid_languages", - "ibm_appid_mfa_channel", "ibm_appid_mfa", + "ibm_appid_mfa_channel", "ibm_appid_password_regex", "ibm_appid_redirect_urls", "ibm_appid_role", @@ -78,11 +78,12 @@ var FreeResources = []string{ "ibm_atracker_target", "ibm_cbr_rule", "ibm_cbr_zone", + "ibm_cd_tekton_pipeline", "ibm_cd_tekton_pipeline_definition", "ibm_cd_tekton_pipeline_property", - "ibm_cd_tekton_pipeline_trigger_property", "ibm_cd_tekton_pipeline_trigger", - "ibm_cd_tekton_pipeline", + "ibm_cd_tekton_pipeline_trigger_property", + "ibm_cd_toolchain", "ibm_cd_toolchain_tool_appconfig", "ibm_cd_toolchain_tool_artifactory", "ibm_cd_toolchain_tool_bitbucketgit", @@ -104,7 +105,6 @@ var FreeResources = []string{ "ibm_cd_toolchain_tool_securitycompliance", "ibm_cd_toolchain_tool_slack", "ibm_cd_toolchain_tool_sonarqube", - "ibm_cd_toolchain", "ibm_cloud_shell_account_settings", "ibm_cloudant_database", "ibm_code_engine_binding", @@ -115,61 +115,62 @@ var FreeResources = []string{ "ibm_container_addons", "ibm_cos_bucket_object_lock_configuration", "ibm_dns_custom_resolver", + "ibm_en_destination_ce", "ibm_en_email_template", "ibm_en_ibmsource", - "ibm_en_integration_cos", "ibm_en_integration", + "ibm_en_integration_cos", "ibm_en_source", "ibm_en_topic", "ibm_event_streams_schema", "ibm_event_streams_topic", + "ibm_iam_access_group", "ibm_iam_access_group_account_settings", "ibm_iam_access_group_dynamic_rule", "ibm_iam_access_group_members", "ibm_iam_access_group_policy", - "ibm_iam_access_group", "ibm_iam_account_settings", "ibm_iam_authorization_policy", "ibm_iam_service_api_key", "ibm_iam_service_id", "ibm_iam_service_policy", + "ibm_iam_trusted_profile", "ibm_iam_trusted_profile_claim_rule", "ibm_iam_trusted_profile_link", "ibm_iam_trusted_profile_policy", - "ibm_iam_trusted_profile", "ibm_is_lb_listener", - "ibm_is_lb_pool_member", "ibm_is_lb_pool", - "ibm_is_network_acl_rule", + "ibm_is_lb_pool_member", "ibm_is_network_acl", + "ibm_is_network_acl_rule", "ibm_is_placement_group", "ibm_is_public_gateway", + "ibm_is_security_group", "ibm_is_security_group_rule", "ibm_is_security_group_target", - "ibm_is_security_group", "ibm_is_share_delete_accessor_binding", "ibm_is_share_mount_target", "ibm_is_share_replica_operations", "ibm_is_ssh_key", + "ibm_is_subnet", "ibm_is_subnet_public_gateway_attachment", "ibm_is_subnet_reserved_ip", - "ibm_is_subnet", - "ibm_is_virtual_endpoint_gateway_ip", "ibm_is_virtual_endpoint_gateway", + "ibm_is_virtual_endpoint_gateway_ip", "ibm_is_vpc_address_prefix", "ibm_is_vpc_dns_resolution_binding", - "ibm_is_vpc_routing_table_route", "ibm_is_vpc_routing_table", + "ibm_is_vpc_routing_table_route", "ibm_is_vpn_gateway_connection", "ibm_is_vpn_server_client", "ibm_is_vpn_server_route", "ibm_kms_instance_policies", + "ibm_kms_key", "ibm_kms_key_policies", "ibm_kms_key_rings", - "ibm_kms_key", "ibm_pi_capture", - "ibm_pi_cloud_connection_network_attach", "ibm_pi_cloud_connection", + "ibm_pi_cloud_connection_network_attach", "ibm_pi_console_language", "ibm_pi_dhcp", "ibm_pi_ike_policy", @@ -177,9 +178,9 @@ var FreeResources = []string{ "ibm_pi_instance_action", "ibm_pi_ipsec_policy", "ibm_pi_key", - "ibm_pi_network_port_attach", - "ibm_pi_network_port", "ibm_pi_network", + "ibm_pi_network_port", + "ibm_pi_network_port_attach", "ibm_pi_placement_group", "ibm_pi_shared_processor_pool", "ibm_pi_spp_placement_group", @@ -196,27 +197,40 @@ var FreeResources = []string{ "ibm_scc_posture_profile_import", "ibm_scc_posture_scan_initiate_validation", "ibm_scc_posture_scope", - "ibm_scc_profile_attachment", "ibm_scc_profile", + "ibm_scc_profile_attachment", "ibm_scc_provider_type_instance", - "ibm_scc_rule_attachment", "ibm_scc_rule", - "ibm_scc_template_attachment", + "ibm_scc_rule_attachment", "ibm_scc_template", + "ibm_scc_template_attachment", "ibm_sm_arbitrary_secret", "ibm_sm_en_registration", "ibm_sm_iam_credentials_configuration", "ibm_sm_imported_certificate", + "ibm_sm_private_certificate", "ibm_sm_private_certificate_configuration_intermediate_ca", "ibm_sm_private_certificate_configuration_root_ca", "ibm_sm_private_certificate_configuration_template", - "ibm_sm_private_certificate", "ibm_sm_public_certificate_configuration_ca_lets_encrypt", "ibm_sm_public_certificate_configuration_dns_cis", "ibm_sm_secret_group", "ibm_sm_service_credentials_secret", "ibm_sm_username_password_secret", "ibm_tg_connection", + "ibm_en_destination_cos", + "ibm_en_destination_custom_email", + "ibm_en_destination_custom_sms", + "ibm_en_destination_msteams", + "ibm_en_destination_pagerduty", + "ibm_en_destination_slack", + "ibm_en_destination_sn", + "ibm_en_destination_webhook", + "ibm_en_slack_template", + "ibm_en_smtp_configuration", + "ibm_en_smtp_setting", + "ibm_en_smtp_user", + "ibm_en_webhook_template", } var UsageOnlyResources = []string{ From 6e781a527eafa9f6394f597999ad7e870d7bd1ee Mon Sep 17 00:00:00 2001 From: Luisa Rojas Date: Tue, 26 Nov 2024 14:59:39 -0500 Subject: [PATCH 55/55] Make note of one-time setup fee --- .../en_subscription_sms_test.golden | 42 +++++++++---------- internal/resources/ibm/en_subscription_sms.go | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden index 4ebd4f515d8..497162da932 100644 --- a/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden +++ b/internal/providers/terraform/ibm/testdata/en_subscription_sms_test/en_subscription_sms_test.golden @@ -1,25 +1,25 @@ - Name Monthly Qty Unit Monthly Cost - - ibm_en_subscription_sms.subscription_sms_lite - ├─ Outbound IBM Cloud SMS Message Units (Lite plan) (Max. 20) 20 Message Units $0.00 - └─ SMS Number Setup Resource Units (Lite plan) 1 Resource Units $0.00 - - ibm_en_subscription_sms.subscription_sms_standard - ├─ Outbound IBM Cloud SMS Message Units (Standard plan) 1,000 Message Units $16.15 - └─ SMS Number Setup Resource Units 1 Resource Units $1.00 - - ibm_en_subscription_sms.subscription_sms_standard_no_usage - ├─ Outbound IBM Cloud SMS Message Units (Standard plan) Monthly cost depends on usage: $0.01615 per Message Units - └─ SMS Number Setup Resource Units 1 Resource Units $1.00 - - ibm_resource_instance.event_notifications["lite"] - └─ Lite Plan 1 Instance $0.00 - - ibm_resource_instance.event_notifications["standard"] - └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events - - OVERALL TOTAL $18.15 + Name Monthly Qty Unit Monthly Cost + + ibm_en_subscription_sms.subscription_sms_lite + ├─ Outbound IBM Cloud SMS Message Units (Lite plan) (Max. 20) 20 Message Units $0.00 + └─ SMS Number Setup Resource Units (Lite plan) 1 Resource Units $0.00 + + ibm_en_subscription_sms.subscription_sms_standard + ├─ Outbound IBM Cloud SMS Message Units (Standard plan) 1,000 Message Units $16.15 + └─ SMS Number Setup Resource Units (One-time Fee) (Standard plan) 1 Resource Units $1.00 + + ibm_en_subscription_sms.subscription_sms_standard_no_usage + ├─ Outbound IBM Cloud SMS Message Units (Standard plan) Monthly cost depends on usage: $0.01615 per Message Units + └─ SMS Number Setup Resource Units (One-time Fee) (Standard plan) 1 Resource Units $1.00 + + ibm_resource_instance.event_notifications["lite"] + └─ Lite Plan 1 Instance $0.00 + + ibm_resource_instance.event_notifications["standard"] + └─ Ingested Events Monthly cost depends on usage: $1.08 per Million Events + + OVERALL TOTAL $18.15 ────────────────────────────────── 5 cloud resources were detected: ∙ 5 were estimated, 2 of which include usage-based costs, see https://infracost.io/usage-file \ No newline at end of file diff --git a/internal/resources/ibm/en_subscription_sms.go b/internal/resources/ibm/en_subscription_sms.go index bafe13452f4..3cf8e3f1151 100644 --- a/internal/resources/ibm/en_subscription_sms.go +++ b/internal/resources/ibm/en_subscription_sms.go @@ -97,7 +97,7 @@ func EnSubscriptionSMSNumberSetupResourceUnitsCostComponent(r *EnSubscriptionSms } costComponent = schema.CostComponent{ - Name: component_name, + Name: fmt.Sprintf("%s (One-time Fee) (Standard plan)", component_name), Unit: component_unit, UnitMultiplier: decimal.NewFromInt(1), MonthlyQuantity: quantity,