-1

So I started by trying to find the service code for RDS instances to use with the pricing API's .get_products() method. But when I used .describe_servies() and went through there list of services, I couldn't find a service for RDS instances. So is there a method through Boto3 to find the on-demand price of each rds instance?

I was trying to replicate something like this, but for rds: Use boto3 to get current price for given EC2 instance type

EDIT: When I use:

>>> import boto3
>>> client = boto3.client('pricing', region_name='us-east-1')
>>> response = client.describe_services()
>>> for x in response['Services']:
...     print(x['ServiceCode'])

I get this list that doesn't include rds:

  • A4B
  • AMAZONROUTE53REGIONALCHINA
  • AWSAmplify
  • AWSAppRunner
  • AWSAppSync
  • AWSApplicationMigrationSvc
  • AWSBackup
  • AWSBudgets
  • AWSCertificateManager
  • AWSCloudFormation
  • AWSCloudMap
  • AWSCloudTrail
  • AWSCodeArtifact
  • AWSCodeCommit
  • AWSCodeDeploy
  • AWSCodePipeline
  • AWSConfig
  • AWSCostExplorer
  • AWSDataExchange
  • AWSDataSync
  • AWSDataTransfer
  • AWSDatabaseMigrationSvc
  • AWSDeepRacer
  • AWSDeveloperSupport
  • AWSDeviceFarm
  • AWSDirectConnect
  • AWSDirectoryService
  • AWSELB
  • AWSElasticDisasterRecovery
  • AWSElementalMediaConvert
  • AWSElementalMediaLive
  • AWSElementalMediaPackage
  • AWSElementalMediaStore
  • AWSElementalMediaTailor
  • AWSEvents
  • AWSFMS
  • AWSGlobalAccelerator
  • AWSGlueElasticViews
  • AWSGlue
  • AWSGreengrass
  • AWSGroundStation
  • AWSIoT1Click
  • AWSIoTAnalytics
  • AWSIoTEvents
  • AWSIoTSiteWise
  • AWSIoTThingsGraph
  • AWSIoT
  • AWSLakeFormation
  • AWSLambda
  • AWSMediaConnect
  • AWSMigrationHubRefactorSpaces
  • AWSNetworkFirewall
  • AWSOutposts
  • AWSQueueService
  • AWSR53AppRecoveryController
  • AWSResilienceHub
  • AWSRoboMaker
  • AWSSecretsManager
  • AWSSecurityHub
  • AWSServiceCatalog
  • AWSShield
  • AWSStorageGatewayDeepArchive
  • AWSStorageGateway
  • AWSSupportBusiness
  • AWSSupportEnterprise
  • AWSSystemsManager
  • AWSTransfer
  • AWSWisdom
  • AWSXRay
  • AlexaTopSites
  • AlexaWebInfoService
  • AmazonA2I
  • AmazonApiGateway
  • AmazonAppStream
  • AmazonAthena
  • AmazonBraket
  • AmazonChimeBusinessCalling
  • AmazonChimeCallMeAMCS
  • AmazonChimeCallMe
  • AmazonChimeDialInAMCS
  • AmazonChimeDialin
  • AmazonChimeFeatures
  • AmazonChimeServices
  • AmazonChimeVoiceConnector
  • AmazonChime
  • AmazonCloudDirectory
  • AmazonCloudFront
  • AmazonCloudSearch
  • AmazonCloudWatch
  • AmazonCognitoSync
  • AmazonCognito
  • AmazonConnect
  • AmazonDAX
  • AmazonDetective
  • AmazonDevOpsGuru
  • AmazonDocDB
  • AmazonDynamoDB
  • AmazonEC2
  • AmazonECR
  • AmazonECS
  • You should include your code. – jarmod May 23 '22 at 16:56
  • RDS pricing appears to be [available programmatically](https://aws.amazon.com/about-aws/whats-new/2015/12/announcing-aws-price-list-api-programmatic-access-to-aws-prices/). Unsure how this might be exposed in boto3. – jarmod May 23 '22 at 17:35
  • @jarmod Thank you. I was just frustrated because there is absolutely no information about pulling on-demand pricing for rds instances using boto3 on google. – Raqib Zaman May 23 '22 at 17:42
  • There's a [paginator](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/pricing.html#paginators) available for describe_services or, as @asdfg suggests, simply request the specific service with the name "AmazonRDS". One way to confirm this name is to use the awscli: `aws pricing describe-services|grep -i RDS` – jarmod May 23 '22 at 17:59

1 Answers1

1

try

response = client.describe_services(
    ServiceCode="AmazonRDS"
)

The reason you are not seeing AmazonRDS printed is because the response probably contains NextToken and you are ignoring it. Read the documentation of what NextToken is and how to use it.

P.S.: Be polite to people who are trying to help you but has no obligation to do so whatsoever.

Asdfg
  • 11,362
  • 24
  • 98
  • 175